10 Programming Proverbs Every Developer Should Know

本文概述了10条编程格言,旨在帮助开发者保持清晰视角,提高工作效率,确保代码质量,实现软件项目的成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Proverbs are used to express universal truths or life lessons in a short and memorable fashion.  I find that they are a great way to keep things in perspective, both in life and in work.  Because of this, I have assembled 10 programming proverbs that every developer needs in their arsenal.

1. There is no smoke without fire

Relax. It's probably just another fire drill

Poorly designed code tends to manifest itself through some common tell-tale signs.  Some examples of these are:

  • Giant classes and/or functions
  • Large blocks of commented out code
  • Duplicated logic
  • Deeply nested if/else blocks

Developers often refer to these as code smells, but personally, I think the term "code smoke" or "code fumes" is more appropriate as it implies a higher sense of urgency.  If you don't address the underlying problem it will come back to burn you later on.

2. An ounce of prevention is worth a pound of cure

Ok, I'm convinced

Toyota's assembly line of the 1980s was famously efficient due to its revolutionary approach towards defect prevention.  Each member of the assembly line was given the ability to halt production when they noticed a problem in their sector.  The idea was that it was better to halt production and fix the problem as early on as possible than to continue producing faulty units that would be tougher and more costly to fix/replace/recall later on.

Developers often make the faulty assumption that productivity = cranking out code quickly.  Many programmers dive straight into coding without a second thought towards design.  Unfortunately, this Leeroy Jenkins approach towards software development tends to lead to sloppy, fragile code that will need to be constantly monitored and patched — perhaps even replaced altogether down the line.  Ultimately, productivity must be measured not only in how much time is spent writing it, but also by how much time is spent debugging it.  A short term gain may prove to be a long term loss if one isn't careful.

3. Don't put all your eggs in one basket

A software team's bus factor is defined as "the total number of key developers who would if incapacitated, as by getting hit by a bus, send the project into such disarray that it would not be able to proceed".

In other words, what happens if you suddenly lost a key member of your team?  Would business continue as usual or would it grind to a halt?

Unfortunately, most software teams fall into the latter category.  These are the teams that turn their programmers into "domain experts" who only deal with requests that fall into their area of expertise..  At first, this appears to be a fairly reasonable approach.  It works for the automaking assembly lines, why not for software development teams?  After all, it's unreasonable to expect each member of the team to be intimately familiar with each and every nuance in the application, right? 

The problem is that developers cannot be easily substituted and replaced.  And while the pidgeon-hole approach works fairly well when everybody is available and accounted for, it quickly falls apart when "domain experts" suddenly become unavailable due to turnover, sickness, or even freak bus accidents. It is imperative that software teams have some sort of redundancy built in.  Code reviews, pair programming, and communal code go a long way to foster an environment where each developer is at least superficially familiar with parts of the system outside their comfort zone.

4. As you sow, so shall you reap

The Pragmatic Programmer has this to say about the Broken Window theory:

Don't leave "broken windows" (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a "Not Implemented" message, or substitute dummy data instead. Take some action to prevent further damage and to show that you're on top of the situation.

We've seen clean, functional systems deteriorate pretty quickly once windows start breaking. There are other factors that can contribute to software rot, and we'll touch on some of them elsewhere, but neglect accelerates the rot faster than any other factor.

In short, good code begets good code and bad code begets bad code.  Do not underestimate the power of inertia.  No one wants to be the one who has to clean up sloppy code, but neither does anyone want to be the one that makes a mess out of beautiful code.  Write it right and your code will have a far better chance at standing the test of time.

5. Great haste makes great waste

Managers, clients, and programmers are getting more impatient by the day.  Everything needs to be done and it needs to be done now.  Because of this, the temptation to throw together hacks and quick-fixes becomes very tough to resist.

No time to properly unit test a new feature?  Oh well, it works for the one test run you put it through.  You can always come back to it later!

Mysterious object referencing error when you try to access property Y?  Whatever, just throw a try/catch block around the code.  We've got bigger fish to fry!

Sound familiar?  It's because we've all done it at some point in time.  And in certain instances, it is justifiable.  After all, we have deadlines to meet and clients/managers to satisfy.  But do it too often and you'll soon find yourself with a very unstable code base full of hotfixes, duplicated logic, untested solutions, and porous error handling.  In the end, you have to strike a balance between getting things done and getting things done right.

6. Look before you leap

The term "Agile Development" is used and abused frequently these days, often as a way for programmers to justify ignoring the dreaded planning/designing phase of software development.  We are creators, and as such we derive pleasure from seeing actual progress made towards a finished product.  Surprisingly, UML diagrams and use case analysis just don't seem to satisfy that desire.  So, we developers often start off coding without any idea of what we are doing or where we are going.  It's like heading out for dinner when you haven't yet decided where you want to go.  You're hungry so you don't want to waste time finding a restaurant and booking a table.  Instead, you just hop in your car and figure you'll think of something along the way.  Only, it ends up taking you longer because you have to make a bunch of U-turns and stops at restaurants that end up having too long of a wait.  True, you'll probably find your way to food eventually, but you probably didn't end up with the meal you wanted and it probably took a lot more time and hassle than it would have had you just called and booked a reservation at a restaurant you wanted to go to.

