Here's a question for those of you who have experience of fixing or enhancing other people's Java code, which I hope will also be really useful for those in the early stages of learning programming. Please contribute!
If you've looked at other people's code, you will know that sinking feeling when you discover 2000 consecutive lines of unindented spaghetti. On the other hand, sometimes you pick up a class library and it just oozes clarity and professionalism.
So the question is - what are the immediate clues that tell you whether a piece of code is a nightmare or a dream? What I'm really hoping for are highly specific answers rather than generalisations - it would be good to be able to use them as a set of explicit tests that we can all apply to our code.
Here's a few of my favourites for starters:
Bad signs:
No indentation or (far worse) wrong indentation.
If, else, or loop blocks that I can't fit on one screen.
Repeated blocks of code that only differ in a couple of lines.
Good Signs:
Member names that fully describe what the member is without needing a comment.
Methods that start with a series of assert statements that document and check the parameters.
Lots of Observer/Listener interfaces.
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
VernonDozier 2,218 Posting Expert Featured Poster
Salem commented: Here you go - http://www.catb.org/~esr/faqs/smart-questions.html :) +29
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.