Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What attributes make programming code 'good'?

 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patterns are the key to good java.
see:
http://www.javaworld.com/columns/jw-java-design-patterns-index.shtml
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 would pay more attention to bug reports than Sun does.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic