What attributes make programming code 'good'?

Hi, I got Two below questions in interview : 1. What attributes make programming code 'good'? 2. What would you change about Java if you alone had the ability to improve it in any way? Can any one plz guide me what will be the exact answer. Regards Bikash [ November 26, 2003: Message edited by: Bikash Paul ]

Patterns are nothing if the code is unreadable. Patterns are worse than nothing if abused or otherwise used incorrectly. Good code is self-documenting. It should be a pleasure to read, easy to understand for someone who knows the language and has some knowledge of what the program is meant to do. THAT is good code, not code that slavishly follows a set of standardised practices just because they're the standard!

Good code is - easy to understand - robust; if you change one part, other parts don't break surprisingly - moveable; it's easy to exchange and/or reuse small parts of it - supple; it makes it easy to do things the right way "Agile Software Development - Principles, Patterns and Practices" by Robert Martin is a very good book on the topic.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus

Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112

posted Nov 27, 2003 05:40:00

0

Originally posted by Bikash Paul: 2. What would you change about Java if you alone had the ability to improve it in any way?

I wouldn't discount the value of a small set of metrics also. In particular: (1) Methods should be small to make the readable, maintainable, and probably more reusable. (2) Classes should be small for nearly the same reasons. (3) Watch the number of method parameters on any method closely. (4) Be wary of very deep inheritance hierarchies. Also be wary of no inheritance at all in an entire program. I generally keep an eye out for those in my code reviews and use these metrics (which Kent Beck would call "Code Smells") as a guide to understand what should be refactored. Kyle