Column | chapter nine algorithm

Url | www.jiuzhang.com

The ultimate nightmare for programmers is probably ancestral code.

Many code farmers have experienced such moments. When Jin Jin Ye ye checks the previous code, you find a loophole that is so obvious that you feel mentally retarded. Seriously, you are ready to make drastic changes, but your old driver colleagues may advise you not to move, and show a meaningful expression.

Because they know you’ve run into the family code.

What is an ancestral code

Legacy code is literally the “treasure trove” of code left to you by your predecessors. There are problems with the code, but either you can’t fix it or you can’t fix it, which is why the treasure trove has been handed to you for so long.

For example, you might come across code like this.

//add by XXXX 201x-x-x: this is a magical piece of code. That’s the right way to write it anyway

Or something like

“I didn’t believe there was a code for quitting,

Until I came across the heirloom code.”

– By the net friend

Almost every company has an ancestral code

Every company has some “legacy issues”. Amazon engineers describe their code as “a big mountain of shit, the biggest mountain you’ve ever seen, and every time you want to fix a bug, your job is to climb right into the middle of it.”

Some Internet users have found Microsoft’s ancestral code.

Read several years of Windows kernel code, also just look, can not change. Sometimes you see some strange logic, don’t panic, there must be a long story. But nothing is absolute. Once I was debugging a blue screen with my colleague, and I saw a piece of kernel memory management code. There was a place I didn’t understand, it seemed that the for loop was repeated once. Well, it must be our poor understanding. Then we looked at it all afternoon and came up with several plausible explanations. To be sure, we plucked up the courage to write to Landy (now a Tech fellow), then the big shot of Windows memory management. We got a quick response.” It is a bug since day 1. I have just checked in a fix. So a bug that had been hidden for more than ten years from NT was discovered by two small white people.

— By Zhihu @Tim Chen

There’s some family code, you move, we can’t go back

Our group has a famous 6000-line back-end JS with no object-oriented wrapper, relying solely on functions. There are several thousand-line functions with more than two dozen parameters, several flag bits, and a dozen numeric states. A comment? Don’t have. Everyone who has taken over this code will accidentally send a friend moments to show their admiration. But amazingly, the code doesn’t have much to go wrong with its execution. Until a few months ago, a big guy rewrote the entire code before leaving, leaving a bug that hasn’t been completely fixed yet.

– by the net friend

Maybe you just want to change a comment, but the following scenario occurs.

Sometimes, ancestral code can be used to create jobs

When I first came to the company, it was a straightforward thing to look at the old code and think why the logic was so convoluted, you had to go around in circles, you didn’t have to share a function and you had to implement a common function, and the common function turned out to be super complicated. Later, I found that those responsible for the stable module were all fired, and I understood the good intentions of uncle Uncles. How difficult it is to keep jobs in certain industries in certain countries! — Zhihu netizen @brick

How is an heirloom code passed down from generation to generation

Faced with the family code, every programmer who takes over will add something new, but no one has the courage to actually solve it, after all, no one wants to dig a hole for themselves.

Many industries are predecessors trees descendants cool, but the program ape is a lot of time predecessors dug holes, posterity fill holes.

Let’s hope the ape world leaves more room for future generations.

Welcome to follow my wechat official account: Ninechapter.



Elite programmer exchange community, regular release of interview questions, interview skills, job information, etc