7. When the only tool you have is a hammer, everything looks like a nail

See?  I *told* you Active Record would work for this project!

Programmers have a tendency to get tunnel vision when it comes to their tools.  Once something "just works" for us on one project, we tend to insist on using it for every project therafter.  It can be a pain to learn something new and, at times, highly unsettling.  The entire time we're thinking "it would have been easier had I just done it the old way!".  Enough of these moments and we will simply go with what we know, even if it isn't a perfect fit for the task.

It's easy to stick with what you know, but in the long run it's much easier to pick the right tools for the job.  Otherwise you will be fitting square pegs into round holes for the rest of your career.

8. Silence is construed as approval

 

I see nothing! Nuh-thing!

This ties in with the theory on broken windows and programming inertia, only on a larger scale.  
The programming community is just that, a community.  Each programmer is a reflection on the craft.  The more bad code that is released into the wild, the more it becomes the status quo.  If you don't make an effort to write good, clean,SOLID code, you will find yourself having to work with it on a day-to-day basis.

Likewise, if you see poorly designed code written by someone else, you should make the effort to bring it up with the creator. I should note, however, that tact ought to be employed in such a situation. In general, programmers are willing to admit that they do not know everything there is to know about software development and will appreciate the gesture.  We all benefit when we help each other out.  Turning a blind eye to problems only perpetuates them.

9. A bird in the hand is worth two in the bush

There is a time and place to discuss system architecture and refactoring opportunities, and a time to just get things done.  It is important to weigh the pros and cons of revamping something that already works just to make it cleaner.  It's an admirable goal, of course, but there will always be code that you want to restructure.  The programming world simply changes too frequently for code to not get outdated.  But at some point you have to provide value to your customers.  The simple fact remains: you can't do two things at once.  The more time you spend refactoring old code, the less time you spend creating new code.  Striking a balance is critical to enhancing as well as maintaining your application in a timely manner.  

10. With great power comes great responsibility

Software has undoubtedly become an integral and vital part of our lives.  Because of this, practicing good software development is more crucial than ever.  It's one thing to have a bug in a game of Pong, it's another to have one in the guidance system of a space shuttle or air traffic control system.  Slashdot recently posted an article describing how a minor glitch in Google News singlehandedly evaporated $1.14 billion in shareholder wealth.  Events such as these demonstrate how much power we wield.  It's a little frightening to think that the code you write today, whether you intend it to or not, may one day be recycled and depended upon for mission-critical applications.  Write accordingly.

Do you have any proverbs you feel should be added to this list?  Feel free to let me know in the comments!

linked from : http://www.kevinwilliampang.com/2008/10/07/10-programming-proverbs-every-developer-should-know/

资源下载链接为: https://pan.quark.cn/s/9648a1f24758 这个HTML文件是一个专门设计的网页,适合在告白或纪念日这样的特殊时刻送给女朋友,给她带来惊喜。它通过HTML技术,将普通文字转化为富有情感和创意的表达方式,让数字媒体也能传递深情。HTML(HyperText Markup Language)是构建网页的基础语言,通过标签描述网页结构和内容,让浏览器正确展示页面。在这个特效网页中,开发者可能使用了HTML5的新特性,比如音频、视频、Canvas画布或WebGL图形,来提升视觉效果和交互体验。 原本这个文件可能是基于ASP.NET技术构建的,其扩展名是“.aspx”。ASP.NET是微软开发的一个服务器端Web应用程序框架,支持多种编程语言(如C#或VB.NET)来编写动态网页。但为了在本地直接运行,不依赖服务器,开发者将其转换为纯静态的HTML格式,只需浏览器即可打开查看。 在使用这个HTML特效页时,建议使用Internet Explorer(IE)浏览器,因为一些老的或特定的网页特效可能只在IE上表现正常,尤其是那些依赖ActiveX控件或IE特有功能的页面。不过,由于IE逐渐被淘汰,现代网页可能不再对其进行优化,因此在其他现代浏览器上运行可能会出现问题。 压缩包内的文件“yangyisen0713-7561403-biaobai(html版本)_1598430618”是经过压缩的HTML文件,可能包含图片、CSS样式表和JavaScript脚本等资源。用户需要先解压,然后在浏览器中打开HTML文件,就能看到预设的告白或纪念日特效。 这个项目展示了HTML作为动态和互动内容载体的强大能力,也提醒我们,尽管技术在进步,但有时复古的方式(如使用IE浏览器)仍能唤起怀旧之情。在准备类似的个性化礼物时,掌握基本的HTML和网页制作技巧非常
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值