Rebirth 2010: I taught Mr. Lei how to make a mobile phone

Chapter 5 What is defense, sexual programming?

Chapter 5 What is defense, sexual programming?

Then I looked at the control panel and there was no abnormal error.

Open the web page, enter the address, click the function with the mouse, everything works fine.

In this way, several functions are completed.

Chen Mo moved his fingers and said, "In fact, the normal process is to write unit tests first and then implement functions, but firstly, time is limited, and secondly, I don't need to write unit tests at this level.

This way, your work on this project is completed, and you should not have to work overtime in the next few days."

Qi Mengmeng watched with her own eyes as the code grew bigger and bigger, becoming more and more full of mysterious rules, and her face was filled with awe.

In the master's hands, these codes are like obedient children, following orders and being extremely obedient.

The function that was originally planned to be her weekly workload did not last more than a quarter of an hour in her master's hands.

She checked the time, 13 minutes and 14 seconds. This was the gap between her and her master.

"All of these things have a unified name, called defensive programming!"

I don’t know if it was an illusion, but Qi Mengmeng felt that the master paused for some reason at the end of his speech.

"What is defensive programming?"

Chen Mo sat back in his seat, hooked his finger at the other party, and motioned him to come over.
"Defensive programming is a careful, cautious approach to programming.

It requires programmers to foresee possible problems when writing code and take steps in advance to avoid them.

This programming habit pays more attention to error prevention and control to reduce possible catastrophic consequences.

The code demonstration just now is the usage of the orthodox school. As the saying goes, the devil is always one step taller than the righteous.

What I am going to teach you next is the evil use of defensive programming.

In fact, there was nothing like this before. As the game between companies and employees intensifies, the latter are often at an absolute disadvantage.

Some predecessors have come up with this idea, that is, by writing obscure code, they can hold some bargaining chips in their hands. Even if they are laid off in the end, they must make the code they are responsible for unmaintainable!

Thereby enhancing your own "irreplaceability" to a certain extent and achieving the goal of making the company afraid to take any action!

If it weren't for the fact that you are my apprentice, I would not easily show this move to others, because once it is used, it will inevitably lead to serious consequences, just like the Seven Injury Fist, which will hurt others and yourself.

However, my current skills are so profound that I can already ignore this side effect."

As he spoke, Chen Mo found the code of the main functional module that he was previously responsible for and fell silent.

At this moment, he looked back at the codes he had written before and found them simply unbearable. They were just for the sake of completing functions and there was no elegance at all. They were slightly better than Qi Mengmeng's code, but only to a limited extent.

After a while, Chen Mo tilted the screen slightly towards Qi Mengmeng.

This time Chen Mo started working at full power, his hands clacking away at the keyboard so quickly that one could see afterimages. This was a skill that only came from the fusion of rich experience and a young body.

This made him very satisfied with his current state. It was great to be young. Then he heard Qi Mengmeng's suppressed exclamation.
"Wow, Master, you are so fast." This is not a good thing to say.
Chen Mo's eyes twitched, and the smooth tapping sound in his hands paused for a moment, and the speed was slightly reduced.
The original code was changed beyond recognition. Of course, Chen Mo did not continue to add on to it like playing with building blocks, but made it as complicated as possible.

Nested loops and advanced syntax encapsulate layers of "security doors" in the code, including but not limited to code, configuration files, and databases.
The code that originally only required 20 lines to implement the function quickly expanded to nearly a thousand lines in just a few minutes. Don’t underestimate it. At first glance, it is full of the beauty of code. If you read it carefully, it will make your scalp numb. The more skilled the players are, the easier it is to get caught up in it and unable to extricate themselves.

It is equivalent to taking something that could be explained in one or two sentences and putting it into dozens of chapters. For example, a group of bandits suddenly appeared on the hillside, and upon closer inspection, they turned out to be the 108 Liangshan generals. They are "Song Jiang, Wu Yong, Lu Junyi, Lin Chong." After reading the names, the nicknames are read, and then the background ties are all added.
One look at him makes people curse, he is simply not a human being.

While writing code, every time Chen Mo wrote a short paragraph, he would explain its meaning to Qi Mengmeng in a simple and easy-to-understand way.

Qi Mengmeng looked at the pile of codes in front of her. Under her master's magic, they were constantly disassembled, broken up, merged, and reorganized, until they became completely incomprehensible. Her face was full of shock.

At this time, an employee passed by.

He had originally passed by Chen Mo's workstation, his ears moved slightly, he exclaimed, turned back, and then began to watch with relish from behind.

[Chen Mo's coding speed has increased, almost catching up with me. Is there any benefit to slapping the boss? ]

[Hey, why do we need to change these codes that have been tested? ]

[Is this an optimization? No, this level of change is already a refactoring. Refactoring now? It’s almost acceptance time, isn’t this just looking for trouble? ]

[Hmm? This grammar can be written like this? I learned a trick, it was worth reading. ]

[But it looks like reverse refactoring, and it's getting more and more complicated. Can it still work? Weird.]

The expression on this guy's face gradually changed from curiosity to confusion, and then he listened to Chen Mo's explanation, his expression switched back and forth between confusion and sudden realization, like a traffic light nailed at a crossroads.
Half an hour later, when Chen Mo reconstructed the core logic of his previous code, the program started to execute without any errors. After a few minutes, the entire process was completed in one go.

"This is called defensive programming. Do you understand?"

Qi Mengmeng stared with her big confused eyes and shook her head as expected, she saw it but didn't understand it.

Chen Mo nodded with relief, "It's right that you can't understand it. Maybe in a few days, when I come to look at the code I wrote, you won't understand it. This is the highest realm of seeing codes in the eyes but not in the heart.

So I can only wish Wang Defa good luck, and hope that there will be no changes when these functions are accepted later, otherwise."

"What else?"

Chen Mo made a flower shape with his hands and said "BOOM".
“Art is an explosion!”

As an intern, Qi Mengmeng was not concerned about whether the system could pass the acceptance inspection. She was a little curious.
"Master, didn't you need to think when you were typing the code just now? It was done in one go, simply..." She couldn't think of any adjectives for a moment, and finally could only give a thumbs up.

"I have been thinking about it. At the beginning, I stopped for a minute to think about how to build the code structure. Then, when I was typing this code, I had already predicted the next code in my mind, just like the oil seller, who only learns by practice.

These are all things you will learn in the future. If I tell you too much, you won’t be able to remember them. Okay, today I have taught you a lot. You should digest it first.”

Chen Mo was about to get some water with the cup in his hand. When he stood up, he found that someone was standing still behind him.

Like a statue.

Collect and you won’t get lost, read and you can get rich!



(End of this chapter)

Tap the screen to use advanced tools Tip: You can use left and right keyboard keys to browse between chapters.

You'll Also Like