seven habits of highly effective programmers

Download Seven Habits of Highly Effective Programmers

Post on 30-May-2018

214 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • 8/14/2019 Seven Habits of Highly Effective Programmers

    1/8

    Seven Habits of Highly Effective Programmers

    As a software engineer, you might want any number of things out of your job - asteady paycheck, the opportunity to work on interesting projects, a springboard tothe next better job, or maybe you just like hanging out with other programmers.But by "effective", I mean the ability to complete projects in a timely mannerwith the expected quality. After working on dozens of software releases, I believethe following practices will bring you there, and while they may involve stickingyour neck out, I'd like to think they will also advance your professionalreputation, career longevity, and personal satisfaction.Understand Your RequirementsThe first step in becoming an effective programmer is to ensure that you arespending your time wisely. And there is no greater waste of time than in workingon something that is not useful or never shipped.Build EarlyGet a demonstrable system working as early as possible. This means establishingthe interface first, whether it's an API or user interface, and stubbing theencapsulated functionality as necessary. This allows your "customers" to check itout, by exercising the user interface or writing code to the API, and anyinconsistencies or omissions in the initial spec can be detected early. Chancesare, you will notice problems or potential improvements even before releasing thisfirst deliverable.There is a classical school of thought that believes if you design everything upfront, then all you have to do is write the code and you're done. That works greatif you've done the exact same project before. Otherwise, it's more likely you'llrun into a point where you're just guessing or operating on questionableassumptions. Upon joining an early-stage wireless internet startup, I found myself in twomonths of design meetings for a wireless portal and gateway due to launch in sixmonths. Eventually we got tired of meeting and finally started coding. Within twoweeks, my part of the project had no resemblance to the original design, and thefirst wireless connection test two months later revealed a fundamentalmisunderstanding of the wireless protocol.This is not to say that design is unnecessary. But after a certain point, designis just speculation. Design should be validated with implementation, and better todo that early and continuously than late and, well, too late.Even if the original design is sufficient, once you have something you can tweak,you can improve upon it. Hardware products (who designed this VCR?), buildings,and large-scale software projects suffer from interfaces that were frozen in"preproduction", but with software, you have an opportunity early in the projectto refine your understanding of the requirements and produce a suitable interface.But it must be done early.Getting something ready early is also good for your occupational well-being. Yourboss will appreciate seeing evidence that something is actually getting done andhaving something available to demo. On the other hand, a drawn out period withnothing to show is a recipe for anxious management.Deliver Often

    Once you have something working, don't just leave it as a "proof of concept". Letpeople play with it, see their reactions, and let this guide and prioritize yourdevelopment. There is no substitute for watching how people use your software.Customer questionnaires and focus studies might provide some useful input but runthe risk of transferring feature and design decisions from the developer to thecustomer.In particular get the software into the hands of the QA staff as soon as possibleand feed them regular builds, preferably at scheduled intervals. Having them testautomated daily builds is ideal, but even a weekly build is pretty good. This willhelp them feel involved in the full life-cycle of the project and they should bebest-trained at identifying and reporting problems. The highest priority should be

  • 8/14/2019 Seven Habits of Highly Effective Programmers

    2/8

    given to issues that prevent them from using the product, e.g. crashes or dead-endpaths - you want them to cover as much as possible as soon as possible and get afeel for the whole product so design issues can be identified early. At a small 3D graphics software vendor, I was put in charge of porting theflagship product from SGI workstations to Windows NT. After six months, the portwas so incomplete and crash-prone that I was reluctant to give the first "alpha"build our test group. Fortunately, the QA manager insisted, and the resultingbombardment of bug reports forced me to immediately focus on the problems thatprevented the testers from exercising the application in any meaningful way. Leftto my own devices, I would have worked on what seemed to be the harder and moreimportant core 3D issues, and probably delayed too long on seemingly mundaneissues like the user interface, load-save functionality, and compabilility withall the varieties of consumer hardware we were planning to support.Programmers often don't want to release code to testers early - they don't want tohear about a bunch of bugs they already know about, and quite possibly the testersdon't want to test something that barely works. But it's the testers' job to findthese problems and programmers need to realize bug reports are a good thing, ifthey arrive early enough.Keep It RealKeep your software running in as close to a shipping state as possible. You neverknow when you'll have to demo the system, send out an evaluation copy, or evendeliver ("OK, time to wrap things up!")Use Real DataIf you just test with sample data, that big iceberg of real data out there isgoing to sink your program. One of the leading semiconductor fabs evaluated a supply chain managementproduct I was working on. After crunching out a milestone delivery to them, we gotword back that the first batch of data they fed it from their own operations wasstill processing - for two days. I sympathized with the lead programmer, who hadto dig down and emergency-optimized everything he could for two weeks with bothmanagement and client breathing down his neck. I'm just glad it wasn't me on theline.Use Real BuildsRemember the development build on your machine is not the real build. On a recent game development project where I worked on the user interface, Igot intermittent reports from QA that some colors were not correct. Eventually, Irealized the problem only showed up in release builds and another programmer usedthe special console debugging hardware to track down the bug. Which turned out tobe a silly mistake I'd made two months previous, failing to specify an initialcolor value in a few cases. The debug build always selected a specific defaultvalue, while the release build optimized that away and the result was lessdeterminate. If I'd made a point of running the release build frequently, I wouldhave spotted my mistake immediately, instead of losing it in the sands of time.Merge OftenDon't procrastinate on merging your code with the main code base - the longer youwait, the harder it gets. I worked with a programmer who "couldn't be bothered with" all the new code

    and data changes that showed up in the repository every day. And certainly, dailymerges did take up some time for all the other programmers, and this programmerwas able to run some impressive standalone demos with a snapshot of the code anddata. But every time we had a milestone delivery, it took days to get the isolatedcode reattached to the current codebase again, sometimes compromising themilestone delivery and risking the funding for the entire project.Keeping your code out of the official build means that programmers cannot evaluateyour code and testers cannot spot bugs early. Maybe you don't want people pickingon your code or bugs, but it's better to identify those issues early than later -suck it up.Understand Your Code

  • 8/14/2019 Seven Habits of Highly Effective Programmers

    3/8

    Life is full of wonderful mysteries, but your code is not the place for them. Youdon't have to know how your car works - if the engine starts making strangenoises, you drop it off the mechanic. When it comes to your code, if you don'tunderstand how it works, or doesn't work, no one will.Code with StyleMy childhood piano teacher once commented to me, "Your sister has a good sense oftiming, and your brother has a good feel of the keyboard." Then he paused. "You,uh, you work hard."Programming is one of those things that a lot of people are more or less competentat, but some in particular have a flair for it. I'm a lousy piano player despiteyears of lessons, and I'm a mediocre basketball player although I enjoy playing itimmensely. But I do like to think I have a flair for programming and writing. Andnot surprisingly, I think good programming is like good writing. Both prose andcode are textual, have grammar, syntax, spelling and semantics and spelling. Formost coders and writers, this is enough, but the best writers and coders have anesthetic and their work features structure and style that can often be identifiedwith the author. Many Windows programmers wonder why grumpy old Unix/Mac/Amiga/Lispprogrammers rail against Win32/MFC/.NET, but if all the API's you've seen are fromMicrosoft, you probably don't know there's anything better.Perhaps not everyone is capable of writing stylish code - I've heard it said thatgood object-oriented programmers, in particular, are born and not made. But likefine music, wine, and literature, you can learn to appreciate good code.Cut-and-PasteThe opposite of stylish programming is cut-and-paste. Grab some code fromsomewhere that is supposed to do something like what you want, tweak it until itsort of works, stir, repeat, and voila, you have the software equivalent ofmystery meat. A few months after leaving one company, a former coworker emailed me asingle function consist