in reply to Re: Code for elegance, code for clarity
in thread Code for elegance, code for clarity

To me, elegant code shows both clarity and inspiration. It can't be a little unorthodox, but the logic must always be transparent.

I would likewise complain in a code review. Fortunately, I am not subjected to them, as I find the concept fairly insulting. I think sometimes it's better to just say "Here is how we want things to be coded" and then talk to the person if you think something can be done better. At work, I hate having to play defense -- "can't we all just get along?". I hate getting assaulted by groups of people at once, like when three people walk into your tiny cube and start looking over your shoulder. Yep, readability and standards are important -- but they can be taken too far.

But yes, one or two short line comments would do wonders in maintainablity. Proof of wizardry does nothing for me. I don't think the "elegant" example was elegant at all. I thought it was quite un-elegant. It did the job, it worked, and it wasn't horribly ugly -- but it was not elegant.

What I want to see is code that is instantly recognizable -- something that doesn't require me to stare at it for one or two minutes to understand. It's ok to require Perl knowledge to understand your code, but I'd rather see more baby-perl rather than golf-perl at work AND on CPAN.

Though, when reading all of this, don't lose the art -- the soul of programming can be lost through coding standards, "readability", and such. Look at how un-fun it can be to write Java when everyone is complaining about how you must always follow convention X-Y-Z or pattern A-B-C. There is some merit, but there is also too-much-of-a-good-thing. In this case, the near-military enforcement of some questionable policies has made the users of this language into a near parody of themselves. A fine example that "too-readable" and "too-orderly" means "way too much code to read and too much work to do". ex: Thingy.getThingy().getOtherThingy().GetDocument(EndOfRant(),EndOfRantChecker(false,true,true);

I guess all things can be overdone or underdone. Still though, back to the point, I don't think elegance has been achieved quite yet.

  • Comment on Re: Re: Code for elegance, code for clarity

Replies are listed 'Best First'.
Re: Re: Re: Code for elegance, code for clarity
by perrin (Chancellor) on Jan 12, 2004 at 18:04 UTC
    Hey, code reviews are your friend! They are not out to get to you! Code reviews are needed because sometimes people don't know that there is a nice common idiom for doing something, and because we all have a tendency to cut some corners if no one is looking. Code reviews keep us honest.

    To be a great programmer, one has to learn to put the overall success of the team and the project ahead of one's personal attachment to his own code. I have a great deal of respect for people who can walk into a code review and look at their own code objectively as community property.

      I have a great deal of respect for people who can walk into a code review and look at their own code objectively as community property.
      As do I. Really, I do. Unfortunately, people tend to take it personally sometimes, especially in some languages where code style borders on religion (which is why I speak of Java). I would love to see fair and unbiased code reviews, but you can't do that when the group is not a meritocracy, but rather ruled on seniority and posturing. Having meetings to question code quality can get very ugly unless everyone is on good terms and is in it for the good of the group not the individual. I want the former, but I have been unable to find it (sad, actually).
        I have a great deal of respect for people who can walk into a code review and look at their own code objectively as community property.
        I had to.

        I was doing Y2K work at the time. The code I wrote wasn't really mine anyway. So, code review was the final acid test to see if what I was sending out was actually correct in every way and didn't cause any problems. In that environment, you quickly learn to disassociate yourself from your work. Otherwise, every question on the code can feel like a personal attack. I've watched that happen too.

Re: Re: Re: Code for elegance, code for clarity
by tilly (Archbishop) on Jan 13, 2004 at 16:40 UTC
    Your comments on code reviews reflect one of the biggest problems. How to give people feedback without getting egos involved.

    What you refuse to see, is your worst trap has more on the psychological dynamics which makes this so tricky. Badly given (or badly received) code reviews are counterproductive. Good ones offer value that can't be matched in any other way.