Slashdot Mirror


Programming Mistakes To Avoid

snydeq writes "InfoWorld's Peter Wayner outlines some of the most common programming mistakes and how to avoid them. 'Certain programming practices send the majority of developers reaching for their hair upon opening a file that has been exhibiting too much "character." Spend some time in a bar near any tech company, and you'll hear the howls: Why did the programmer use that antiquated structure? Where was the mechanism for defending against attacks from the Web? Wasn't any thought given to what a noob would do with the program?' Wayner writes. From playing it fast and loose, to delegating too much to frameworks, to relying too heavily on magic boxes, to overdetermining the user experience — each programming pitfall is accompanied by its opposing pair, lending further proof that 'programming may in fact be transforming into an art, one that requires a skilled hand and a creative mind to achieve a happy medium between problematic extremes.'" What common mistakes do you frequently have to deal with?

56 of 394 comments (clear)

  1. Printable version - All on one page by Yuioup · · Score: 5, Informative

    And now for the printable version with all the tips on one page:

    http://infoworld.com/print/145292

    Y

    1. Re:Printable version - All on one page by CountBrass · · Score: 4, Insightful

      'programming may in fact be transforming into an art, one that requires a skilled hand and a creative mind to achieve a happy medium between problematic extremes.' Bullshit. Programming has always been an art that required skill and a creative mind. The only people who have claimed otherwise have been managers, who would prefer all techies were interchangable cogs, and crap programmers: the gimps and muppets of our trade.

      --
      Bad analogies are like waxing a monkey with a rainbow.
    2. Re:Printable version - All on one page by commodore64_love · · Score: 4, Insightful

      >>>Programming has always been an art that required skill and a creative mind

      plus logical thinking (like the machine you're programming). It always surprised me when my Professor/Director of Engineering said programming should not be considered a "science" or "engineering". He said they were the equivalent of bus drivers - just human beings running a machine.

      At first I thought, 'Well maybe he has a point' but no not really. Driving a machine is a skill that can be learned in a day or two. Programming a machine requires years - the same amount of time needed to learn any engineering discipline.

       

      --
      "I disapprove of what you say, but I will defend to the death your right to say it." - historian Evelyn Beatrice Hall
    3. Re:Printable version - All on one page by Bobakitoo · · Score: 3, Insightful

      If you would have care to check the link, you would have see the IBM advertisment on the side. Also print layout is a feature of the site, OP did not invented it or hacked it in. Or maybe it is you that run ads-blocker and steal their labor? If you get mod down it will be only because you speak bullshit.

    4. Re:Printable version - All on one page by AmiMoJo · · Score: 2

      I think driving is pretty similar. You can learn it in a few days of intensive training but if you want to be a really good driver you need to stick to best practices and learn how the car itself works and what its limits are.

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    5. Re:Printable version - All on one page by olau · · Score: 3, Insightful

      That's because your professor learnt it in a day or two and now thinks he's a star programmer, while the sad truth is more like he's years from producing anything better than the crap beginners can crank out. As far as I can tell, most professors are at that level when it comes to programming. So none of his co-professors have probably corrected him. I've heard a Ph.d. refuse our explanation of why our SML student project processing strings as lists was slower than gzip (written in C) with "but they have the same time complexity".

      It has the depressing side-effect that people in college are being thought principles that the real star programmers shy away from, while nobody is working on hammering the really important ones into them.

      Of course, there are exceptions to this generalization.

    6. Re:Printable version - All on one page by LO0G · · Score: 2

      I had a friend in college who got a double major in art and electrical engineering. When I asked her why she was working in such different fields, she responded that to her art and electrical engineering were both forms of art.

      For some reason this has stuck with me for decades (yeah, I'm an old guy).

  2. Tests, Manual, Support by programmer. by Barryke · · Score: 5, Insightful

    What common mistakes do you frequently have to deal with?
    - Software only tested by programmer.
    - Manual only written by programmer.
    - Support can't do a day without programmer.

    A good programmer should know when to delegate. Or their boss should. Depends on office culture perhaps.

    --
    Hivemind harvest in progress..
    1. Re:Tests, Manual, Support by programmer. by Tridus · · Score: 4, Insightful

      Don't think thats the fault of the programmer in a lot of cases. I'd love to have someone in my office to write a manual and do proper QA. But the budget doesn't include those things, and I don't get to set the budget.

      Sometimes the reality is that you either get a program that doesn't have those things, or you try to do those things and don't have enough money to build anything.

      --
      -- "So they told me that using the download page to download something was not something they anticipated." - Bill Gates
    2. Re:Tests, Manual, Support by programmer. by Jimmy+King · · Score: 4, Insightful

      I agree. This is a very big problem for me as management keeps cutting back the tech staff where I work.

      I write the code, I test the code, I write the docs for people. I've tried explaining over and over again that this is terrible. I shouldn't be the final tester. I already think it works or I wouldn't have written it that way and wouldn't be at the point of testing. This affects my testing and causes me to miss things. I also know how it's supposed to work too well and so don't even think to try stupid stuff that users inevitably do which breaks stuff.

      Documentation is similar. I know how it works and how it was intended to work. At times this makes things obvious to me that are not necessarily obvious to someone else and so they may not find their way into the documentation.

    3. Re:Tests, Manual, Support by programmer. by WrongSizeGlass · · Score: 2

      Ah, I see. All small-time open source software (software written by a single person in their own time) is a "mistake." Nice.

      Oh please, that's not what he means and you know it. There are a lot of companies that think the person who wrote the code should also test it ("They know it better than anybody else!") and write the manual ("They know it better than anyone else!").

      This is not a knock against "one person operations" such as OSS, freeware, shareware, etc. They are forced to deliver quality code, testing and documentation because it is their name on the product. When it's a company that is just trying to save money (or they just don't understand or even listen) then it's a bad thing. When you choose to be the chief, cook and bottle washer then it's your job to get everything right. When it's thrust upon you and it's not in your skill set or project timeline, well, then quality just suffers.

    4. Re:Tests, Manual, Support by programmer. by TheRaven64 · · Score: 2

      Another approach that I've seen is to write the manual first, then the code. The manual, in describing everything that the user can see and do, functions quite well as an informal specification and (usually) has the advantage of being more readable.

      --
      I am TheRaven on Soylent News
  3. Programming Mistakes To Avoid... by Anonymous Coward · · Score: 3, Funny

    ...just try to avoid errors and you should be set.

    1. Re:Programming Mistakes To Avoid... by Anonymous Coward · · Score: 4, Funny

      ...just try to avoid errors and you should be set.

      But Warnings are ok. Just no errors. Warnings still compile.

    2. Re:Programming Mistakes To Avoid... by jekewa · · Score: 3, Insightful

      I know you're being factitious, but software compiled with "acceptable warnings" may also lead to runtime failures.

      I once had a job writing C++ software where the lead made us write code with zero warnings, turning the compiler to the most strict. Justifiable suppression was allowed (for example, in cases of ambiguous type-casting from library headers). While I thought this was overkill, we were internally hired to help a group whose software was woefully unreliable; turns out they went the other way, turned off all compiler warnings and suppressed some "acceptable" errors. Correcting their errors and compromising on some of their warnings brought the quality of their software to at least a stable level.

      There is a middle ground, but I've chosen to go with the zero-tolerance route on warnings; they're easy to get rid of, and encourage careful and thoughtful use (and even abuses).

      A good rule of thumb is that if your IDE or compiler is complaining about it, you probably left yourself open for a failure.

      Of course, not having any warnings doesn't prevent errors due to bad logic...that's a whole other ball of flame-bait.

      --
      End the FUD
  4. Maintaining code by others are always a nightmare by TheViciousOverWind · · Score: 4, Interesting

    Until you spend enough time with it, to learn why the original programmer did as he did.

    As I see it, most projects start out with a good structure and the best of intentions, and then comes deadlines and the developer having to juggle several projects at once, and then a shortcut is taken here, then there. And suddenly you end up with a non-documented project where the only person that knows how it works is the original developer.

    There will however always be BAD code by bad programmers. I've taken over Java progress where everything was OOP'ed into hell (as in a bazillion classes more than was needed for the application) and PHP projects which should be OOP'ed but consisted of about 500 files that included each other in a huge confusing net.
    I've also had to take over projects where the original developer was using new technology because he thought it would be fun (at the expense of the customer). Having a huge website in PHP/MySQL and then having crucial parts of it in Ruby/PostreSQL is just a maintenance nightmare.

    --
    My <1000 UID is with a hot chick
  5. Missing from the article by eagleyes · · Score: 5, Insightful

    The most common programming mistake to avoid: Reading badly written articles about "what programming mistakes to avoid".

  6. accompanied by its opposing pair by Barryke · · Score: 3, Informative

    Doesn't mistake number 2 contradict number 1? Or am I missing something?

    Yup. FTA:

    Below you will find the most common programming pitfalls, each of which is accompanied by its opposing pair, lending further proof that programming may in fact be transforming into an art -- ...

    --
    Hivemind harvest in progress..
  7. Mistakes? by thermal_7 · · Score: 2

    I very rarely see programming mistakes. There seems to be 2 kinds of programmers.

    - Those who care about what they do and try hard.
    - Those who don't care about what they do and don't try hard

    The later write terrible code, but it is just because they are either lazy or aren't suited to the profession and can't get enthused. Very rarely do you see someone who cares about there work make a big mistake (and if so they are probably just starting out).

    1. Re:Mistakes? by Chrisq · · Score: 5, Funny

      I very rarely see programming mistakes.

      Neither do the bad programmers!

  8. Re:do x but not too much! by Chrisq · · Score: 5, Insightful

    Doesn't mistake number 2 contradict number 1? Or am I missing something?

    The whole lot is full of contradictions:

    4: Delegating too much to frameworks 8: Reinventing the wheel
    9: Opening up too much to the user 10: Overdetermining the user experience
    5: Trusting the client 6: Not trusting the client enough

    I think that there is a meta-message, akin to Buddha's middle way. Don't take any rule to extremes.

  9. Re:do x but not too much! by icebraining · · Score: 2

    Fair enough. So debug while you code. Seems like good advice.

    s/debug/test/

  10. Programming Mistake #0 by Voulnet · · Score: 4, Insightful

    Programming mistake #0: Believing that your computer degree (Computer Engineering or Computer Science alike) automatically puts your code in a high level of quality.

    Not to bring any academia vs industry argument, but many students miss the idea of a Computer degree with programming courses in it: The degree intentionally doesn't go to details because it needs to give you a background into a broader set of subjects. Industry needs one to be very attentive to details in that one thing he's doing at the moment.

    1. Re:Programming Mistake #0 by digitig · · Score: 5, Insightful

      True enough. And since every rule has to have a complement, 0a: Assuming that you don't need to learn any of that theory: algorithms, data structures, normalisation and so on

      --
      Quidnam Latine loqui modo coepi?
  11. "Common" mistakes by Alex+Belits · · Score: 4, Insightful

    The only common mistake I see is not firing the programmer who makes any of those "common" mistakes. There is absolutely no reason for any of this shit to be "common" unless "programmers" who make them are uneducated dumbasses who should never be allowed anywhere near software development.

    Now, please, give me the list of "common mistakes" made by surgeons and aircraft engineers, and compare them with this list of amateurish crap.

    --
    Contrary to the popular belief, there indeed is no God.
    1. Re:"Common" mistakes by prionic6 · · Score: 2

      I really could not find much data, but the total number of surgical
      procedures performed in the U.S. per year is around 70 million. I'd expect the UK to have at least 10% of that. That means about 700 lost objects for 7000000 procedures, 1 in 10000. Pretty good track record, although these are not the only mistakes to happen of course.

    2. Re:"Common" mistakes by tudorl · · Score: 5, Funny

      Now that's what I call encapsulation :)

    3. Re:"Common" mistakes by erroneus · · Score: 2

      While I agree with what you say, the problem is that bad programming is largely the result of cultural personality shift.

      Lately, I have been taking some classes on web development... yeah I don't know Photoshop, Illustrator or Flash particularly well -- I like text editors though dreamweaver is growing on me. There is one person in the class who is all about shortcuts. He doesn't want to understand anything, he just wants "results." He's a business man who runs a company that is all about outsourcing. He actually doesn't know anything and doesn't do much of anything -- he's a project manager. He gets wind of a project, starts advertising job positions based on the project and then bids on the project. Business outsource to people like him, who in turn, outsources to others. All the while, he knows next to nothing about what is going on or how to do it. Why is this bad? Simple: QUALITY. How does he know if it's good quality? How does he know if it's secure or stable? He can't, he doesn't and he doesn't care. He is the personification of what is wrong with our current business practices. LOTS of people are like this and getting increasingly like this. This includes programmers and especially younger programmers.

      I have a co-worker who fancies himself a programmer. Looking at his results, I would have agreed with him. But one day, I was tired of the way his table output looked, so I went in to patch it to put "" in where all empty cells would appear. It was super easy. But looking at his code was not! I was shocked and disturbed by what I saw in his source code. A professional he is not. Not comment one in his code. Structure was for crap. It reminded me of my days programming BASIC on Apple/Commodore/TRS-80. You "think it and write it" was my style back then and is apparently his style now. The world needs a LOT less of this. Meanwhile, REAL programmers get no recognition and want none... they care about the quality of the code while project manager care about deadlines.

      Once upon a time, programming was an art of out-thinking the user. It was often a game of predicting their mistakes and stupidity and working to prevent them from blowing the system up. The article opens up with precisely this mind set. But before long, programming short cuts began appearing and even "write a program without writing any code" started to appear. (When I first saw "RAD" tools, I cringed heavily. "Are people really comfortable not knowing what these black boxes do?" Apparently, YES!)

      I once commented on a topic about programming and validating input. I was responded to with a lot of negative feedback talking about how much time and trouble it is; how much of a performance issue it could cause. I was shocked that people actually felt that way. (Heh, someone even tried to school me on "RegEx" processing... did I really have to point out that more simple and direct methods are actually faster? Sure, RegEx-s occupy a smaller portion of your source code, but the object code and library dependencies are often higher, not to mention that "generic" code blobs often do a lot of unnecessary things. It's cool, I get it -- I think in terms of assembly language and I care about wasted instructions and wasted memory -- I grew up in a 64k limited environment.)

      Should programmers be fired for making "common mistakes"? Well, yes and no. I say no because I wouldn't consider anyone who makes those mistakes to be "programmers."

    4. Re:"Common" mistakes by Just+Some+Guy · · Score: 5, Informative

      UK doctors leave 722 objects inside patients in 1 year

      That's actually not the fault of the doctor, except in the "it's his O.R. so anything that happens in it is his responsibility" sense.

      The "circulating" tech or nurse is the non-sterile person who fetches stuff out of cabinets, opens packages, and makes notes like "opened a package of 10 sponges" (typically by making a row of checkmarks on a pre-printed form).

      The "scrub" tech or nurse is the sterile-gowned-and-gloved person standing next to the surgeon who passes instruments, puts knife blades on the scalpel handles, loads the needle drivers, and keeps track of the gazillion tiny pieces to everything. There are so many removable parts because everything has to be able to be broken down into pieces small enough to clean, sterilize, and package, and part of preparing for a surgery is re-assembling all the stuff so it'll be ready if the surgeon needs it.

      The circulators and scrubs work together as a team. The circulator will say stuff like "here's the 10-pack of sponges", and the scrub will relay messages like "I counted them and there are 10 sponges there" or "I opened a package of 5 needles and there are actually 5 needles". The circulator will check off "10 sponges" or "5 needles" or "bolt and wingnut for the retractor" to build a list of everything that has been opened in the room which could possibly fit inside someone.

      At some point, the surgeon will say, "OK, I'm getting ready to close". At this point, "the count" begins. The circulator will ask how many needles the scrub has, and the scrub will answer (including the one that the surgeon is actively using at that moment). If the counts match, the circulator will check off "needles" and move on to sponges, or knife blades, or wingnuts, or whatever else they'd opened earlier. When they're done, the circulator will announce that the count is correct and the surgeon will finish closing, which they're already well into by this point because the count is pretty much always correct.

      Except when it's not.

      The biggest ass-chewing I've ever received in my life was when I was in the Navy and scrubbing for some captain and we couldn't reconcile the number of sponges. One was missing, and the presumption was that it was still inside the patient. After a few minutes of pissed-off-high-ranking-officer-screaming, they wheeled the patient out anyway and prepared to X-ray them to find the missing sponge. Ideally, everyone would stop what they're doing and stand around while we searched, but the realities of surgery are that the anesthesiologist plans the sleeping and waking cycles and you really don't want to start putting them back down into deep anesthesia or keep them down longer than absolutely necessary.

      So, we tore the room apart. We moved cabinets. We dismantled the surgical table. We dumped all the trash - clean and hazardous - onto the floor to dig through it. The captain would periodically stick his head in to ask why the hell we hadn't found the f'ing sponge yet and what the hell was wrong with us and did we know whether this was a courtmarshalling offense.

      Finally, the anesthesia resident - a much lower-ranking officer fresh from med school - sheepishly asked what a sponge looked like. Turns out, one had fallen on the floor during the case and he'd "helped" us keep the room clean by throwing it in the anesthesia trash that he was responsible for.

      As an enlisted person, that was the one time in my career that I actually yelled at an officer (who had the good grace to accept that he'd screwed up and had it coming to him). He went and told the surgeon what happened, X-rays were avoided, courtmarshalls were cancelled, and we scrubbed the room down from ceiling to floor because we'd strewn bloody trash all over the place while digging through it.

      Anyway, so yeah. The counts are ultimately the responsibility of the surgeon, but the surgeon is not the person who actually does the counting - nor could they possibly be expected to without dramatically lengthening the time a patient would have to spend under anesthesia. Behind every object left inside a patient is a scrub and/or circulator who accidentally miscounted or who lied on the count sheet to hide their screwup.

      --
      Dewey, what part of this looks like authorities should be involved?
  12. Pointer typedefs by QuoteMstr · · Score: 4, Insightful

    Pointer typedefs were a bad idea in the 1980s. They're just terrible today. One pet peeve of mine is this:

    typedef struct _FOO { int Blah; } FOO, *PFOO;

    void
    SomeFunction(const PFOO);

    That const doesn't do what you think it does. There was never a good reason to use pointer typedefs. There is certainly no good reason to do so today. Just say no. If your coding convention disagrees, damn the coding convention.

    1. Re:Pointer typedefs by Psychotria · · Score: 3, Informative

      Pointer typedefs were a bad idea in the 1980s. They're just terrible today. One pet peeve of mine is this:

      typedef struct _FOO { int Blah; } FOO, *PFOO;

      void
      SomeFunction(const PFOO);

      That const doesn't do what you think it does. There was never a good reason to use pointer typedefs. There is certainly no good reason to do so today. Just say no. If your coding convention disagrees, damn the coding convention.

      Care to elaborate (on pointer typedefs and the CONST PFOO usage)? Honest question from someone that hasn't touched a C/C++ for the last 12 years and is trying to clear the cob webs.

      The pointer is constant... not what it "points to" and the typedef "hides" that

    2. Re:Pointer typedefs by $RANDOMLUSER · · Score: 4, Informative

      His point was that a PFOO is a POINTER to a struct _FOO, and so when you say void SomeFunction(const PFOO), you're saying that the POINTER is constant, not the thing being pointed to, which is probably not what was intended. Since the definition of PFOO is located elsewhere, probably in another header file, it's easy to get yourself confused as to what data type you're dealing with.

      --
      No folly is more costly than the folly of intolerant idealism. - Winston Churchill
    3. Re:Pointer typedefs by The+New+Andy · · Score: 2
      The obvious reason you might want a typedef like that is for a mostly-opaque data-structure, where you have several different implementations, some of which require a level of indirection, some of which don't. (The "mostly" in "mostly-opaque" is there to mean that calling code never accesses the type directly, but the type is complete, so the compiler can put it on the stack).

      In short - pointer typedefs are good for the times when you really want to say "this is data of some type, maybe a pointer, maybe a struct, maybe an int".

      (oh, and to add to your complaints about that code - _FOO is also a reserved identifier...)

    4. Re:Pointer typedefs by emt377 · · Score: 2

      Ever see Windows code declare anything const?

  13. Programming Mistakes To Avoid by $RANDOMLUSER · · Score: 5, Funny

    1) VB
    2) Perl
    3) Silver bullets
    3) Writing your own "framework".
    4) Using somebody else's "framework".

    --
    No folly is more costly than the folly of intolerant idealism. - Winston Churchill
  14. GOTO... by Ecuador · · Score: 3, Funny

    Is it indecent of me to reminisce on the days of olde when such a topic would simply turn into a lengthy discussion mocking BASIC programmers?

    --
    Violence is the last refuge of the incompetent. Polar Scope Align for iOS
    1. Re:GOTO... by ledow · · Score: 3, Insightful

      I happen to agree with the general idea of that thread - goto is powerful, even in good code, but it easily misused to create spaghetti code. The choices then available are: Remove goto from the language / never use goto, or careful audit each use of goto to make sure it provides sufficient advantages and *doesn't* make the silly mistakes possible.

      The languages that remove things that provide complications to inept programmers (e.g. pointers, goto etc.) tend to be the ones that are hardest to program with predictable efficiency for.

      There's nothing wrong with goto. Just don't lob it into code without thinking about it.

  15. Re:#1 - Not managing the pointers and memory yours by dhavleak · · Score: 5, Informative

    #1 - If you are a programmer, BE A PROGRAMMER and manage the pointers and memory allocations yourself. Garbage collection is for little boys. Men deal with it on their own with techniques that work and are efficient.

    So mega-strongly disagree dude. Not saying you shouldn't do heavy lifting when necessary -- just that you should only do it when necessary. Don't re-invent the wheel every time. Frameworks exist that do work for you for a reason. Chose your frameworks well, understand them in depth, and you can do good things. If you "start from the first principles" every time, you end up with a humongous fucking surface of new code -- which is bound to have a nasty bug or three. It comes down to choosing the best tools for the job.

    #2 - Initialize all variables to known values. int i; doesn't cut it. int i=0; does.

    True dat. Lots security pitfalls here too -- not just garden variety bugs.

    #3 - Use descriptive variable names

    So true. Corollary to that: because a variable name is descriptive, don't make wanton assumptions about it.

    #4 - you shouldn't be allowed to program anything new until you've been a maintenance programmer for a few years and seen the crap code that others puke into the world. Your crap code stinks too, BTW.

    I'd modify this to say "always, always, always have a peer-review process". Junior devs are prevented from checking in crap because it gets caught by senior devs. The junior devs also learn quality habits from reviewing senior devs' code. Multiple reviewers is always a good thing. Review your design among the entire team before anyone writes a single line of code. Remember to keep security in mind when reviewing code. Use static analyzers when you're done with the "human" aspect of the review. Apply every imaginable quality bar to your code, and only check it in once it has passed scrutiny.

  16. Is this real? by Psychotria · · Score: 4, Insightful

    I've not worked as a programmer for, hmm, maybe 15 years and all of this was known way back even before I "retired" from that line of work. Perhaps all these levels of abstraction upon abstraction make things harder to understand. Back in my days these "pitfalls" were obvious because we all (well, not all, but a lot) knew ASM and actually even used it regularly (even inline, *shudder*).

    Someone above mentioned pointer typedefs and gave the example of typedef struct { int Blah; } FOO, *PFOO; (yes I left off the bit before the the opening brace deliberately.) and then suggesting that people don't know that void SomeFunction (const PFOO) {} doesn't behave as expected. Now this could, I suppose, be seen as a failure of the language. But, shit, any idiot who understands the underlying logic can see why that causes problems. Which goes back to my point of maybe all these modern levels of abstraction and getting away from the machine are, in some ways, detrimental.

    Now, get off my lawn. Umm, except I don't have a lawn because I sprayed the growth inducing hormone RoundUp all over it, but that is beside the point. I think.

  17. Re:Maintaining code by others are always a nightma by YeeHaW_Jelte · · Score: 2

    All true. My personal favorites are larger, long running projects where all of the above is true and all kinds of undocumented business logic is embedded in the code making a rewrite unfeasable and you have to decide which part of the code is outright sloppy or bad, which parts are feasable and which parts aren't actually being used anymore. Top that off with the original developers being unavailable (either dead or fleeing) and you'd be painting a pretty accurate run-of-the-mill software enviroment.

    --

    ---
    "The chances of a demonic possession spreading are remote -- relax."
  18. Re:Maintaining code by others are always a nightma by BiggerIsBetter · · Score: 5, Insightful

    There will however always be BAD code by bad programmers. I've taken over Java progress where everything was OOP'ed into hell (as in a bazillion classes more than was needed for the application) and PHP projects which should be OOP'ed but consisted of about 500 files that included each other in a huge confusing net.

    I see this one as a lack-of-experience problem. People have good intentions and want to build scalable, extensible, maintainable code. This is good. Unfortunately however, they're wrong. The apps they're building are small irregardless of the amount of thought they put into them, and they won't have to scale and extend the way they think they might - you don't need interfaces and impls and arbitrary inheritance for everything when the webapp is 4 screens of Spring WebFlow! Sure, if you're building something that warrants it, this is the way to go, but most of aren't building apps that big or flexible. It seems to take time to learn this, and to know when to apply the patterns and when to just build it.

    As a smarter man than I once said, Make things as simple as possible, but no simpler. If you do that, your code will work, it'll be understandable by the next guy, and you'll have a fighting chance of meeting your deadlines.

    --
    Forget thrust, drag, lift and weight. Airplanes fly because of money.
  19. Re:do x but not too much! by BiggerIsBetter · · Score: 2

    Yes it does. The difficult part is knowing the balance, as indicated by the summary: "programming may in fact be transforming into an art, one that requires a skilled hand and a creative mind [...]"

    Personally, I believe we'd be better off it professional programming transformed from an art into an engineering discipline. IMHO, building robust and efficient applications should be a boring and repetitive exercise in design and implementation of prescribed design patterns... maybe then we'd turn our industry's abysmal success rates around.

    --
    Forget thrust, drag, lift and weight. Airplanes fly because of money.
  20. Two Major Mistakes by grcumb · · Score: 5, Funny

    My two most common mistakes:

    1. Variable scoping
    2. Memory leaks
    3. Off-by-one errors
    --
    Crumb's Corollary: Never bring a knife to a bun fight.
  21. The PRE programming mistakes by petes_PoV · · Score: 4, Insightful
    By the time the coding starts, most projects are already doomed. The basic mistakes that occur before any code is written have a far greater effect on the project. While these are almost all outside the control of the programmer, he/she always gets the blame due to the "last person who touched it, broke it" principle. My short list of favourites would be:

    Allowing too many options / features in the design. The classic example being unable to decide whether feature A or B is best, and ducking the issue by including them both

    Assuming 5 working-days of effort can be achieved in a working week. Conveniently forgetting about all the office overheads such as "progress" meetings, timesheet administration, interrupted work, all the other concurrent projects. Even the most efficient, single-threaded operation needs half a working-day per week just for the trivia.

    Following on from that, conveniently forgetting about annual leave commitments, national holidays and the possibility of sickness. If 5 working-days per week is impractical, 12 working-months in a year is downright negligent.

    The tacit assumption that testing will inevitably be followed by reelase - rather than bug-fixing.

    Holding the end-date constant while delaying the start, or presuming that all delays in the specification, design, approval stages can somehow be reclaimed during coding (how: by thining faster?)

    --
    politicians are like babies' nappies: they should both be changed regularly and for the same reasons
  22. Avoid over engineering and over generalising by rgravina · · Score: 3, Insightful

    The biggest programming mistakes I've had the displeasure of making, or discovering in others code, almost always centre around one of these two problems:

    1. The code is over-engineered
    2. The code was abstracted before there was even a need for the abstraction.

    I remember when I was less experienced, how thrilled I'd be over code that was clever, solved many problems aside from the one I was trying to solve, and had some clear reusability built in. What a work of art, I thought.... until I eventually realised that much of the extra code I had written didn't get used, the abstracted code was never reused - or even if it was, I couldn't predict how it would be reused and the abstraction was clumsy at best, useless at worst.

    It's sad when this happens - good intentions, but the end result is a lot of waste. I'm embarrassed to look over my earlier code which is like this.. I like to think I do it less now, but the temptation is always there... I'm going to need to do this later anyway... I can just abstract this bit here and reuse it some day in the future...

    My advice now... Don't do it! Just wait until the reuse case comes along, or the new feature request comes along, and *then* do it. You'll know so much more about the problem domain then, or you might avoid days (weeks!) of wasted effort.

  23. Re:do x but not too much! by turbidostato · · Score: 4, Informative

    "The whole lot is full of contradictions"

    No, it isn't. It goes "don't do that... but don't fall in the other extreme".

    That's on line with his central idea that programming is "an art, one that requires a skilled hand and a creative mind to achieve a happy medium between problematic extremes".

  24. Re:do x but not too much! by Tridus · · Score: 3, Insightful

    That, and being able to figure out what people actually want in the first place.

    Quite a few projects fail simply because the people requesting it have no idea what they actually want. They can't articulate their needs, or why they need it, or even where the idea came from. If you can't nail that down, the rest of it is a crapshoot.

    (The only thing worse is when they DO know what they want, and it's for entirely irrational reasons.
    "We want Sharepoint!"
    "Okay, why?"
    "Umm... because we do!"
    "What does Sharepoint do that you want?"
    "Documents, and stuff!"
    "Sigh...")

    --
    -- "So they told me that using the download page to download something was not something they anticipated." - Bill Gates
  25. Don't get me started by mrjb · · Score: 5, Insightful

    Don't get me started on preventing programming mistakes. If I'd address the most common programming mistakes that I've ran into in the wild and write an article about each of those mistakes at a time, I would end up with a whole book on the matter and would probably call it "Growing Better Software".

    I find the given top 12 list of mistakes a bit weak- I'd be able to avoid all of these and yet write horrible code. My personal recommendation for a top 12 of programming mistakes to avoid would be:

    1. Failing to check function parameters before using them: null pointers, limits, lengths, etc. This will make your program unstable and/or unpredictable.

    2. Spending too little time thinking about and designing the data structure of the application. This will make you get stuck when maintaining/extending your application.

    3. Following every market hype - When the marketing bubble bursts, you'll have to start over again.

    4. Designing user interfaces without actually involving users - You'll be surprised how easy it is to confuse users.

    5. Infinitely deeply nested if/else statements - This will make code absolutely unreadable.

    6. No documentation whatsoever - Who's going to maintain your code after you change jobs?

    7. Ignoring existing, universally accepted standards - so you'll cause interoperability issues or be doomed to either reinvent the wheel.

    8. Hard-coded values/magic numbers - as a result, any change must be made in code rather than allowing power users to configure their own system.

    9. Littering code with global variables - this implies statefulness of code, making it pretty near impossible to predict how a function will behave next time it is called.

    10. Being unaware of the "Big O" order of your algorithms, causing code to be unnecessarily inefficient.

    11. Strong platform dependency: This can shorten the lifetime of your application to whenever the next platform upgrade takes place, or keep you stuck at the current version of the current platform forever.

    12. Thinking you can figure out everything by yourself - In learning by doing, experience can only follow from making mistakes. By getting yourself a mentor or an education, you can actually learn from the mistakes that thousands have made before you.

    13. Stopping at 12.

    --
    Visit http://ringbreak.dnd.utwente.nl/~mrjb/growingbettersoftware to download your free copy of the book
  26. Re:do x but not too much! by silverglade00 · · Score: 2

    Don't take any rule to extremes.

    Except sometimes you should. ;)

  27. Re:Maintaining code by others are always a nightma by Savage-Rabbit · · Score: 4, Insightful

    There will however always be BAD code by bad programmers. I've taken over Java progress where everything was OOP'ed into hell (as in a bazillion classes more than was needed for the application) and PHP projects which should be OOP'ed but consisted of about 500 files that included each other in a huge confusing net.

    Taking over projects fitting those descriptions is never a good idea. They are nothing but pain, it's impossible to resolve the problems with the app and the code unless you opt for a complete rewrite. If, however, you go that route the remaining developers will be pissed off because they wrote the crappy code and you are basically saying that their ugly baby is ... well ... UGLY! What's worse, you are saying it out loud for everybody including the PHBs to hear. Eventually you end up being frustrated, your PHB either caves in to complaints about you and puts you in your place or you get laid off. Unless, of course, you anticipate this and quit before he gets the chance. There is no substitute for writing code properly and designing and planning your application properly no matter how insignificant the application seems to be because you will never know which piece of shit app will take off and scale into something much, much bigger. Myself, I learned this from a friendly lecture I was given by my boss after I handed in my first project on my very first job. He made me rewrite the thing entirely claiming it was better that I learned the value of things like database abstraction and MVC separation right away. He was right.

    --
    Only to idiots, are orders laws.
    -- Henning von Tresckow
  28. Re:Maintaining code by others are always a nightma by WED+Fan · · Score: 2

    Or when BAD programmers, think they are good, and label other programmers as BAD. Which one are you?

    --
    Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly and applying the wrong fix.
  29. Re:#1 - Not managing the pointers and memory yours by Just+Some+Guy · · Score: 2

    #1 - If you are a programmer, BE A PROGRAMMER and manage the pointers and memory allocations yourself.

    And output formatting. printf is for wussies. Also, networking; if you can't whip up your own application-tailored TCP stack, then you should go back to playing with VB. And GUI toolkits? TOOLKITS?!? What are you doing, building a footstool? Hell, no! Manly programmers don't use toolkits, they use the library of macros they built while apprenticing to Knuth.

    You're completely right. All this mamby-pamby resource management crap is for Kindergartners and Excel users. Real Programmers flip bits with soldering irons, and we like it this way.

    --
    Dewey, what part of this looks like authorities should be involved?
  30. So... by Graham+J+-+XVI · · Score: 2

    What are the mistakes I should not avoid?

  31. Documentation by GodfatherofSoul · · Score: 2

    When we migrated to C++ a while back, my biggest gripe became the number of projects, library, et.al. that weren't documented. I won't name the very popular library, but when I contacted the developers (I was still new with C++ at the time), they told me to "read the headers." Your code is not documentation, no matter how well you comment your functions. There's a subculture out there that I don't get that has the mindset that "it was hard to write, it should be hard to use" (and that's almost a direct quote from a library author). I don't know if it's job security, elitism, nepotism, or what. But, with some projects there's a cold disregard (borderline hostility) towards the people who will actually be using the product.

    --
    I swear to God...I swear to God! That is NOT how you treat your human!
  32. Re:skill vs engineering by Anonymous Coward · · Score: 2, Insightful

    I think you overestimate the predictability of the engineering disciplines.