The Way to Neat Code
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 1: Professionalism
Before opening the reading of this book, it is inevitable to ask yourself a question, and depending on the answer to this question, you will decide your attitude towards the reading of this book.
Do you want to be a "professional"? You do want to be a professional software engineer, right?
If the firm answer is - "Yes -----!" , then tune in to listen to Uncle Bob's pontificating about his 40+ years of programming experience~!
1.1 Be clear about what you want
If you want to be a professional, you must take responsibility.
"Professionalism" is not only a symbol of honor and pride, but also clearly implies responsibility and duty.
It's impossible to gain honor and pride from something you can't be responsible for.
1.2 Assumption of responsibility
It is irresponsible to deliver software without testing the routines.
Uncle Bob is the "Engineer in Charge" of a software program that controls a small-computer system for measuring the quality of telephone lines and a crisis system, written in assembly language. The system runs a "nighttime routine" every night to test the lines, and Bob delivers the new system program to the user without testing it in order to keep the new feature on schedule, resulting in a succession of bug fixes that cost the user and the manager money.
How can I be held accountable?
1.3 First, do no harm
1.3.1 Do not disrupt software functionality
Can't develop a perfect program, then be responsible for your imperfections.
A professional is someone who can be held accountable for the mistakes they make, even if those mistakes are actually inevitable.
So the first thing we need to practice is "apologizing", which is necessary, but not sufficient. It is not enough to make the same mistake over and over again.
With more professional experience, your error rate should decrease rapidly, even asymptotically approaching zero. Failure rate can never equal zero, but it is your responsibility to keep it infinitely close to zero.
The specific performance is given here:
-
Make it impossible for QA to find any problems
-
To be sure the code is working
It's important to do 100% testing of the content of the code you write, but isn't some code hard to test? Yes, but the reason it is hard to test is because it was not designed with testing in mind. The only solution is to design code that is easy to test, preferably by writing the tests first and then the code to be tested, an approach calledTest Driven Development (TDD)。
-
Automated QA
As a developer, you need to have a relatively quick and reliable mechanism for determining whether the code you've written works properly and doesn't interfere with the rest of the system. Therefore, your automated tests should at least be able to let you know that your system is likely to pass QA.
1.3.2 Do not damage the structure
Mature professional developers know that smart people don't break the structure to release new features.
Well-structured code is more flexible. Sacrificing structure is not worth the cost and will be regretted in the future.
The fundamental guiding principle of all software projects is that the software should be easy to modify. To build a rigid structure against this principle undermines the economic model that frames the entire industry.
The only way to prove that software is easy to modify is to make some actual modifications.
When should you make these small, simple changes? Anytime! Focus on whichever module you want to improve the structure by making a few simple changes to it. You can also tweak the structure from time to time each time you read through the code.
If you find it cumbersome to re-test after making changes, it shows the importance of mastering the testing methodology.
1.4 Professional ethics
Career development is your own business. Your employer is not obligated to ensure that you are invincible in the workplace, nor is it obligated to train you, send you to conferences or buy you books to recharge your batteries. It's all up to you. The software developer who is counting on his or her employer for his or her career development is going to be miserable.
You should plan to work 60 hours a week. The first 40 hours are for your employer and the last 20 hours are for yourself. In those remaining 20 hours, you should read, practice, study, or do other things that will enhance your career.
Maybe you don't want to be that diligent. That's fine. It's just that then you can't consider yourself a professional, because there are specialties that you need to invest time in pursuing.
-
Know your field
Overall, the vast majority of those hard-won ideas of the past 50 years are as valuable, if not more valuable, today as they were in the past.
Listed below are the things that every professional software developer must be proficient in:
-
design pattern.. Must be able to describe all 24 patterns in the GOF book and also have hands-on experience with most of the patterns in the POSA book.
-
Design Principles. It is important to understand the SOLID principles and to have a deep understanding of component design principles.
-
Methods.Must understand XP, Scrum, Lean, Kanban, Waterfall, Structured Analysis and Structured Design.
-
fulfill. Must have knowledge of test-driven development, object-oriented design, structured programming, continuous integration, and pair programming.
-
Workpiece.Must understand how to use UML diagrams, DFD diagrams, structure diagrams, Petri network diagrams, state migration diagrams, flowcharts and decision tables.
-
persistent study
Read books, read relevant articles, follow blogs and tweets, attend technical conferences, visit user groups, and get more involved in reading and study groups. If you don't know something, learn it, don't shy away from it. If you are a .NET programmer, learn Java; if you are a Java programmer, learn Ruby; if you are a C programmer, learn Lisp; if you really want to practice your brain, learn Prolog and Forth!
-
practice
Excellence in work is based on hard work. True professionals tend to learn and work hard in order to refine their skills. It is not enough to call it practicing just to do the daily work, it is only a kind of executional operation, not practicing. To practice means to specialize in the practice of skills in addition to daily work, with a view to self-improvement.
The authors here point to "kata" type exercises, similar to brushing leetcode to solve small unit problems.
-
collaborative
Professional software developers tend to try harder to program, practice, design, and plan with others so they can learn a lot from each other and get more work done in less time and with higher quality.
-
give advice (in study)
The best way to get a quick and firm grasp of certain facts and ideas is to share them with the person you are responsible for mentoring. In this way, the mentor will benefit from the teaching and learning as well.
-
Understanding the business area
Every professional software developer is obliged to understand the business area for which he or she is developing a solution. If you write financial systems, you should know about the financial domain; if you write travel applications, then you need to get to know the travel industry. You don't necessarily need to be an expert in the field, but you still need to put in the work and considerable effort to recognize the business domain.
-
Alignment with employers/clients
Your employer's problems are your problems. You must figure them out and seek the best solutions. Every time you develop a system, you should put yourself in the employer's shoes and make sure that the features you develop truly meet the employer's needs.
-
unpretentious
Programming is a creative activity. Writing code is the process of creating something out of nothing; we boldly create order out of chaos. We confidently issue precise and accurate commands, and the slightest mistake and misbehavior of the machine can cause incalculable damage. Programming is therefore also an act of extreme self-importance.
However, professionals also know that they will fall on their face, that there are times when their risk assessment is wrong, and that there are times when they are out of their depth. At these times, if they look in the mirror, they will see the egotistical fool grinning at them.
Thus, the professional is the first to laugh when he finds himself the butt of a joke. He never mocks others; he accepts it when he makes a fool of himself. Instead, he laughs it off. He doesn't disparage others for their mistakes because he knows that he could be the next one to make a mistake.