Tips on writing concise and elegant Java?

Read Bob Martin's Clean Code. It's a book full of tips on exactly this subject: writing well-organised, very readable code, with Java as the example language.

1 +1 for that. Also remember (I don't think this merits an answer of its own) that you can break complicated expressions across lines - unlike python. – Ninefingers Jan 8 '11 at 2:06 Started reading it, it indeed looks like a jumbo-pack of answers to my question.

Thanks! – P? Teris Caune Jan 12 '11 at 13:00 Old thread but Python expressions can be broken with the '\' character if by 'lines' we mean lines of text.

– Erik Reppen Aug 26 '11 at 15:50 Please read "Clean Code" with some skepticism. The ideas are great, but I find some examples too dogmatic. E.g."extracting methods till you drop" will make your code less concise and (in my opinion, because of much more indirections and hidden dependencies) less readable.

– DaveBall Aug 27 '11 at 23:14.

You can achieve this to some extent on different levels: the language itself: use all features the language offers, e.g. The ternary operator (though some think it's not very readable) and Java7's elvis and diamond operator how you implement: use all the libraries and their features! Don't optimize prematurely! The design: use design patterns and the suggestions in Josh Bloch's Effective Java.

Precisely document your design decisions by referencing them (e.g. "Visitor" or "Bloch Item 7").

The Ternary Operator (shorthand for if-then-else statement) can be handy. String value = {condition}? "Was true" : "Was false.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions