前阵子看完了《The Pragmatic Programmer: From Journeyman to Master》,虽然该书是1999年发行的,也没有新版本出来,但读了之后还是感觉受益良多。
先说说不够好的方面。程序开发方面的知识和技术变化非常快,书中知识点可能都没跟上时代的脚步,比如介绍版本控制(Source Control)时就没有提高当前最流行的Git。书中也没有讲到怎么利用社交媒体来提升自身的价值。书里的知识点有些缺乏足够的案列来介绍具体该如何操作,只有对于有相关经验的开发者才能体会到书里表述的信息。所以书里讲得虽然好,还是需要更多的实践去累计其经验。
当然好的方面远远多很多。书里的知识是经过了作者数十年的经验累积总结下来的,这么多年里也获得了众人的认可。书中涵盖的软件开发方面的内容非常的广泛,从如何开始开发,怎么开发,到之后如何协作维护,最后文档总结归纳都有介绍。很多书里的告诫都让我找到了现实中不合理的依据:比如“Don’t Live with Broken Windows”让我明白为什么大家不喜欢写单元测试,就是因为我们项目本身没有多少单元测试, 而我也应该去“Fix the Problem, Not the Blame”,并且要“Be a Catalyst for Change”来测试组里的人去参与到自动化测试中。书中很多知识都可以在现在继续实践,比如书中“Domain Language”一节里就介绍了Backus–Naur form(BNF),让我意识到用很多时候对于问题需求和结论的描述,其实可以用这种结构化的语言来描绘会清晰很多。回想其实SQL语言查询语句的规格,还有Java语言的规格就是用这类语言来表述的,可惜之前并不知道它们也是值得学习的一部分。
我无法将整本书向大家完全阐述清楚,还是需要自己去阅读,并结合实际环境和能力来实践。
书中穿插了很多简短的建议,总结在本文以供参阅:
Care About Your Craft
Why spend your life developing software unless you care about doing it well?
Think! About Your Work
Turn off the autopilot and take control. COnstantly critique and appraise your work.
Provide Options. Don’t Make Lame Excuses
Instead of excuses, provide options Don’t say it can’t be done; explain what can be done.
Don’t Live with Broken Windows
Fix bad designs, wrong decisions, and poor code when you see them.
Be a Catalyst for Change
you can’t force change on people. Instead, show them how the future might be and help them participate in creating it.
Remember the Big Picture
Don’t get so engrossed in the detailed that you forget to check what’s happening around you.
Make Quality a Requirements Issue
Involve your users in determining the project’s real quality requirements.
Invest Regularly in Your Knowledge Portfolio
Make learning a habit.
Critically Analyze What You Read and Hear
Don’t be swayed by vendors, media hype, or dogma. Analyze information in terms of you and your project.
It’s Both What You Say and the Way You Say It
There’s no point in having great ideas if you don’t communicate them effectively.
DRY – Don’t Repeat Yourself
Every piece of knowledge must have single, unambiguous, authoritative representation within a system.
Make It Easy to Reuse
If it’s easy to reuse, people will. Create an environment that supports reuse.
Eliminate Effects between Unrelated Things
Design components that are self-contained, independent, and have a signle, well-defined purpose.
There Are No Final Decisions
No decisions is cast in stone. Instead, consider each as being written in the sand at the beach, and plan for change.
Use Trace Bullets to Find the Target
Tracer bullets let you home in on your target by trying things and seeing how close the land.
Prototype to Learn
Prototyping is a learning experience. Its value lies not in the code you produce, but in the lessons you learn.
Program Close to the Problem Domain
Design and code in your user’s language.
Estimate to Avoid Surprises
Estimate before you start. You’ll spot potential problems up front.
Iterate the Schedule with the Code
Use experience you gain as you implement to refine the project time scales.
Keep Knowledge in Plain Text
Plain text won’t become obsolete. It helps leverage your work and simplifies debugging and testing.
Use the Power of Command Shells
Use the shell when graphical user interfaces don’t cut it.
Use a Single Editor Well
The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable.
Always Use Source Code Control
Source code control is a time machine for your work – you can go back.
Fix the Problem. Not the Blame
It doesn’t really matter whether the bug is your fault or someone else’s – it is still your problem, and it still needs to be fixed.
Don’t Panic When Debugging
Take a deep breath and THINK! about what could be causing the bug.
“select” Isn’t Broken
It is rare to find a bug in the OS or the compiler, or even a third-party product or library. The bug is most likely in the application.
Don’t Assume It – Prove It
Prove your assumptions in the actual environment – with real data and boundary conditions.
Learn a Text Manipulation Language
You spend a large part of each day working with text. Why not have the computer do some of it for you?
Write Code That Writes Code
Code generators increase your productivity and help avoid duplication.
You can’t Write Perfect Software
Software can’t be perfect. Protect your code and users from the inevitable errors.
Design with Contracts
Use contracts to document and verify that code does no more and no less than it claims to do.
Crash Early
A dead program normally does a lot less damage than a crippled one.
Use Assertions to Prevent the Impossible
Assertions validate your assumptions. Use them to protect your code from an uncertain world.
Use Exceptions for Exceptional Problems
Exceptions can suffer from all the readability and maintainability problems of classic spaghetti code. Reserve exceptions for exceptional things.
Finish What You Start
Where possible, the routine or object that allocates a resource should be responsible for deallocating it.
Minimize Coupling Between Modules
Avoid coupling by writing “shy” code and applying the Law of Demeter.
Configure, Don’t Integrate
Implement technology choices for an application as configuration options, not through integration or engineering.
Put Abstractions in Code, Details in Metadata
Program for the general case, and put the specifics outside the compiled code base.
Analyze Workflow to Improve Concurrency
Exploit concurrency in your user’s workflow.
Design Using Services
Design in terms of services – independent, concurrent objects behind well-defined, consistent interfaces.
Always Design for Concurrency
Allow for concurrency, and you’ll design cleaner interface with fewer assumptions.
Separate Views from Models
Gain flexibility at low cost by designing your application in terms of models and views.
Use Blackboards to Coordinate Workflow
Use blackboard to coordinate disparate facts and agents, while maintaining independence and isolation among participants.
Don’t Program by Coincidence
Rely only on reliable things. Beware of accidental complexity, and don’t confuse a happy coincidence with a purposeful plan.
Estimate the Order of Your Algorithms
Get a feel for how long thins are likely to take before you write code.
Test Your Estimates
Mathematical analysis of algorithms doesn’t tell you everything. Try timing your code in its target environment.
Refactor Early, Refactor Often
Just as you might weed and rearrange a garden, rewrite, rework, and re-architect code when it needs it. Fix the root of the problem.
Design to Test
Start thinking about testing before you write a line of code.
Test Your Software, or Your Users Will
Test ruthlessly. Don’t make your users find bugs for you.
Don’t Use Wizard Code You don’t Understand
Wizards can generate reams of code. Make sure you understand all of it before you incorporate it into your project.
Don’t Gather Requirements – Dig for Them
Requirements rarely lie on the surface. They’re buried deep beneath layers of assumptions, misconceptions, and politics.
Work with a user to Thing Like a User
It’s the best way to gain insight into how the system will really be used.
Abstractions Live Longer than Details
Invest in the abstraction, not the implementation. Abstractions can survive the barrage of changes from different implementations and new technologies.
Use a Project Glossary
Create and Maintain a single source of all the specific terms and vocabulary for a project.
Don’t Think Outside the Box – Find the Box
When faced with an impossible problem, identify the real constraints. Ask yourself: “Does it have to be done this way? Does it have to be done at all?”
Start When You’re Ready
You’ve been building experience all your life. Don’t ignore niggling doubts.
Some Things Are Better Done than Described
Don’t fall into the specification spiral – at some point you need to start coding.
Don’t Be a Slave to Formal Methods
Don’t blindly adopt any technique without putting it into the context of your development practices and capabilities.
Costly Tools Don’t Produce Better Designs
Beware of vendor hype, industry dogma, and the aura of the price tag. Judge tools on their merits.
Organize Teams Around Functionality
Don’t separate designers from coders, testers from data modelers. Build teams the way you build code.
Don’t user manual Procedures
A shell script or batch file will execute the same instructions, in the same order, time after time.
Test Early, Test Often, Test Automatically
Tests that run with every build are much more effective than test plans that site on a shelf.
Coding Ain’t Done Till All the Tests Run
‘Nuff said.
Use Saboteurs to Test Your Testing
Introduce bugs on purpose in a separate copy of the source to verify that testing will catch them.
Test State Coverage, Not COde Coverage
Identify and test significant program states. Just testing lines of code isn’t enough.
Find Bugs Once
Once a human tester finds a bug, it should be the last time a human tester finds that bug. Automatic tests should check for it from then on.
English is Just a Programming Language
Write document as you would write code: honor the DRY principle, use metadata, MUV, automatic generation, and so on.
Build Documentation IN, Don’t Bolt It On
Documentation created separately from code is less likely to be correct and up to date.
Gently Exceed Your users’ Expectations
Come to understand your users’ expectations, then deliver just that little bit more.
Sign Your Work
Craftsmen of an earlier age were proud to sign their work. You should be, too.
受教了!呵呵!