Location>code7788 >text

The Way to Neat Code - Reading Notes (11)

Popularity:189 ℃/2024-09-19 11:23:09

The Way to Neat Code

image-20240904225436374

Synopsis:

This book is a summary of the experience of programming guru "Uncle Bob" over 40 years of programming career, explaining what kind of attitude, what kind of principles and what kind of actions are needed to become a real professional programmer. The author takes the detours and mistakes made by himself and his colleagues as examples, with the intention of guiding those who come after him and helping them to take a higher step in their careers.

This book is suitable for all programmers and can be used as a reference for all those who want to become professionally literate in the workplace.

Chapter 11 Pressure

img

Imagine an out-of-body experience: you see yourself lying on an operating table while a surgeon performs open-heart surgery on you. The surgeon is trying his best to save your life, but time is running out, which means that every move he makes is a matter of life and death for the patient - your life is on the line. How do you expect the surgeon to behave? Do you expect him to be calm and organized? Do you expect him to order his assistants clearly and precisely? Do you want him to stick to the surgical procedure exactly as he was trained to do it? Or do you want him to sweat and curse? Do you want him to throw surgical instruments around and clunk things? Do you want him to be full of resentment, blaming management for setting unrealistic surgery times and yelling all the time that he doesn't have enough time?

Do you expect him to act like a professional, or like the kind of do-gooder we commonly see in some developers?Even under pressure, the professional developer is calm and decisive. Despite the mounting pressure, he stays true to the training and discipline he has received, knowing that these are the best ways he can overcome the sense of pressure brought on by deadlines and commitments.

1 Avoid stress

The best way to stay calm under stress is to avoid situations that cause stress. Avoidance may not completely eliminate stress, but it can significantly reduce stress and shorten the duration of high stress periods.

Commitment:

It is important that we avoid committing ourselves to deadlines that we are not sure we can meet.

The business side always expects to get these commitments because they want to eliminate the risks. What we need to do is quantify the risks and state them to the business side so they can prepare accordingly. Making unrealistic promises hinders the achievement of goals and is not good for the company or the individual.

keep in good repair

The way to fast forward to ensure deadlines is to keep things tidy.

Stress can be avoided by making the system, code, and design as neat as possible. This is not to say that we should spend endless hours cleaning up code, but simply that chaos should not be tolerated. Messiness slows down speed, leads to delays and broken promises. Therefore, do your best to keep the output neat and clean.

Discipline in the midst of crisis:

Choose those principles of discipline that you would still follow in a time of crisis and follow them in all your endeavors.

Adhering to these disciplinary principles is the best way to avoid getting into a crisis. And don't change your behavior when adversity strikes. If the disciplinary principles you follow are the best way to do your job, then firmly uphold them even in a deep crisis.

2. Coping with stress

Don't panic:

Coping with stress properly. Long nights with no desire to sleep do not help to solve problems faster. Sitting around being irritable doesn't help either. And the worst mistake you can make is to be reckless and hasty! Avoid the idea of throwing your life away. Rushing will only lead you deeper into the abyss. Instead.To relax. Think deeply about the problem. Strive to find the path that will lead to the best possible outcome, and then follow that path at a reasonably steady pace.

Communication:

Let your team and supervisors know that you are in the middle of a difficult situation. Tell them the best plan you have developed to get out of the situation. Ask for their support and guidance. Avoid the panic that arises. Nothing makes you more angry and irrational than panic. Panic can increase your stress level tenfold.

Rely on your disciplinary principles:

Instead of panicking and looking around in a daze for something else to fall back on, rely calmly and intently on your own disciplined principles, which will help you get out of the rut faster. (If you're following TDD, you'll be writing even more tests than usual. If you're a firm believer in relentless refactoring, this is the time to refactor more. If you believe in keeping functions as small as possible, this is the time to make them smaller. The only way to beat the stress ordeal is to rely on what you already know works - your usual discipline.)

Seek help:

Twinning! When the mind boggles, find a partner who is willing to pair program with you. You'll move forward faster with fewer flaws. A twinning partner will help you keep your principles and stop your insanity. A partner will catch things you miss, will suggest helpful ideas, and will pick up the slack when you lose focus and keep going. Similarly, when you see other people under pressure, reach out and work in pairs with them to help them out of a difficult situation.

3. Conclusion

  • The trick to dealing with stress is to avoid it as much as possible when you can, and to face it head on when you can't.
  • Pressure can be avoided by making deliberate commitments, following your own disciplinary principles, and keeping tidy.
  • When facing pressure head-on, it is important to remain calm, communicate more with others, stick to your principles of discipline, and seek help from others.