The Clean Coder (Part I)

来源:互联网 发布:星际争霸1 mac 编辑:程序博客网 时间:2024/05/22 03:48

“The Clean Coder” is a name of a book. It’s also the kind of person I want to be. Several days ago, I went to my class advisor and asked, “How long will it take to read this book”. He said, “It won’t take you much time. Ten hours is totally enough.” Reading English books is always a grind for me. This one is no exception. Sadly and expectedly, it took me 20 hours to finish it.

 

In the second page of this book, there is very brief introduction of Uncle Bob’s writing, which says, The Robert C. Martin Series is directed at software developers, team-leaders, business analysts, and managers who want to increase their skills and proficiency to the level of a Master Craftsman.” I belong to none of these types mentioned above. I’m just a newbie who know little about software development. But still, with determination and bravery, I picked up the book and read it. This book can be counted as a definitive guidebook of how to become a professional, a craftsman and a master. I’m dreaming about being a master. So it’s worth my time reading it.

 

To be professional, we should first know the precise definition of professionalism and what it takes to be a professional. “It is an attitude of honesty, of honor, of self-respect, and of pride. It is a willingness to accept the dire responsibility of being a craftsman and an engineer. That responsibility includes working well and working clean. It includes communicating well and estimating faithfully. It includes managing your time and facing difficult risk-reward decisions.”The key point of professionalism is taking responsibility. With knowledge comes the responsibility to act! The same philosophy can be found in the movie“Spider Man”, which is “With great power comes great responsibility.”

 

Throughout the book, Uncle Bob shared with us many of his personalworking practices------He’s been fired. He’s lauded. He’s been a team leader, a manager and even a CEO. He’s worked with brilliant programmers as well as slugs. He’s worked on high-tech cutting-edge embedded software/hardware systems. He’s worked on projects as trivial as a corporate payroll system. Of course, he has programmed in a variety of programming language, such as COBOL,FORTRAN, BAL, PDP-8, PDP-11, C, C++, Java, Ruby and Smalltalk. What an exciting and rich life he has lead. These practices mean a lot to me. Because they make me realize my misunderstanding of my career. “ You don’t have to be in one of the top companies and do a significant project to demonstrate your talent and creativity. Don’t be afraid of making mistakes. Learn to fail, or fail to learn!” I said this to myself.

Uncle Bob then talked about his first job as a programmer. At that time, coding was an effortful and arduous job. While reading these old time programming stories, I felt embarrassed, shameful and even guilty. To some extent, they inspired me. Now that these old time programmers can get through this tough period, I believe I can conquer any difficulty confronted with me when coding.

 

So, how to behave like a professional?

Compared to nonprofessional, it’s much harder to be a professional.Professionals must take responsibility for their own job-----there are no other people they can rely on. As a professional, you should do no harm to both the function and structure of the software. You must create as few bugs as possible. But the fact is that bugs will always exist in your code. It’s your job to fix them and you must learn to apologize when your software collapses. Before giving the deliverable to QA, test it as many times as you can to make sure it works.

 

Work ethics of professionals

No one is coming. Your career is your responsibility. It’s not your employer’s responsibility to make sure you are marketable. That is to say, you should make yourself more adequate and more competent. You should plan on working 60 hours per week. The first 40 are for your employer. The remaining 20 are for you. During this remaining 20 hours you should be reading, practicing, learning, and otherwise enhancing your career.

 

Here are some specific work ethics

1.      Know your field.

Other than have a good knowledge of the ideas, disciplines, techniques, tools, and terminologies in ITfield, you should constantly be increasing your knowledge. Though our field is progressing very rapidly, it’s good for you to know ideas and techniques of th epast. This kind of knowledge will certainly give you some insights and inspiration.

2.      Continuous learning.

“Read books,articles, blogs, tweets. Go to conferences. Go to user groups. Participate in reading and study groups. Learn things that are outside your comfort zone. If you are .NET programmer, learn Java. If you are a Java programmer, learn Ruby.If you are a C programmer, learn Lisp. If you want really bend your brain,learn Prolog and Forth!” Just as The Pragmatic Programmer : From Journeyman to Master”says, “Learn a new language each year.”

3.      Practice.

As an old saying states,“Practice makes perfect.” That’s true. Practice is an essential part of making you more skillful and more proficient. Uncle Bob has a wonderful metaphor here, “Consider how musicians master their craft. It’s not by performing. It’s by practicing. And how do they practice? Among other things,they have special exercises that they perform. Scales and etudes and runs. They do these over and over to train their fingers and their mind, and to maintain mastery of their skill.”

4.      Collaboration.

By collaborating with others, we can spot our own defects and weaknesses and learn something from them. Above all, we can be more efficient and productive while we cooperating.

5.      Mentoring.

.“The best way to learn is to teach.” About mentoring, Albert Einstein has a very classic and interesting remark, “You do not really understand something unless you canexplain it to your grandmother.” (I just read this sentence from another book and I didn’t verify it.)

6.      Know your domain.

“If you are writing an accounting system, you should know the accounting field. If you are writing a travel application, you should know the travel industry. You don’t have to be a domain expert, but there is a reasonable amount of due diligencethat you ought to engage in.” “Interview your customers and users about the foundation and basics of the domain.”

7.      Identify with your employer/customer.

That means understand in-depth of your customers’ problems. When you are coding for a project, try to code from the customers’ perspective and care about their needs.

8.      Humility

That’s right, humility.Uncle Bob’s argument is compelling, so I’ll just quote him.

“Professionals know they are arrogant and are not falsely humble. A professional knows his job and takes pride in his work. A professional is confident in his abilities, and takes bold and calculated risks based on that confidence. A professional is not timid.

However a professional also knows that there will be times when he will fail, his risk calculations will be wrong, his abilities will fall short; he’ll look in the mirror and see an arrogant fool smiling back at him.

So when a professional finds himself the butt of a joke, he’ll be the first to laugh. He will never ridicule others, but will accept ridicule when it is deserved and laugh it off when it’s not. He will not demean another for making a mistake,because he knows he may be the next to fail.”

 

 

How to behave

1.      Say no.

This chapter may be the most controversial section of the book. Based on your expertise, you should firmly say no to your supervisor, your manager and customer, when they have an unreasonable and harsh request. Rushing to complete is always the source of bugs and crashes. As a professional, it’s your accountability to guarantee your software are free of insidious and devastating bugs, passes all tests, have complete functionality and works.

There is much more to say about this strategy. If you have interest, I strongly suggest you read “Chapter2: Saying No” of this book.

2.      Say yes.

The strategy of saying yes prevents you from breaking your promises. You should understand the true meaning of “try”and “yes” .

原创粉丝点击