Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Are You Proud of Your Code?

Posted by Zonk on Monday December 10, @08:11AM
from the code-poets-speak-up dept.
An anonymous reader writes "I am downright embarrassed by the quality of my code. It is buggy, slow, fragile, and a nightmare to maintain. Do you feel the same way? If so, then what is holding you back from realizing your full potential? More importantly, what if anything are you planning to do about it? I enjoy programming and have from a young age (cut my teeth on BASIC on an Apple IIe). I have worked for companies large and small in a variety of languages and platforms. Sadly the one constant in my career is that I am assigned to projects that drift, seemingly aimlessly, from inception to a point where the client runs out of funding. Have any developers here successfully lobbied their company to stop or cut back on 'cowboy coding' and adopt best practices? Has anyone convinced their superiors that the customer isn't always right and saying no once in awhile is the best course of action?"

Related Stories

Are You Proud of Your Code? | Log In/Create an Account | Top | 682 comments (Spill at 50!) | Index Only | Search Discussion
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1) | 2 | 3
  • by suso (153703) * on Monday December 10, @08:12AM (#21640631) Homepage Journal
    One thing to keep in mind when determining the quality of your code is that other people will most likely criticize the quality of your code. Usually saying that it sucks, when usually its just the person having their own way of doing things. I don't know why this is, I think its just human nature.

    I've seen time and time again programmers taking over for other programmers' code and saying that the previous person's code sucks. Its like a right of passage or something.
    • Re:Something to note about other people's opinions by DeeQ (Score:2) Monday December 10, @08:20AM
      • by SilentBob0727 (974090) on Monday December 10, @10:22AM (#21642127) Homepage
        Over-commented code (the kind where there's 2-3 lines of comments for every one line of code -- not every closing brace needs a reminder that we're exiting a code block, thanks!) is pretty awful too. I've met people of the agile variety who insist that well-written code needs no documentation: that if you carve your code up into small, tight, appropriately named classes and methods it becomes obvious what your code does and your code becomes "self-documenting", and I've met people who won't even look at code unless every single line is commented telling them precisely what it does, so "int i = a + 2;" has to have a comment above it saying "// create a signed 32-bit integer variable, i, and assign it two more than the value of a".

        The former is wrong because while it's great that we now know what each little piece of your code does, it's still a challenge to see the forest for the trees in all but the most trivial cases (it also means that after several refactors you end up with a whole lot of miniature orphaned functions littering up your code that are never called and that do nothing but that everyone's afraid of deleting). A good method name doesn't tell the reader why the method is there or what its intended usage is. The latter is wrong as well, because suddenly naturally flowing code is broken up to the point where comments become a distraction and make the code harder to read (incidentally, this is why I started using justified end-of-line comments... it helps with the distraction).

        You should always comment your classes (or your data structures if you're using a non-object-oriented language) -- state the reason they exist, what requirement they fulfill, their role in the application, and any caveats to using them. Comment your constants, class and instance variables if it's not bleedingly obvious from the class description what purpose they serve.

        Comment your public methods! Your public methods are essentially the exposed API into your code, so if you want your successor reusing code you wrote rather than writing his own that does the exact same thing, it had better be absolutely clear how it is to be used. At a minimum, this should include what the method is there to do, a detailed description of each parameter to the function, and any constraints on the parameters, side effects of invoking the method (Does it write to any files? Set any external variables? Allocate or free any memory?), the range of values that can be returned, a description of any special return values, and any exceptions that can be raised when calling the function. Comment your private methods as well, though with your private methods you may be justified in just explaining why the method is there.

        And for the love of God, don't comment your private variable accessors unless they get or set in an unusual manner. And you don't have to comment constructors that just assign parameters to instance variables.

        Finally, while those agile guys are right in that your code really should have a natural flow and speak for itself, you should still comment your runtime code. Longer functions should be divided up into "paragraphs" with comments stating what's about to happen and how the current state contributes to the overall goal of the function. If your functions have extremely clean divisions of functionality, consider breaking them up into smaller private functions unless you're concerned with every last ounce of performance and can't afford the 10-20 cpu cycles necessary to do a function call (or declare the methods as inline). If you're doing something in a manner that's unorthodox or not immediately readable or that will make someone reading your code go, "what the hell?", either rewrite it (=D) or comment it to justify why you feel it was necessary to do it that way.

        Automated unit tests can also be a good supplement to well-documented code, as they give natural examples of code usage and can serve as tutorials for people trying to learn your code. Often this displays intent a lot better than commen
        • Re:Something to note about other people's opinions by Antiocheian (Score:1) Monday December 10, @10:34AM
        • by mini me (132455) on Monday December 10, @10:54AM (#21642609)

          # Les gars sont agiles droite. Si le code est écrit Bien, il va parler pour lui-même.
          # Il n'ya pas besoin de Double emploi avec ce que dit le code dans une autre
          # langue (Anglais). C'est peu comme votre commentant Anglais paragraphes d'une
          # interprétation française. À moins français est votre langue maternelle c'est
          # juste aller Pour obtenir de la manière et de rendre la lecture de la même Anglais
          # Plus difficile. Comme un programmeur, c'est mon travail d'être Parle couramment le
          # langage de programmation de mon choix. Reading Code devrait être aussi simple que de lire un livre.
          The agile guys are right. If the code is written well, it will speak for itself. There's no need to
          duplicate what the code says in another language (i.e. english). It's kind of like commenting your
          english paragraphs with a french interpretation. Unless french is your native tongue it's just going
          to get in the way and make reading the english even more difficult. As a programmer, it's my job to
          be fluent in my programming langauge of choice. Reading code should be as easy as reading a book.

          # Cela dit, parfois, vous avez vraiment à écrire Quelque chose d'anormal, et, dans ce cas, vous devriez
          # Commentaire. Toutefois, ces cas sont rares Entre.
          That said, sometimes you really do have to write something abnormal, and in those cases you should
          comment it. However, those instances are few and far between.
          • by SilentBob0727 (974090) on Monday December 10, @11:25AM (#21643097) Homepage
            This is a false analogy. Human language is symmetric in that it is designed to be produced and consumed by a human. Programming languages, on the other hand, are asymmetric in that regard. As such, reading a computer program requires a certain amount of aptitude that's better suited to a computer -- for example, tracking the entire program state at any given time. Granted, you only have to track the state that's relevant to the current context, but recursively switching contexts (see function call, go look up function, finish reading function, go back to function call, keep reading previous function) is something a computer does well and a human doesn't do well.

            Also, humans tend to read left-to-right, top-to-bottom. Any worthwhile program is filled with loops, branches, conditionals, calls, recursion, etc. As the program size grows, it becomes very difficult to sit down with the uncommented code and just read it, and actually take away the general gist of what was just read. To do so requires several sessions of hard concentration and focus, and time to reflect on and digest how it all works together. Well-structured, well-written code can only go so far.

            Comments, in many cases, make up for that lack of aptitude. It's not restating, it's clarifying what the code does so as to make it less likely for the reader to get lost and help speed up the learning curve.
            • Re:Something to note about other people's opinions by mini me (Score:2) Monday December 10, @11:51AM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:2) Monday December 10, @12:04PM
              • by Anonymous Coward on Monday December 10, @12:13PM (#21643955)

                But I'm saying that well written code does not need clarification.

                Here's some well-written code:

                                int nIMin = m_nIMax;
                                int nIMax = m_nIMin;
                                int nJMin = m_nJMax;
                                int nJMax = m_nJMin;


                So is it a bug? I can hear you protest now that you'd need to see it in context to know. But if I add a single short comment:


                                int nIMin = m_nIMax; // initialize to opposite ends of range
                                int nIMax = m_nIMin;
                                int nJMin = m_nJMax;
                                int nJMax = m_nJMin;


                you know that my intent was to initialize max with min and min with max.

                There is no way to express this in the code itself, and this kind of situation crops up all the time in well-written code of even moderate complexity. People with limited imaginations, who lack the capacity to see that their code could be read in many different ways, are generally unable to grasp this point, even when presented with multiple examples. Sad, really.
              • Re:Something to note about other people's opinions by magical_mystery_meat (Score:2) Monday December 10, @02:00PM
              • by JavaRob (28971) on Monday December 10, @07:51PM (#21650169) Homepage Journal

                But I'm saying that well written code does not need clarification. When it's well written there's nothing more that can be said in any other language that hasn't already been said directly in the code. I'll admit there are border cases where it's almost impossible to write code that is abundantly clear
                Have you never been brought on to maintain a large codebase that you didn't write? Even if it's *beautifully* elegant and refactored to a sparkling shine of perfection, you're still going to be lost in large sections of it for a while. There's going to be project-specific terminology decided by the developers in variable & class naming that you'll have to learn, and you simply cannot always glance at a single shard of an enormous project and comprehend where it fits into the whole. Ideally, you're going to have a whole lot of relatively independently functioning little parts, right?

                Suppose you have an exception raised in a given class. You know the line number, and you open the class... if it's involved in serving a purpose that's low-level enough, it's going to take you a far more time to figure out what it's for, how it's used, and what role it plays in the project as a whole if you don't have, say, 3 simple lines of plain English in the header comment.

                Personally I don't write too many comments in my "normal" code. I write progressively more as the code gets more complicated -- some features are simply too complex to even fit the implementation in my head all at once, so I write a shorthand walk-through of the implementation before I start. When I'm done, sometimes the code has actually boiled down enough that I can chuck that (sometimes I'm not so lucky).

                You have to comment implementations that "look wrong" or are counter-intuitive, possibly because of client demands ("the last software package did it that way, so our other systems are designed to correct for it..."). What, are you naming methods calculateScaleWronglyPerClientRequest()?

                It can be wise to flag methods (or classes) that will *appear* unused to refactoring analysis, because they're loaded & accessed dynamically.

                I could go on.
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Monday December 10, @12:28PM
              • by coryking (104614) * on Monday December 10, @12:54PM (#21644691) Homepage Journal

                I would challenge [the staunch agile supporter] to come up with a "well-written" alternative
                And your code comments will tell them that you tried to create a well written alternative but it didn't pan out because [insert comment here].

                Besides making up for language deficiencies, most comments should be exactly "this looks bad, but it is the right solution because [insert reason]" or "this code sucks, but [insert reason]". Good comments aren't English translations of the code, they provide the "what I was smoking when I wrote this". Bad comments are "initialize counting variable".

                I should also add that good comments should be written for everything publicly exposed. Good implementations of Intellesense will make life easy down the line by sucking up the comments (or xmldoc for visual studio projects and perldoc for perl).

                Really, this entire debate is an old news. People should really RTFM [amazon.com] :-)
              • Re:Something to note about other people's opinions by mini me (Score:1) Monday December 10, @12:59PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Monday December 10, @03:30PM
              • That's Not Good Code (Score:5, Interesting)

                by severoon (536737) on Monday December 10, @03:31PM (#21646909) Journal

                The biggest thing I see wrong with other people's code is not at the syntax level or to do with commenting. It's based on a misunderstanding of basic CS principles. An example is in order from last week...

                In the codebase I work on, there's a module that analyzes documents and tags them, assigning different weights to each tag based on relevance. (Think of the way google works--it reads a web page and tags it with terms, then if you type in one of those terms while doing a search that document comes up--yes I know this isn't the way google actually works, save it. :-p ) At one point we send a list of tagged documents from one system to another, and this area was the source of many, many bugs. The responsible developer spent the better part of last week slaving on this code and every change seemed to introduce more bugs than it removed. Finally, I got involved to see what the problem was.

                Here is one thing (out of many) that I found. After the docs arrive in the new system, each doc is supposed to be persisted along with the top 5 most relevant tags (the rest discarded). The code was written to create a Document, check a hash table that maps the doc to the number of tags it currently has, add a tag if that doc doesn't yet have five, then increment the value associated with that doc in the hash table. When I saw this, my head almost exploded. At some point, this developer thought it would be a good idea to create a hash table and keep this information, information which is available in the document itself (he could've just called doc.getTags().size() to see how many tags it currently had). Now he created this hash table and all his code was written to depend on it, so of course he had to write a lot of code to keep it in sync with the state of all these documents.

                This sounds like a simple enough thing, right? It's not necessary, and it's not the best thing, but it's a fairly simple mistake and one that couldn't impact code readability all that much, right? Maybe--but consider that this is one of about 10 simple mistakes I found, and you can imagine the explosion of interactions of all these simple mistakes...and that's why we burned a person-week on something that should've been trivial. When I pointed out to this developer that he could just get the number of tags directly from the doc itself, and doesn't need to keep this state in some other object too, he said something to the effect of, "That's a different approach, but whatever...one's not better than the other."

                But one is better. If this developer understood the difference between intrinsic and extrinsic, he never would've written that code in the first place much less defended it. To put a fine point on it: the number of tags associated with a document is intrinsic to the document itself, so that is where the information should live...not there as well as some hash table somewhere. The document is the authority and the final word on how many tags it has at any moment in time. (There's a principle in databases called the SUA Principle--it means one should keep data in a Single place, in an Unambiguous manner, and that should be the Authoritative source of that data and no other. It applies here too.) Putting this info into some other object, even if that object exists solely for the purpose of tracking that info, means you're creating an object that stores information that is extrinsic to it. Never a good idea...now you need a whole bunch of supporting code that keeps the extrinsic info in sync at all times.

                Let's say I'm designing a Ball class for use in a physics application that students learning physics can use. They can shoot the ball out of a cannon, put it under water, in deep space, on Jupiter, etc, and see how the simulation behaves. As the developer of this class, I decide to add a characteristic to the ball that keeps info about its "heaviness". What should I add, a getWeight() method or a getMass() method? The developer I was talking t

              • Re:That's Not Good Code by SilentBob0727 (Score:1) Monday December 10, @03:37PM
              • Re:Something to note about other people's opinions by tilde_e (Score:2) Monday December 10, @06:26PM
              • Re:Something to note about other people's opinions by Chemisor (Score:2) Monday December 10, @06:42PM
              • Re:That's Not Good Code by severoon (Score:2) Monday December 10, @06:48PM
              • Re:comments are important by thejuggler (Score:3) Monday December 10, @07:12PM
              • Re:Something to note about other people's opinions by thejuggler (Score:2) Monday December 10, @07:16PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Monday December 10, @07:56PM
              • Re:Something to note about other people's opinions by jamie(really) (Score:1) Monday December 10, @09:39PM
              • Re:Something to note about other people's opinions by GermanDZ (Score:1) Monday December 10, @10:42PM
              • Re:That's Not Good Code by DusterBar (Score:1) Tuesday December 11, @12:06AM
              • Re:That's Not Good Code by severoon (Score:2) Tuesday December 11, @04:11AM
                • 1 reply beneath your current threshold.
              • Re:That's Not Good Code by severoon (Score:3) Tuesday December 11, @04:22AM
              • Re:Something to note about other people's opinions by syousef (Score:2) Tuesday December 11, @08:00AM
              • Re:Something to note about other people's opinions by Chemisor (Score:2) Tuesday December 11, @08:58AM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @10:49AM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @10:54AM
              • Re:Something to note about other people's opinions by Chemisor (Score:3) Tuesday December 11, @01:07PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @01:12PM
              • Re:Something to note about other people's opinions by syousef (Score:2) Tuesday December 11, @04:45PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @05:39PM
              • Re:Something to note about other people's opinions by syousef (Score:2) Tuesday December 11, @05:50PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @06:53PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @07:03PM
              • Re:Something to note about other people's opinions by syousef (Score:2) Tuesday December 11, @09:12PM
              • Re:Something to note about other people's opinions by syousef (Score:2) Tuesday December 11, @09:21PM
              • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Tuesday December 11, @10:11PM
              • Re:Something to note about other people's opinions by syousef (Score:2) Wednesday December 12, @02:58AM
              • Re:Something to note about other people's opinions by boyfaceddog (Score:2) Wednesday December 12, @08:10PM
              • Re:Something to note about other people's opinions by QuietObserver (Score:1) Thursday December 13, @12:43AM
              • Re:Something to note about other people's opinions by PastaLover (Score:2) Thursday December 13, @09:19AM
              • Re:Something to note about other people's opinions by PastaLover (Score:2) Thursday December 13, @09:27AM
              • Re:Something to note about other people's opinions by LaurensVH (Score:1) Saturday December 15, @04:44PM
              • Re:Something to note about other people's opinions by joaommp (Score:1) Monday December 17, @03:48AM
              • 11 replies beneath your current threshold.
            • Re:Something to note about other people's opinions by supersnail (Score:2) Monday December 17, @03:46AM
          • Re:Something to note about other people's opinions by Nazlfrag (Score:2) Monday December 10, @12:39PM
          • by IngramJames (205147) on Monday December 10, @01:10PM (#21644909)
            The agile guys are right. If the code is written well, it will speak for itself. There's no need to
            duplicate what the code says in another language (i.e. english).


            Some of the time, that is correct. Most of the time, it isn't. But that's just in my field (financial software). There are two languages in use in the software I write and maintain: "code", and "business". It is vital, in my area, that code is commented well, to explain the business reasons behind the code. Small loops sometimes speak for themselves and don't need commenting. For example, a method called "getAllCashSecuritiesForAccount", if it contains only a simple loop, doesn't need commenting.

            But because developers come in who don't have a financial background, and don't know their way around the system, comments in the code are essential. It helps them understand both the code they are looking at, and the business flow.

            But the main reason for having clear, concise comments in the code is so that you don't have to read the code. For example (apologies for the VB):

            'get the securities in the current scope
            avItems = dctSecurities.Items
            for nCtr = 0 to dctAllSecurities.Count-1
                Set oSecurity = avItems(nCtr)
                If oSecurity.CurrentScope = enScope Then
                      colScopeSecurities.Add oSecurity
                End If
            Next nCtr

            ' Apply the change to each security in turn - if they have the relevant settlement currency
            dTotal = 0
            For each oSecurity in colSecurities
                If oSecurity.SettlementCCy = sCCy Then
                    oSecurity.MakeAChange dNewValue
                    dTotal = dTotal + oSecurity.MarketValue
                End If
            Next oSecurity

            ' Handle case of account going short
            If dTotal < 0 then
                  oAccount.HandleShortChange
            End If



            The above comments are all aligned. They appear in the IDE in a different colour. They are written in plain English. They are clear and concise. If I am looking for a bug which involves the total value which has changed being wrong, then from scanning 3 lines, written in plain English, it is fairly clear where I should start my search. Yes, given a few more seconds, I can read through the whole code, and see what is being done. But it's quicker and easier to read 3 lines of English than 15-odd lines of code, which aren't aligned.

            In fact, possibly the most useful aspect of comments like the above are to eliminate all the code you don't need to read.

            You could argue, of course, that the above could be broken down into 3 seperate methods, all clearly named. But I think that's overkill. This is a simple method, doing three simple things. I ought to be able to read it all the way through without having to flip between three different methods, which exist only to save the developer taking the time to type some clear comments.

            Lastly: yes, I am aware that the above code performs two seperate iterations of the same objects, and is terribly inefficient; it is for illustrative purposes only, and on no account should be treated with any seriousness :)
          • by nahdude812 (88157) * on Monday December 10, @03:11PM (#21646593) Homepage
            There is too often a difference between what a block of code does and what it is supposed to do. Code comments can indicate the intention of a block of code. This is a big deal, because I see code which passes test cases all the time, but which don't work as intended especially under exception circumstances (what if the arguments were a value other than what was expected).

            Plus sometimes you can understand each operation in the code block but not know what it does. Have you ever looked at an MD5 implementation? You need a comment that tells you what it does in general terms even though you know what it does in specific terms.

            I believe in making my code self documenting as much as reasonable, but any time I'm not simply reading data and outputting it (or reading data and inputting it), a backup comment describing the purpose both makes it easier to read and to maintain.
          • Re:Something to note about other people's opinions by DragonWriter (Score:2) Monday December 10, @05:04PM
          • I'll be the millionth person to disagree here... by Mongoose Disciple (Score:2) Tuesday December 11, @12:44AM
          • Re:Something to note about other people's opinions by IngramJames (Score:2) Friday December 14, @01:18PM
          • Re:Something to note about other people's opinions by demallien2 (Score:1) Tuesday December 18, @05:48AM
        • Re:Something to note about other people's opinions by oliverthered (Score:3) Monday December 10, @10:55AM
        • Re:Something to note about other people's opinions by coaxial (Score:2) Monday December 10, @11:23AM
        • Sorry, I have to bite about this. (Score:5, Informative)

          by Fross (83754) on Monday December 10, @11:27AM (#21643159) Homepage
          I am one of those people who likes lots of code. So much so that I've developed a style, similar to how I used to code 68k assembler, of running comments down a second column (usually 40-60 characters in) that describes what is going on. After all, it doesn't interrupt the flow of the code, and if you're editing Java on an 80-column fixed-width interface, you're doing it wrong to begin with. I wouldn't say I comment every line, probably one in every 3. However, this gripe with over-commenting is fundamentally flawed:

          and I've met people who won't even look at code unless every single line is commented telling them precisely what it does, so "int i = a + 2;" has to have a comment above it saying "// create a signed 32-bit integer variable, i, and assign it two more than the value of a".

          Why on earth would you write a comment like that? That is ridiculous. However, the line DOES need a comment. It's declaring a variable with a non-descriptive name and doing something specific with it. Now, the comment should do something like say what the variable is used for, if it's non-obvious. In this case, "int i" is usually used for loops, so it doesn't need a comment unless it's *not* used for loops. :) However, if it was being used in a loop, why is it being set to a+2? Is a some sort of offset in an array? Is it a user-entered value? THIS is what the comments will illustrate, eg:

          int i = a + 2; // skip the first two elements in the loop as they contain other data

          or

          int i = a + 2; // user input will be off by 2 because of (strange reason here)

          writing comments like "initialise variable" is useless, but thinking that may be all there is shows a misunderstanding about how comments work.

          You can assume the person reading your code is a programmer, familiar with the language used, and able to follow general program flow. However, he may not be familiar with the rest of the system, nor with any specific tricks you may use[1]. Comments should be like a director's commentary on the code, pointing out what may not be obvious, and giving the bigger picture - the reason why a specific variable is used a certain way, or what a messy few lines of code may be achieving, eg: // now split the input into an array and parse ready to give to the file handler
          (horrible loop declaration here)
          (even more horrible regex here)
          (custom function calling here)

          It's said comments are like sex - even when they're bad, they're still pretty good. I'm pretty sure I've never spent 3 hours trying to work out how to get THAT to work, though!

          [1] eg, I use a relatively uncommon trick in Java doing string comparisons of if(!"blah".equals(myString)) because it can't fail on the null pointer check that if(!myString.equals("blah")) can. A simple example, but something more complicated will save someone time if it just has a quick comment next to it saying what that section of code is achieving.
        • by Sparks23 (412116) * on Monday December 10, @11:38AM (#21643373)
          On the agile, small-functions stuff, there is a reason that agile programming is mostly meant for languages like Java; most agile teams have testing harnesses which will tell them when a small function is no longer used, or how many places a small function is used. This does not solve the 'forest for the trees' problem, but does at least eliminate the fear of deleting small orphaned functions.

          I do otherwise agree with all your points; the best place is a middle ground between agile's self-documenting and the traditional ZOMG COMMENTS. At my (non-agile) workplace, we document at the top of each function what the function does and what it takes and returns, as well as documenting any complex or unintuitive block of code within a function. (The ideal would be to avoid unintuitive code entirely, of course, but this is not always possible when dealing with things like VoIP goo.)
        • Excuse me if I'm rambling, but... (Score:4, Interesting)

          by djasbestos (1035410) on Monday December 10, @12:24PM (#21644137)
          I fully agree. I inherited a LOT of uncommented and shittily commented code, and it is a royal PITA to figure out WHY it is doing what it is doing (which was basically your point). On the other hand, at least with crappy comments, there is occasionally a nugget of useful information...I despise the comment-free code more, but the code itself also looks like it was designed by someone on an acid trip.

          So yes, comments should say WHY more than WHAT (specifically) a line or block of code does. A short narrative is usually the most helpful, ime. Basic description of what the method (or even a crucial line if it's the least bit unconventional or otherwise unintuitive) does (in bird's-eye-view terms / how you would explain it to a non-programmer), and WHY it is doing it if that purpose isn't obvious from WHAT.

          And I also say (most of) my predecessors' code sucks, but in this case, it does. There was one guy who seemed to have a decent idea of what he was doing, and I think he got burnt out by the complete buffoon of an "IT Manager" they had at the time (hurray cronyism! He still works here in his own project group because he's friends with the big boss). But the other guys...one would have actual end-user visible error messages like "the stupid polack messed up again", and had one of Shakespeare's plays in its entirety linked on one of the maintenance web sites. The other guy consistently set up SQL accounts with "password" and sysadmin privileges (I've gotten it secured now, but it's causing quite a bit of havoc for some users). Crazy and stupid, respectively. Then we have a contractor (still with us, hopefully not much longer)...who is arrogant AND stupid (with coding, anyways...quite manipulative with the non-technical people who control his paycheck). He implements concepts and technologies that he does not understand in completely useless and excessively complicated ways. He also has a big problem with turnover of his underlings, resulting in even crappier code. The rest of us want to completely scrap his project because it's so bad (the aforementioned "acid trip code"). But you know what they say: "CONTRACTING: if you aren't part of the solution, there's good money to be made in prolonging the problem."

          I am lazy: I make sure it works before it goes out, and I write it so the user can configure it to do what they need without having to bother me to do hard code changes, recompile, and redeploy. I've already got enough of that with existing code I've not yet had time to rewrite.

          So, in short, if you are neither crazy nor stupid, your code probably won't suck that bad. Every time I'm skeptical of my own code, I just look at the code I am maintaining and replacing. I simply remind myself: mine actually works. I wrote them from start to finish, so the code is consistent. My boss can look at it and understand what it's doing with his experience with older languages and teething knowledge of .NET. And the other programmers whose code does NOT suck (separate project group) have given me positive feedback on what they've seen of mine. A limited degree of self-doubt is good for keeping you honest with the quality of your work, but don't worry about it TOO much.
        • Re:Something to note about other people's opinions by dubl-u (Score:3) Monday December 10, @12:27PM
        • Re:Something to note about other people's opinions by Tim Browse (Score:3) Monday December 10, @12:48PM
        • Re:Something to note about other people's opinions by Actually, I do RTFA (Score:2) Monday December 10, @01:15PM
        • Re:Something to note about other people's opinions by ILongForDarkness (Score:2) Monday December 10, @01:45PM
        • by Beardo the Bearded (321478) on Monday December 10, @02:10PM (#21645755)
          I once wrote a bit of code that was about 15 lines.

          With comments, it was about 150 lines.

          It was a reasonably tricky set of decoding code that did a lot of fancy things to get the data out of a packet for a specialized application. It worked quite well, with corruption of about 20% still being recoverable into the original data.

          Anyway, nothing about the encoder was even remotely obvious. I wanted to make damned sure that whoever had to maintain that code had at least a reasonable clue as to what was going on without having to draw out charts and wonder why the indexes used were flipping at certain points. It wasn't comments like "this is an integer." "Now the integer increases". It was more like: "If the accumulated error goes above the threshold indicated, then we have to move back at least one step to find a different pathway. Since we know that the first pathway was not a match, then we increment the error threshold, increment the index, and *decrement* the position in the message." (I can't remember exactly, it's been a year since I wrote that, I no longer work there, and there's an NDA anyway.)

          Another piece of code I wrote stripped the GPS data from a GPS module's RS-232 output. It was trivial to write the code, since it was an iterative loop. However, comments for each line made it impossible to get lost in the series of 15 nested loops and in the placement of commas and other fields. It was really handy to see at a glance exactly which lines were used to skip to any given field.

          (Special thanks to the lameness filter for not letting me post it quite right!)

          At this point, get the GPS longitude minutes:
          $GPGGA,180432.00,4027.027912,N,08704.857070, W
                                            ^^
           
          GPS.longitude_min = get_number
          GPS.longitude_min << 4
          GPS.longitude_min |= get_number
           
          Skip the period:
          $GPGGA,180432.00,4027.027912,N,08704.857070, W
                                              ^
          skip_period;
          Any coding practice has to be flexible enough to allow you to make your point. If you're not commenting because you think the code is obvious, then maybe you haven't coded real stuff, or you haven't coded really tricky stuff. Maybe I write my code with a little bit of overkill in the comments, but at least I know that years from now, anyone can take a look and know exactly what I was thinking and know how to update the code.

          My code's been reviewed by an independent auditor as "better than most".
          • 1 reply beneath your current threshold.
        • Re:Something to note about other people's opinions by ryanscottjones (Score:1) Monday December 10, @02:45PM
        • Re:Something to note about other people's opinions by edwdig (Score:2) Monday December 10, @04:13PM
        • Re:Something to note about other people's opinions by famebait (Score:3) Monday December 10, @05:48PM
        • Re:Something to note about other people's opinions by jebblue (Score:1) Tuesday December 11, @12:55AM
        • Re:Something to note about other people's opinions by XavidX (Score:1) Tuesday December 11, @02:13AM
        • Re:Something to note about other people's opinions by SilentBob0727 (Score:1) Monday December 10, @03:43PM
        • 2 replies beneath your current threshold.
    • by JustinKSU (517405) on Monday December 10, @08:22AM (#21640705)
      Codes is an expression of the programmer's though process. Everyone thinks in a different way. Invariably the last person's code will seem to suck because you have to think differently to understand it. Patterns were developed to create a common ground where people can think about problems in a similar way. Regardless of how pointless and off track a project might be you still should be able to design reusable concise code if you follow the right kind of patterns.
    • by Anonymous Coward on Monday December 10, @08:26AM (#21640761)
      I had this problem with a guy that was complaining that my code was full of GOTO statements, used all global variables, and didn't have any comments or subroutines. Bah, it worked so why should he bitch about it?
    • by Chatsubo (807023) on Monday December 10, @08:30AM (#21640803)
      A lot of the time you find that, while someone is still employed, they do a good job of hiding their mistakes and covering up. It's when they leave that things start to go downhill because now suddenly, someone has to go read and understand their code. Then you realise it's a patchwork of quick fixes and bad design, and decide nice clean rewrite is in order.

      At this point you try to justify the change to management, who will "schedule it for sometime next year", since this is not causing them any pain, only you get that priviledge. From that point on, you're stuck with someone else's bugs forever.

      Now you're upset and become very vocal about the problems you now have to deal with.

      There is a difference between "different" code that works, and bad code that routinely causes problems.

      Usually the cracks show about a week or two after the guy leaves. And by cracks, I mean serious, client affecting shit.
    • Re:Something to note about other people's opinions by morgan_greywolf (Score:1) Monday December 10, @08:34AM
    • by jacquesm (154384) on Monday December 10, @08:39AM (#21640889) Homepage
      style is one eternal point of contention (except for python programmers, but they're in a straight jacket), I don't think that it is a part of 'are you proud of your code', that has little to do with what other people think of your code, but everything about what you think of your own code.

      When I look at my own code it's a mixed bag. The stuff that I earned the most money with is actually programmed quite bad, some of the most elegant stuff I wrote is sitting unused on the shelf.

      I find that in a commercial setting I'm far more inclined to 'cut & paste' to keep moving rather than refactoring just to save the time. Sure, it leads to maintenance headaches down the line and I quite often just scrap stuff and rewrite it rather than figuring out what it did and why. Tools evolve at such a tremendous clip that I don't think the lifespan of code is anywhere near the point where it could be justified to spend say an extra week or two to get an algorithm tweaked to perfection if the next release of the tool or framework is going to have it built in anyway.

      Faster machines also lead to sloppy code, I'm running a lot of production stuff on uncompiled PHP, whereas in the past I've rolled out code in assembler because I could beat the C compiler by a couple of cycles on most tight loops.

      Times are changing, and that is the biggest 'driver' against 'clean' code, it won't be long before the actual code will start to disappear. For some environments that is already happening.

      Oh well, old guys like me will find employment writing for embedded systems, which are about a decade behind the curve.

    • by noidentity (188756) on Monday December 10, @08:39AM (#21640893)

      Here are some pet peeves of mine involving dealing with other people's code. I don't think many of these are subjective either.

      • Header files you can't #include without getting errors because you didn't #include something it requires (but stupidly doesn't #include itself).
      • Lots of global variables that are read and written by several modules.
      • Header files lacking comments about what functions do.
      • Use of non-standard names for types with a fixed number of bits, instead of those from stdint.h/inttypes.h. So they have u16 or int16 instead of int16_t. Or really stupid stuff like uint instead of unsigned int (or just unsigned, which is equivalent).
      • Lack of const-correctness. Something like void print_string( char* str ); Huh, does it modify the string? No, then why does it take a pointer to non-const?
      • Unnecessary non-portability. Don't use #include unless #include isn't sufficient.
      • Internal things put in header files. If it's only used in the module, keep it in the module's source file only! Same goes for not making internal functions static, opening the possibility of clashes.
      • Files indented with two spaces instead of a tab, or even just one space. Fortunately this can be worked around with tools.
      • Unnecessarily space-taking comments about a function's visible behavior. Things with lines of stars around everything, etc.
      • Lack of structure tags, preventing forward declaration. Don't do typedef struct { ... } foo_t; do struct foo_t { }; and a typedef if necessary.
      • Macros for integral constants (yes, even in C), since enum does the job and obeys scope (yes, C has different scopes, not just C++).
      • Fundamentally, things that aren't highly modular and can be understood and used in isolation. I want to combine modules and have a minimum of complexity increase due to this combination.
    • Re:Something to note about other people's opinions by ByOhTek (Score:2) Monday December 10, @08:41AM
    • Re:Something to note about other people's opinions by RandoX (Score:2) Monday December 10, @08:43AM
    • by sm62704 (957197) on Monday December 10, @09:13AM (#21641249) Homepage Journal
      I've seen time and time again programmers taking over for other programmers' code and saying that the previous person's code sucks. Its like a right of passage or something

      You should realise that programming is an art. In art school what you''re referring to is called a critique. It's a good thing. From an old tome I wrote about ten years ago, Steve's School of Fine Art [mcgrew.info]:

      Lesson 1: The Critique
              The ultimate in masochism. Your grade depends on the critique. In the critique, everyone in class exhibits their work, and comments on all of it. How good yours looks depends on how bad theirs looks. Each work is scrutinized and ruthlessly shredded by your competitors, whose grades depend on how good their work looks compared to yours. These people are mostly talentless losers, not unlike yourself, who desperately want their work placed somewhere where someone might see it, just like you and Vincent.

            To survive this ordeal, keep your work covered until nearly everyone has their work displayed. Place yours prominently next to the worst piece of crap in the room. While everyone is ripping each other to shreds with pompous, empty, multisyllable phrases, translate what they say into plain english, which will demonstrate to the instructor that you, unlike they, actually understand this gobbledygook. Praise everyone's work with backhanded compliments in such a way that the teacher knows that you know it's crap, while the other students think you're complimenting their work.

            Beat everyone to the punch by being merciless about your own work, especially if you've outdone yourself and have actually produced something that doesn't suck. The teacher knows what you've done right; show him/her/it that you know what you've done wrong.

            Smile smugly when you're ripped. Let your face say "HA! It worked! They HATE it!" (See Insulting an Art Student and Art History, below)

            Lastly, be an attractive woman with large breasts. The heterosexual men and the lesbians will all be trying to get in your pants and won't be hard on your work, the homosexual men will be afraid of being thought of as mysogonistic, and the heterosexual women will dismiss you completely as a total, talentless airhead. This is the only place they won't think of you as a threat.

      -mcgrew

      Condsidering the subject matter, every comment on this story should be modded "flamebait".
    • Re:Something to note about other people's opinions by MyDixieWrecked (Score:2) Monday December 10, @09:15AM
    • Re:Something to note about other people's opinions by goatbits (Score:2) Monday December 10, @09:29AM
    • by Tom Cully (1052856) on Monday December 10, @09:54AM (#21641735)
      Q: How many developers does it take to change a lightbulb?

      A: 10. 1 to change the bulb, and 9 to say "no, I would have done it like this..."

      For me, this is part of the "Is programming is a science or an art?" argument. You can send a person to Art College and then have them paint for 10 years, and even then they won't necessarily produce masterpieces. Sometimes we comment like that on code we've taken over, because it really is awful...
    • Re:Something to note about other people's opinions by ribuck (Score:2) Monday December 10, @10:04AM
    • Never about other people. by SanityInAnarchy (Score:2) Monday December 10, @11:24AM
    • Re:Something to note about other people's opinions by Hoi Polloi (Score:2) Monday December 10, @11:27AM
    • Re:Something to note about other people's opinions by Doctor Crumb (Score:2) Monday December 10, @11:49AM
    • Re:Something to note about other people's opinions by Brad Eleven (Score:3) Monday December 10, @12:17PM
    • Re:Something to note about other people's opinions by oxygen_deprived (Score:1) Monday December 10, @12:50PM
    • Last rights by Tetsujin (Score:2) Monday December 10, @01:03PM
    • Re:Something to note about other people's opinions by TheRealBurKaZoiD (Score:1) Monday December 10, @01:47PM
    • Re:Something to note about other people's opinions by RSA7474 (Score:1) Monday December 10, @02:26PM
    • Re:Something to note about other people's opinions by Darinbob (Score:1) Monday December 10, @04:00PM
    • Re:Something to note about other people's opinions by lena_10326 (Score:2) Monday December 10, @04:03PM
    • Re:Something to note about other people's opinions by MikeFM (Score:2) Tuesday December 11, @03:28AM
    • Re:Something to note about other people's opinions by zerosigns (Score:1) Wednesday December 12, @06:32AM
    • Re:Something to note about other people's opinions by CuriousCuller (Score:1) Wednesday December 19, @10:02PM
    • 6 replies beneath your current threshold.
  • Same here (Score:5, Insightful)

    by polar red (215081) on Monday December 10, @08:16AM (#21640663)
    the problem is... the client doesn't always know what he wants, and the continuous changing of the specs (and hence of the code) make it a mess. It gets worse when near release some 'minor' changes have to be included and a lot of code has to be written in a very short time. There's a big difference between the theory of the 'waterfall-model'(and it's derivatives) and reality.
    • Re:Same here by ByOhTek (Score:3) Monday December 10, @08:47AM
      • Actual Software Engineering (Score:4, Interesting)

        by TheSciBoy (1050166) on Monday December 10, @09:17AM (#21641281)

        In what other line of work does principal construction begin before the customer has defined what it is they are ordering?

        A software is not a product in itself. It's not like an "apple" or an "orange", it's more like a "building" or a "vehicle". A building and a vehicle can be the solution to many different problems. A truck doesn't necessarily solve a customers problem if he's looking for a way to transport people in style from A to B.

        But while I think that most people understand this, they have a very fuzzy and indistinct concept of the cost of changing the specification once construction has begun because you can't walk the customer out to the building, point at the construction and say: "To make the changes you require we will have to tear out that wall there, remove all the concrete laid here, that will require a week and scrap more than four tonnes of construction material".

        This is where software engineering comes in: With a good model and by sticking to the principle that you begin with a specification from which you construct a series of test to see if the specification has been fulfilled. From the specification a design is made. The design specification is used to implement tests to see that the design has been followed. From the design the code is written and on the code the tests are run.

        Now when the customer changes the specification you can look at the design and the code and see (hopefully) how substantial the changes will be and what the cost will be. Your customer will thank you for being more accurate in your estimation, for pointing out the costs (which is the only thing your customer will care about, remember that time is money and is just another type of cost).

        I have so far only worked in one workplace where this model was used and it was used very successfully in my opinion. Writing all those documents surely sucked, until it came time for implementation, which was frighteningly quick and painless. The ultimate pride for the well documented, well planned, well concieved and tested code has made me utterly incapable of being satisfied with any other way of working (which is why I've switched jobs a lot).

        Changing to a structured approach to working is costly, but the benifits are bountiful and will ultimately save money and time. I can almost promise that while you might lose a customer or some goodwill of a few customers in the interim, in the long run, the customers will flock to you since you are delivering on time, the functionality they asked for.

      • Re:Same here by computational super (Score:2) Monday December 10, @09:49AM
        • Re:Same here by ByOhTek (Score:2) Monday December 10, @10:03AM
      • The 2 strongest defenses by sjames (Score:3) Monday December 10, @10:30AM
      • Re:Same here by Hognoxious (Score:1) Monday December 10, @11:19AM
    • The waterfall model by Per Abrahamsen (Score:2) Monday December 10, @08:51AM
    • Re:Same here by YeeHaW_Jelte (Score:2) Monday December 10, @09:03AM
    • Re:Same here by WallyDrinkBeer (Score:1) Monday December 10, @09:26AM
    • Re:Same here by miltonw (Score:1) Monday December 10, @10:00AM
    • Re:Same here by tknd (Score:2) Monday December 10, @02:06PM
    • Re:Same here by mkiwi (Score:2) Monday December 10, @02:14PM
    • Re:Same here by Hognoxious (Score:1) Monday December 10, @11:09AM
    • 4 replies beneath your current threshold.
  • it keeps us employed... by Dr_Art (Score:1) Monday December 10, @08:19AM
  • This Should Explain It by explosivejared (Score:2) Monday December 10, @08:19AM
  • Getting better. (Score:5, Informative)

    by Ihlosi (895663) on Monday December 10, @08:20AM (#21640693)
    It is buggy, slow, fragile, and a nightmare to maintain.



    When looking back at my first project, I feel the same. But I also think that I've learned a lot from it, and all subsequent projects were much, much better.


    So, by being "not proud" of your code, you've made the first step towards improving it.

    • Re:Getting better. (Score:4, Informative)

      by RandoX (828285) on Monday December 10, @08:34AM (#21640837)
      If you start coding from the beginning with the best possible methods, then congratulations. If you're like myself, and most of the rest of us, you're learning better ways to do things as you go. I know that I can't help but look back at older projects and think that there are better ways to do what I've done. Now I know better. Now I'll write things in a more efficient and maintainable way. I can only hope that in a few years I'll look back at the code I write this week and have an even better, cleaner, faster, and more maintainable way to do it.
    • Re:Getting better. by tompatman (Score:1) Monday December 10, @08:49AM
    • Re:Getting better. by JackHoffman (Score:2) Monday December 10, @09:29AM
    • Re:Getting better. by Thanshin (Score:2) Monday December 10, @09:37AM
    • Re:mod parent up by digitig (Score:2) Monday December 10, @09:11AM
    • Re:mod parent up by SageMusings (Score:2) Monday December 10, @06:19PM
    • 2 replies beneath your current threshold.
  • More Design (Score:3, Informative)

    by Loophole64 (871990) on Monday December 10, @08:22AM (#21640709)
    Often times you can avoid a lot of this headache by spending more time in design. If you can flush the project out in some detail during design, and include the customer, more of those changes will be included in the original design before you ever start to code. Unfortunately, others in your organization will often feel like design time is wasted time. You have to be steadfast in your will to spend time in the design phase.
    • Re:More Design by Sgt.Modulus (Score:1) Monday December 10, @08:33AM
    • Re:More Design by 0xdeadbeef (Score:3) Monday December 10, @08:44AM
      • I agree by pkbarbiedoll (Score:2) Monday December 10, @09:21AM
      • Re:More Design by zeroduck (Score:2) Monday December 10, @09:51AM
      • Wasted Time? by maz2331 (Score:2) Monday December 10, @04:43PM
    • Re:More Design by bunratty (Score:2) Monday December 10, @08:47AM
    • Re:More Design by Oligonicella (Score:3) Monday December 10, @08:51AM
    • Re:More Design (Score:4, Insightful)

      by Foolicious (895952) on Monday December 10, @09:25AM (#21641395) Homepage

      Often times you can avoid a lot of this headache by spending more time in design.

      Theoretically speaking, yes. Practically speaking, no. In fact, no no no no no no no. I've found that more time in the design phase means less time in the actually-doing-stuff and fighting-about-scope-creep and why-have-we-only-1-day-for-testing-and-bug-fixes? and you-didn't-ask-for-that-yes-I-did-no-you-didn't-yes-I-did-then-show-me-where-it-is-in-the-requirements phases.

      You're 100% right that better design usually allows for better code; however, when you're in the real world where your actual work is interrupted every 2 or 3 hours by "status" meetings or calls from a "project manager" or some kind of "business analyst" or whatever asking if something is done, and your clients only care about it working just then and there so they can meet THEIR client's deadline (so they can then meet THEIR clients' deadlines and so and so forth), well, then you just get the project done, knowing full well that your questionable code is screwing yourself or someone like you over in the future.

      You really have no choice. Principles, aside from the deeply held moral ones, don't carry much weight, especially if you work at a larger company. Calling for standards is all good and well -- until my fat, white (sometimes pimply) butt is on the line. Then I just get it done. I'd rather I get another paycheck than piss clients off and have 10 meetings (cutting into even more of my time) talking about how to implement coding standards that will, for all intents and purposes, never actually be implemented, even after we've decided to implement them!

      • Re:More Design by MartinG (Score:2) Monday December 10, @09:57AM
        • Re:More Design by Foolicious (Score:1) Wednesday December 12, @11:51AM
      • Re:More Design by Bastard of Subhumani (Score:2) Monday December 10, @11:58AM
        • Re:More Design by Foolicious (Score:1) Wednesday December 12, @11:46AM
      • You know,,, by gillbates (Score:2) Monday December 10, @01:58PM
        • Re:You know,,, by Foolicious (Score:1) Wednesday December 12, @11:39AM
    • Re:More Design by MartinG (Score:2) Monday December 10, @09:50AM
    • Re:More Design by computational super (Score:2) Monday December 10, @10:20AM
    • Re:More Design by famebait (Score:2) Monday December 10, @06:20PM
  • You have to communicate (Score:5, Insightful)

    by MosesJones (55544) on Monday December 10, @08:22AM (#21640711) Homepage

    Getting good IT practices is about establishing a business professionalism in IT that is respected. This means that you have to explain to the business what "good" looks like, you have to understand the business drivers so you can put your challenges into that context and you have to talk to the business in terms it understands.

    All too often IT folks bitch and moan about coding, testing, requirements, design time or whatever and how its all the fault of the business. This is victim mentality IT, the way to change it is to actually work out what "good" would be for the business and then work with them to deliver it.

    This means the most important coding skill in successful IT departments is the ability to communicate.
  • Customers often WRONG by pjt48108 (Score:2) Monday December 10, @08:22AM
  • In the process right now. by timmarhy (Score:1) Monday December 10, @08:23AM
  • Happy with mine by Anonymous Coward (Score:1) Monday December 10, @08:23AM
  • wise man says by wwmedia (Score:1) Monday December 10, @08:27AM
  • I seem to find that trying to code more slowly than I could helps a lot. I'm not the most efficient coder there is, but I tend to produce less bugs and have more time to make better design decisions when I slow myself down.

    I've had several jobs where I've found that although management never seems to approve of a slower process in itself, they do begin to see the values once they notice that my code tends to be less buggy than that of my peer programmers.

    As for turning around bad practices... That's always hard. Culture is a tricky thing. But it helps to use analogies, lots of analogies! System grown too large with too many kludges? Compare to building a skyscraper on the foundations of a cottage. Management wants to speed up a project by senselessly adding more people? Compare to: "One woman can make one baby in nine months. Two women can make two babies in nine months, but two women can't make one baby in four and a half months..."

    Be creative, be thorough, and be proud of your work. Always try to make the next iteration better, but also remember that sometime meeting the deadline is all that counts.

    My two cents, I guess...
  • Apples/Oranges (Score:4, Insightful)

    by ilovegeorgebush (923173) on Monday December 10, @08:27AM (#21640773) Homepage
    In programming, there are a million and one ways to do the same thing. There is no right or wrong, only good & bad. I've seen some damn shocking code over the past few years, and I've written my fair share too. It's swings and roundabouts, it's up to you to learn from your mistakes and push yourself as a programmer to better your code quality. Keep in mind that what you right is what people use, and it's the difference between "computers suck" and "hey, that was cool!".

    And as the first reply said, someone will always criticise your code. Decent programmers know this and still do their best.
  • Worse Than Failure (Score:3, Funny)

    by Rik Sweeney (471717) on Monday December 10, @08:28AM (#21640777) Homepage
    No matter what I think of my code, I always know (pray) that it'll never be bad enough to be submitted to Worse Than Failure [thedailywtf.com].

    That said, I do revisit code that I'd written a few years back and think "WTF were you thinking?!"
  • Unreasonable expectations by RandoX (Score:2) Monday December 10, @08:28AM
  • Always be proud of your code. by SolitaryMan (Score:2) Monday December 10, @08:29AM
  • Management (Score:3, Informative)

    by Algorithmnast (1105517) on Monday December 10, @08:30AM (#21640801)

    I know that with my own management, they're quite uninterested in quality - and entirely interested in the "schedule". They have a schedule, and want to meet it with our client (we're consultants) no matter what that does to our quality.

    Of course, once the code is accepted by the client then by #definition it is good enough and changes to existing code are only possible if we can prove that the existing code is buggy.

    Then there's the bizarre requirement that developers use copy/paste whenever possible. It's not as if we get paid by the line, but it seems that some of the senior architect types think that LOC matters. (no jokes please)

    Add in management's desire to see as little change to things as possible, we get a very poor heurestic for Hill Climbing [wikipedia.org] as a model of our software development "practices".

    • Re:Management by pk-swe (Score:1) Monday December 10, @08:21PM
    • 1 reply beneath your current threshold.
  • Be proud of the work, not the code (Score:5, Insightful)

    by PIPBoy3000 (619296) on Monday December 10, @08:30AM (#21640805)
    I have a lot of applications that are elegant enough. It may not have perfect validation for every field and not all the GUI bells and whistles, but it does what it's supposed to. I know my share of developers that spend a ton of time making their code elegant and beautiful. In one case, the developer spent so much time making their N-tier application with huge numbers of tables that were normalized to the bajillionth degree that they were finally let go. The goal is to meet the need, not to fulfill some inner desire to create art with lines of code.
  • There is hope! by big ben bullet (Score:1) Monday December 10, @08:31AM
  • TIME! (Score:4, Interesting)

    by microTodd (240390) on Monday December 10, @08:33AM (#21640827) Homepage Journal
    The answer to your question as to what is holding you back is complicated and multi-faceted. I'm sure you'll receive many interesting answers (and I look forward to reading them...hopefully it'll help me become a better coder).

    From a pure Computer Sciency standpoint, remember that no code is ever completely bug-free...its mathematically impossible. Testing does not prove the absence of bugs, it only proves the presence of successful use/test cases.

    But the number one thing holing me back is time. When I'm coding on the company's dollar, there's only so much time to spend in design, in writing test cases, in having someone peer review your code. And thus, there's just not enough time to spend doing things in the absolute, 100% correct way. There has to be some compromise.

    I suspect that even if I had time, I would run out of mental energy first.
    • Re:TIME! by msuarezalvarez (Score:2) Monday December 10, @08:41AM
    • Re:TIME! by Oligonicella (Score:2) Monday December 10, @09:03AM
      • Re:TIME! by kalidasa (Score:2) Monday December 10, @10:02AM
      • Re:TIME! by Tim Browse (Score:2) Monday December 10, @01:20PM
      • 1 reply beneath your current threshold.
    • Re:TIME! by DRobson (Score:1) Monday December 10, @10:11AM
    • Re:TIME! by jethroT (Score:1) Monday December 10, @10:17AM
    • Re:TIME! by ct1972 (Score:1) Monday December 10, @10:31AM
      • Re:TIME! by snark23 (Score:1) Monday December 10, @12:49PM
    • Re:TIME! by Maximum Prophet (Score:2) Monday December 10, @01:58PM
  • Lost out (Score:5, Funny)

    by gaou (1200987) on Monday December 10, @08:33AM (#21640829)
    "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
    Edsger Dijkstra


    Sorry mate, there is no hope :)

  • "Have any developers here successfully lobbied... by Nursie (Score:2) Monday December 10, @08:34AM
  • Not enough time by paranoid.android (Score:2) Monday December 10, @08:36AM
  • by Hektor_Troy (262592) on Monday December 10, @08:38AM (#21640877)
    The best code I've ever had the pleasure of working on, was made when I worked for an actual engineering company. Not software engineering, but engineers that build physical stuff.

    They understand the need for excelent documentation, rock solid requirements and that you don't get halfway in a project and change its direction (ie, "sure, the Golden Gate is halfway done, but we'd actually like it to go from Lime Point and meet up with the Bay Bridge around Treasure Island Road"). They understand that some things take half the time to do but are four times as expensive to maintain, and they prefer quality over quantity.

    Least the ones I worked with
    • 1 reply beneath your current threshold.
  • In a word? by Zebra_X (Score:2) Monday December 10, @08:38AM
  • Eric Raymond wrote, in "The Art of Unix Programming": "The combination of threads, remote-procedure-call interfaces, and heavyweight object-oriented design is especially dangerous... if you are ever invited onto a project that is supposed to feature all three, fleeing in terror might well be an appropriate reaction."

    The product I work on at work features all three. It can be 'interesting' to maintain sometimes. That being said, it's frequently possible to rewrite sections and management sometimes listens to the programmer types and has let us restructure things sometimes. For example, we've mostly gotten rid of the RPC stuff.

    When I want to satisfy my urge to work on good, clean code, I do some open-source work. Open-source tends to have that, because nothing else tends to work for very long.

  • Deadlines by Martian_Kyo (Score:1) Monday December 10, @08:39AM
  • For me, good code is like good math by AccUser (Score:2) Monday December 10, @08:39AM
  • All Code Sucks... (Score:3, Interesting)

    by iBod (534920) on Monday December 10, @08:40AM (#21640905)
    ...to somebody, for some reason.

    There is no Holy Grail of code.

    What is good coding style to me, may be anathema to you.

    Ok, there is utterly shit code (which probably accounts for a fair proportion of all code if my life experience is anything to go by), then there is 'run of the mill' code, then sometimes rare glimpses of 'great' code.

    Great code for me is when you see it and understand the programmers intention, and you think: a) I would have done it that way, or more likely b) if I was smarter I would have done it that way. You learn from great code, if you're already a good coder.

    I think the greatest obstacle to 'great' code is 'language fascism'. Some languages are better than others, that's true, but they way some people carry on you'd think it was only possible to write 'great' code in their language of choice. This behavior is generally exhibited by those that can code in one (or at most two) languages only.

    I'm generally proud of my code and am happy for others to scrutinize it. All that means is that I spent the time to make it as good as I could withing the prevailing time/cost constraints.

    I used to write a lot of assembler. Some of my colleagues used to think it was cool to use obscure instructions, in unintended ways, just to show how 'cool' they were at flipping the registers. I never subscribed to this idea and always used 2 or 3 common instructions instead of one 'neat' instruction. Performance never seemed to suffer and maintenance programmers were eternally grateful.

  • Code is communication (Score:5, Insightful)

    by Dystopian Rebel (714995) * on Monday December 10, @08:41AM (#21640915) Journal
    After a long time in the software industry, I came to realize that Code Is Communication.

    By far the largest part of the lifespan of any code is Maintenance. Code has to be intelligible. Not just through commenting, but in every construct and usage.

    Think about effective communication. The effort to be clear will improve what you are doing. It will also make your mistakes evident so you can correct them.
  • Takes a group to judge an individual (Score:5, Insightful)

    by eebra82 (907996) on Monday December 10, @08:43AM (#21640929) Homepage
    Gather around me kids, for I am sitting here in my 18th century rocker to tell you a story about a programmer.. A good programmer..

    I used to work for a small-sized IT business; a popular community that housed some 130,000 members. It began with the loss of a fellow employee who had basically coded 99% of everything on the site. To that date, everything had worked fine. We had some issues every now and then, but a backup system helped us from getting hammered if anything bad happened.

    We never worried too much about him leaving because, for starters, I had some experience with the code/system. In addition, the now departed programmer had left a comprehensive list of features and explanations of his system that would help any programmer (that would replace him) to get around any tricky problems that would/could occur.

    Unfortunately, I won't go into what type of business this was, but let's just say that it's not typical programming skills. When I began looking for his replacement, I realized how hard it was to get someone with adequate skills and all the knowhow that was required besides the actual programming. As we were on a tight budget, it was important for us to find that one guy who didn't expect a zillion dollar salary. Typically, that would be someone who shares our interests, a recent graduate who knows his ways around programming.

    Eventually I found one guy who claimed to be all that we wanted. After a month, it turned out that the guy was more and more frustrated over how things worked at the company. He disliked about everything about the code and spent most of the time cursing. At this point, I started to believe that our entire code sucked.

    Roughly a month later, we decided to rebuild "everything" so that he could have his ways around the code. Since we only had one programmer, I had to comply because it was an important role in the company. My limited coding skills provided no extra help in evaluating our current code, so I trusted this guy since he seemed to be very thorough and experienced. Also, I was promised it would take no longer than one month to do all this.

    What a fool I was. If it ain't broken, don't fix it. I should have known, but a company on a tight budget and no one else with good programming skills forced us into this move. Turns out, our super experienced programmer needed not one month, but two, three, four, five, six and seven months to complete his task. By then, he had reprogrammed almost everything and merged some of it with the old code. We waited for the relaunch of our software with great anticipation. Three! Two! One! Go! Oh crap, everything f*cked up.

    Following the launch of our new software, we had months and months of trial and error problems. Members were complaining and nothing went in the right direction. Eventually, we were essentially bankrupt and had to let the superb programmer go. The guy who had left us with a huge mess.

    When I read this Slashdot story, I had a smile on my face because I learned that a programmer can only know that his code is perfect by the response of many other programmers who can view his code (i.e. open source). Some programmers seem to think their code is perfect and that occurring bugs are caused by impossible-to-foresee problems. The point of my story is that if you truly want to know if you are a good programmer, you must let a lot of programmers decide that for you. Unless your name starts with J and ends with ohn Carmack, of course.
  • It's not just the client by Dr. Winston O'Boogie (Score:1) Monday December 10, @08:44AM
  • TCO (Score:3, Informative)

    by devnullkac (223246) on Monday December 10, @08:45AM (#21640949) Homepage

    Saying "no" to the customer is not normally what's called for. Instead, your team must clearly state the total cost of any proposed change. Factoring maintainable quality into cost estimates is an art that an organization must learn if it wants to get asked to do another job after the money for this one runs out (project drift leads to no results leads to unhappy customers, as you well know). When the customer responds with "Well, isn't just as simple as changing X into Y?" then that's when you get to say "no."

  • Here's a start to better code by Man_Holmes (Score:2) Monday December 10, @08:46AM
  • Unfortunately, yes. by squiggleslash (Score:2) Monday December 10, @08:46AM
  • Personal Best Prqctices by aunchaki (Score:1) Monday December 10, @08:47AM
  • Code... by CFBMoo1 (Score:1) Monday December 10, @08:56AM
  • Yes (Score:5, Funny)

    by Average_Joe_Sixpack (534373) on Monday December 10, @08:56AM (#21641065)
    I often use "Programmer: Alan Smithee" in the comment header
    • Re:Yes by kalidasa (Score:2) Monday December 10, @09:22AM
  • Yes, yes and yes (Score:4, Insightful)

    by YeeHaW_Jelte (451855) on Monday December 10, @08:56AM (#21641067) Homepage
    Yes, I am proud of my code, or maybe not always the code but at least my coding. It's not always possible to create beautiful, well mantainable code. I try to, but sometimes there's just not the time.

    Yes, I have convinced my employer to stop allowing cowboy coding practices -- she didn't even realize it was happening. I'm currently head of the programming division of a inhouse IT dept for a large travelagency specialized in cruises ... it's a pretty large department for such a small company, as we write all our inhouse software ourselves and have been for the last 5 years. When I came to work here, the codebase was about that old -- 5 years -- and maybe a two dozen different 'cowboys' had been writing the software resulting in a large heap of steaming shit. They were not centrally coordinated and everyone of them was doing things in his own style either out of laziness of ignorance.

    Anyhow, I managed to convince the CEO that there was a problem ... she had no idea that it was a mess, the company being a travel agency and she having very little knowledge of automation herself. I used a difficult coding project (connecting to a GDS, the guys that administer plane reservations, car rental, cruises etc) and a general optimation project ( the application was becoming very slow due to all the bad programming going on ) to build her confidence in me and asked her to put me in charge of code sanity. She did.

    I am now trying to reform the bunch of code cowboys that currently works here to a well disciplined programming team ... and I hope I'm succeeding. Gave them code standards to work to, asked them to clean up the code base where they stumbled upon crappy pieces, moved from Visual Source Safe to Subverion (thank god!) and started regular meetings once a week.

    The codebase is still very messy at places, but many basics (use of one and only one database class e.g.) have improved very much and I think the people here are happier for it. It's much less frustrating to work on nicely formatted code that doesn't have braindead sections that aren't commented.

    To make a long story short, if you're not proud of the code you write, make sure you improve it.
  • by w4rl5ck (531459) on Monday December 10, @08:59AM (#21641083) Homepage
    I came to the conclusion that you are the only person who is ultimately responsible for the state of the code you write is YOU. Nothing else, no one else.

    Project deadlines, crazy customers, chief engineers, thunderstorms, even a Tsumani. It's just you.

    Reason:

    if you write buggy code, whatever the reason may be, it falls back to you. You will have to fix it, you will be MADE responsible for it. EVERY time. No one asks WHY you did it.

    And you don't like it yourself, which is a bad thing. One should LOVE his work, not hate it.

    If you force yourself to push everything else into a state that enables YOU to write good/nice/beautiful code, you will gain something. If not, you will suffer. That's about it. It has nothing to do with other people, with companies, with unemployment.

    So, get up, and write that good code. Whatever it takes.

    Good luck :)
  • Quality Over Quantity by wzinc (Score:1) Monday December 10, @09:03AM
  • Change your paradigm by mdmkolbe (Score:2) Monday December 10, @09:04AM
  • Stick It to the man by creeves1982 (Score:1) Monday December 10, @09:04AM
  • anonymous reader writes by sm62704 (Score:2) Monday December 10, @09:05AM
  • another great source for code improvement by ajaxlex (Score:1) Monday December 10, @09:08AM
  • I am content with most of *my* code by mrjb (Score:2) Monday December 10, @09:09AM
  • Pride fades with time (Score:5, Interesting)

    by Opportunist (166417) on Monday December 10, @09:11AM (#21641227)
    Generally, whenever I complete a set of code, it's perfect. It's flawless. It's the stunning pinnacle of coding, and it should go on some kind of display page where everyone can marvel at it, worship it and experience its perfection so they may find true enlightenment.

    Usually, when I unearth the code 6 months later I wonder if there's any way to get this horrible piece of hacked crap out of the CVS somehow...

    It's just that, well, you learn. You improve. Yes, even after more than a decade of coding, you still learn and improve. You learn new tricks, you learn to use new libraries, and you discover better and more efficient ways to use them by using them. So generally, yes, I'm proud of my code. For a while.
  • Find the problem, not the symptom by JavaSavant (Score:2) Monday December 10, @09:11AM
  • To be honest? (Score:3, Informative)

    I am downright embarrassed by the quality of my code. It is buggy, slow, fragile, and a nightmare to maintain. Do you feel the same way?
    No.
  • good luck by jmyers (Score:2) Monday December 10, @09:17AM
  • Be an arsehole by fozzmeister (Score:2) Monday December 10, @09:17AM
  • New features vs cleaning/debugging by mujo (Score:1) Monday December 10, @09:19AM
  • as long as my code is unique... by someone1234 (Score:2) Monday December 10, @09:22AM
  • Yes, I am.. but now of my collegues' code.. by HBSorensen (Score:1) Monday December 10, @09:24AM
  • bottom up doesn't work by virchull (Score:1) Monday December 10, @09:24AM
  • Nope not really, not a line of it! by haplo21112 (Score:2) Monday December 10, @09:27AM
  • The key to writing good code, is NOT to write it. by kbradl1 (Score:1) Monday December 10, @09:28AM
  • So many questions, so little time by cpct0 (Score:2) Monday December 10, @09:31AM
  • I'm Lead Dev, at a young startup... by beyonddeath (Score:1) Monday December 10, @09:31AM
  • Better code style by Lars Clausen (Score:2) Monday December 10, @09:33AM
  • REALITY CHECK: It doesn't matter... by PatSand (Score:1) Monday December 10, @09:33AM
  • Often by jrexilius (Score:2) Monday December 10, @09:34AM
  • It's about value to whoever pays the bills. by Fross (Score:2) Monday December 10, @09:35AM
  • Are you kidding me? by sirgoran (Score:2) Monday December 10, @09:44AM
  • You're doing every perfect! by SlappyBastard (Score:2) Monday December 10, @09:45AM
  • Good, quick, cheap: choose two. by threaded (Score:2) Monday December 10, @09:47AM
  • "Proud?" father of a hack by GoNINzo (Score:2) Monday December 10, @09:48AM
  • by Caine (784) * on Monday December 10, @09:49AM (#21641663)
    Ok, so this might sound a little harsh, but you see, the solution to your problem is this: code better. It really is that simple. Yes, it's nice if you can anchor things with project managers or whatever you have above you, but it's not really necessary.

    Having problems with bad interface? Design better interfaces. Jumbled, complex code? Refactor it. Slow execution? Improve the algorithms. There's basically no project that takes longer time by doing things right, more often than not the opposite is true. A good refactor can save tons of time.

    There's no magic bullet, however much support you get from superiors or coworkers. The only thing you can do is simply write better code.
  • Always write code... (Score:5, Funny)

    by ebbe11 (121118) on Monday December 10, @09:49AM (#21641669)
    ...as if the guy who is going to maintain it is a 6'6" tall two feet wide bodybuilding psychopath who knows where you live.
  • Same here by codeboost (Score:1) Monday December 10, @09:49AM
  • Clearly the author and I have something in common. by gru3hunt3r (Score:1) Monday December 10, @09:53AM
  • If you want your code to be better... by kunakida (Score:1) Monday December 10, @09:55AM
  • Proudest of ... by smcdow (Score:2) Monday December 10, @09:55AM
  • My worst coded app - how wonderful it was! by PortHaven (Score:2) Monday December 10, @09:55AM
  • Java and C++ vs PHP by mulhollandj (Score:2) Monday December 10, @09:57AM
  • self-help solution by aristolochene (Score:1) Monday December 10, @10:03AM
  • It depends on who it's for by macemoneta (Score:2) Monday December 10, @10:07AM
  • Change Will Always Come... by Koldark (Score:1) Monday December 10, @10:14AM
  • Comment your code by dgun (Score:1) Monday December 10, @10:14AM
  • Cowboy coding by Lalo Martins (Score:1) Monday December 10, @10:16AM
  • Economics by chord.wav (Score:1) Monday December 10, @10:17AM
  • Ugly code by tobe (Score:2) Monday December 10, @10:23AM
  • Gang of Four by Dan667 (Score:2) Monday December 10, @10:25AM
  • Sometimes by Apreche (Score:2) Monday December 10, @10:25AM
  • Buy and read... by Chysn (Score:2) Monday December 10, @10:27AM
  • Maybe by protomala (Score:2) Monday December 10, @10:31AM
  • And the first step is by plopez (Score:2) Monday December 10, @10:33AM
  • Good Code Vs. Bad Code by Biffers (Score:1) Monday December 10, @10:33AM
  • Note to self by gencha (Score:1) Monday December 10, @10:42AM
  • Proud? by jandersen (Score:2) Monday December 10, @10:45AM
  • Sometimes whole groups are by Tzinger (Score:1) Monday December 10, @10:46AM
  • From someone that doesn't code... by PenguinBoyDave (Score:2) Monday December 10, @10:50AM
  • Haven't you learned anything? by jjb3rd (Score:1) Monday December 10, @10:51AM
  • Perspective and Experience (Score:4, Insightful)

    by martyb (196687) on Monday December 10, @10:55AM (#21642635)

    Many good comments already. I'd like to add some based on my experiences since 1972.

    Background: I was fortunate to be introduced to structured programming early on. I've used, and helped develop/test tools to implement, various coding methodologies (CASE, anyone?) I've worked on operating systems and compilers. Yes, plural on each of those. I've worked at huge multi-nationals and a 3-man startup.

    Observations:

    • I've written crap code. I think it's part of the rite of passage. I did the best I could with what I knew, and when I knew better, I tried to do better.
    • I've read books and taken courses, but there's no comparison to just diving in and reading LOTS of OTHER PEOPLE's code... and then learning from it.
    • Attitude is important. There is a HUGE difference between "That's stupid" and "Why did they do THAT?" Be open to be educated.
    • Be organized. In your thinking, notes, and code. In my experience, bugs tend to congregate at the interfaces. Be it a procedure call or return or in an interrupt handler, I try to keep things as clean as possible. Hacks WILL come back and bite me/others.
    • Make junk stick out. When I'm pressed for time and know I'm taking a shortcut, I flag it as such. It's easier for me to find a needle in a haystack if I use BIG needles.

    Lastly, here is a quotation I found back in the 80's (IIRC from someone at SofTech) and it has guided my thinking ever since:
    Strive to understand your problem.
    Don't try to solve it.
    A fully-stated problem
    embodies its solution.

  • No by wasabii (Score:2) Monday December 10, @11:03AM
  • Which code? by Richard Steiner (Score:2) Monday December 10, @11:10AM
  • Development Methodology (Score:3, Interesting)

    by inKubus (199753) on Monday December 10, @11:11AM (#21642855) Homepage Journal
    Adopt a development methodology that defines what features will be developed and what features WILL NOT be developed. Now you have a place to put all those "great ideas" people have while you're still making the base product. You can also keep them in mind while making other modules, so you know you can make them later. This eliminates scope creep. It may not seem like a piece of paper will work, but as a society we all know the power of forms. Act like it's not your choice, that someone in management is making you use the methodology. No one will want to contradict anyone else so they will just accept it. And when it works, and you come in on-time and on-budget it will become part of the corporate culture.

    Your deliverables (above) will be a part of your project charter. You will also include stuff like: a list of stakeholders, RISKS AND ASSUMPTIONS (such as a deadline not being met, etc.), testing, and of course "Success", which will be a list of metrics that define a successful product (ie: it can generate payroll checks, it can print report A, etc). Then, take your project charter (look it up on google) and put a bunch of lines on the bottom for you, the team and the management and the key users to sign off on. Do not start work until it gets signed off. Then make a copy for yourself and file the original with the project documentation. Work and complete all the features to be developed. At the end, take the project charter and make sure everything is fulfilled, then give it to the "customer" and have them sign off again for completion (after you demo the software).

    Usually scope creep means poor project management, and as a developer you can't expect anyone else to do it. Just do it, you will be very thankful you did. Also, if it's a short project, try something called Quick-Kill [ddj.com] project management. Large projects need a better methodology. I use one I made up that's based on the quick kill and some microsoft stuff, with some unix version control stuff, and oracle business process analysis stuff... Over time you will develop your own methodology and become a star senior programmer making $300,000 a year.

    Have fun
  • Proud of my code? by LGM95223 (Score:1) Monday December 10, @11:14AM
  • Nope by LoaTao (Score:1) Monday December 10, @11:19AM
  • Management has a role in this too by Anonymous Coward (Score:1) Monday December 10, @11:26AM
  • Occasionally I ... (Score:4, Interesting)

    by kcdoodle (754976) on Monday December 10, @11:26AM (#21643135)
    Once in a while I take a small change and tell the client/boss/myself that it is a really BIG change.

    Then I go through a totally re-write the code from end-to-end. I look for unused sections, variables, etc. I re-order all the logic so that it is logical. Then I test for the necessary period of time.

    Since most of the code is already written, I start by writing out the business rules and I make the order of the code follow the order of the business rules, more-or-less. I put ALL of the business rules into the code as comments. I also send the rules to the client/boss/myself/others.

    Doing this just once a year, on each critical section of code actually saves me much more time than the initial investment, so everyone wins.
  • The Difference Between Programmers.... by coaxial (Score:2) Monday December 10, @11:29AM
  • Limited resources by jbeaupre (Score:2) Monday December 10, @11:29AM
  • Quality of code versus execution by caywen (Score:1) Monday December 10, @11:30AM
  • test first by Surt (Score:2) Monday December 10, @11:31AM
  • Why It Sucks to be an In House Programmer by tuzo (Score:1) Monday December 10, @11:36AM
  • Your manager works for you. by kwerle (Score:2) Monday December 10, @11:37AM
  • legacy (Score:4, Interesting)

    by suitti (447395) on Monday December 10, @11:41AM (#21643435) Homepage
    My last two projects have been to babysit and sun down legacy systems. These were written in Perl, are web & database based, were written over a period of about ten years by multiple people, had no development system (all changes are made in production), and are each at least a half million lines of code.

    One such system has two very different kinds of programmers. One kind produces very small, tight, elegant code. Each line may be complex, but there aren't very many of them. Another kind generally codes for conceptually easier tasks, and has a verbose style. Individual lines are trivial assignments, but there are sometimes thousands of them.

    The elegant code is MUCH more difficult to debug. It's also, generally, broken much less often. The verbose code is generally very easy to fix.

    But i've gotten an appreciation for other ways to do things. And, there aren't nearly as many of us 'elegant coders' out there for replacement. But i still don't see how some apps can be accomplished at all without us. This appears to be language, library and tool independent. Fred Brooks seems to have something to say about this.

    I'm firmly in the realm of 'elegant coder' myself. My favorite piece of late is 750 lines of very dense code involving a seven dimensional hash (but sometimes six - it varies) with dynamic indexes. It replaces a 25,000 line chunk that had to be changed every year. The new bit never needs change. However, despite ample documentation and three tutorials, i was unsuccessful in showing the new team how it worked. The new system has designed this bit out completely.

    One thing about both projects is that the employer either started a project to replace them, or actually replaced them. In both cases, it was an incredible amount of work and expense to do this. Millions of dollars. It would have been both cheaper and better to fix their problems, and update their user interfaces. At least, once an appropriate programmer was found. Oddly, we have at least two on our current team.

    Oh, yes. The replacement projects went over budget and were late by at least a factor of two. Much more, if you consider that something like half of the functionality was removed. And there seems to be one chunk that the new team doesn't seem to be able to deliver. Perhaps the new team needs an elegant coder.
    • Re:legacy by xant (Score:2) Monday December 10, @01:47PM
      • Re:legacy by suitti (Score:2) Friday December 14, @03:30PM
  • Go agile by beef3k (Score:1) Monday December 10, @11:55AM
  • Perfectionist by BackBox (Score:1) Monday December 10, @11:55AM
  • Does it work? by ducomputergeek (Score:2) Monday December 10, @11:58AM
  • How to be more proud more often by inonit (Score:1) Monday December 10, @12:05PM
  • You are, and here's why by JoeCommodore (Score:2) Monday December 10, @12:07PM
  • A lot of my code is sloppy by krunk7 (Score:2) Monday December 10, @12:14PM
  • My code works fine :) by TheLink (Score:2) Monday December 10, @12:22PM
  • Variform. by andr0meda (Score:2) Monday December 10, @12:34PM
  • legalistic confrontation quenches creative effort by MellowTigger (Score:1) Monday December 10, @12:34PM
  • Re: Are You Proud of Your Code? by sick_soul (Score:1) Monday December 10, @12:42PM
  • I just took a look at my code from 8 years ago by melted (Score:2) Monday December 10, @12:53PM
  • It depends by Nicolay77 (Score:2) Monday December 10, @12:56PM
  • code can be perfect by nachumk (Score:1) Monday December 10, @01:04PM
  • You need some pair programming by scorp1us (Score:2) Monday December 10, @01:32PM
  • What's holding him back? by fahrbot-bot (Score:2) Monday December 10, @01:42PM
  • Lots-O-Comments by javamann (Score:1) Monday December 10, @01:55PM
  • my code and my wife's but by sal (Score:1) Monday December 10, @01:57PM
  • Coding is not the Big Issue by Mutatis Mutandis (Score:2) Monday December 10, @02:00PM
  • because management likes it that way by jay2003 (Score:2) Monday December 10, @02:08PM
  • In 2 letters... (Score:3, Informative)

    by worldcitizen (130185) on Monday December 10, @02:16PM (#21645855)
    >I am downright embarrassed by the quality of my code. It is buggy, slow, fragile, and a nightmare to maintain. Do you feel the same way?

    No.

    Honestly, most of the time writing bad code is not faster than writing reasonably good code.

    To improve even more, try having a policy of doing a quick code review before non trivial check-ins. Knowing that you'll have to show and explain your code to a peer, that does help in resisting the temptation to take some shortcuts (e.g., why save time writing when it will take longer to explain). Code reviews should be easy to "sell" to upper managers, as they provide a certain degree of mitigation for the risk of one programmer leaving.
  • Best practices = bad code by sigmabody (Score:1) Monday December 10, @02:19PM
  • my answers to your questions. by Interested Spectator (Score:1) Monday December 10, @02:33PM
  • Documentation, Commenting,... by Univac_1004 (Score:1) Monday December 10, @02:38PM
  • Work is for Crap; your Free project is for Quality by mkcmkc (Score:2) Monday December 10, @03:00PM
  • Computer Science degree, before and after by fatalGlory (Score:1) Monday December 10, @03:17PM
  • My humble advice by orangehead911 (Score:1) Monday December 10, @03:33PM
  • Indentation and meaningful variable names by powermacx (Score:1) Monday December 10, @03:47PM
  • Piece of cake! by slashbart (Score:1) Monday December 10, @03:47PM
  • You have to code defensively... by Kazoo the Clown (Score:2) Monday December 10, @03:54PM
  • Make yourself proud! by sinnema313 (Score:1) Monday December 10, @04:04PM
  • On the contrary by DerPflanz (Score:1) Monday December 10, @04:12PM
  • What about programming languages? by musicbear (Score:1) Monday December 10, @05:07PM
  • Awwww by PPH (Score:2) Monday December 10, @07:04PM
  • Customer = Wrong (Score:3, Interesting)

    by 7Prime (871679) on Monday December 10, @07:12PM (#21649819) Homepage Journal
    The unfortunate truth, and this goes for ever profession, is that the customer is almost NEVER right, in fact, you can count on them being wrong about 95% of the time.

    The worst part is when the customer doesn't know what's best FOR THEM. Especially when it's your job to do what's best for them... then you have a contradiction. I work in advertising, and I run into this constantly. It's my job to help my clients sell their products/services, and they've hired me to do just that. But many times, clients think they know how to do it themselves, and then tell me what to do, when their ideas could, likely, harm their image and their sales.

    What do I do? They've hired me to do my job and help them, but their very instructions will certainly harm them. My hands are tied, I just want to scream at them, "Let me do my job, and make you lots of money!"
  • Every several months... by chubbchubbs (Score:1) Monday December 10, @07:22PM
  • I used to be.. by spiffmastercow (Score:1) Monday December 10, @07:59PM
  • broken patterns by sentientbrendan (Score:2) Monday December 10, @08:18PM
  • Depends by Scud (Score:1) Monday December 10, @08:18PM
  • Are You Proud of Your Code? by Goondra (Score:1) Monday December 10, @08:39PM
  • Uh ... by ScrewMaster (Score:2) Tuesday December 11, @12:41AM
  • Commenting the code?? by madbawa (Score:1) Tuesday December 11, @02:39AM
  • Sometimes by RAMMS+EIN (Score:2) Tuesday December 11, @03:57AM
  • The art of commenting by rjwoodhead (Score:1) Tuesday December 11, @07:17AM
  • I like my soul, thanks... by Icarium (Score:1) Tuesday December 11, @08:53AM
  • Nothing I wrote for money is worth a... by grikdog (Score:1) Tuesday December 11, @06:12PM
  • Take small, meaningful steps by Twylite (Score:2) Wednesday December 12, @09:58AM
  • Code should read like a novel... by Simonetta (Score:2) Thursday December 13, @06:27PM
  • sometimes by burdalane (Score:1) Thursday December 13, @08:20PM
  • Get the customer involved by lazy b (Score:1) Friday December 14, @04:14PM
  • No by QuasiEvil (Score:2) Sunday December 16, @07:34PM
  • 44 replies beneath your current threshold.
(1) | 2 | 3