Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Patterns Vs EffectiveJava

I am student striving to improve my Java and general programming skills. I am familiar with some of the basic design patterns.

I have two books on my disposal "Head First to Design Patterns" and "Effective Java"(Josh Bloch), both aiming to promote good programming practices.

However I am confused as to "how should I read the texts so that it makes the most sense?"

From what I understand, design patterns are basics and effective java has some addon practices in addition to general design patterns.

What is the right way to look on the entire scenario?

like image 451
Nitish Upreti Avatar asked Aug 08 '26 00:08

Nitish Upreti


2 Answers

You just have to build your knowledge up. Some of that is by reading good books, of which the Josh Bloch book is a very good book. Some of it is by taking on programming tasks in your spare time and keeping an eye on blogs and other websites such as stackoverflow. While some of it you will get through other practical experience i.e. at work.

These things take time and come with experience. Just enjoy the language and immerse yourself in it. Patterns aren't the be all and end all of the language - they're part of an effective toolkit though. It's better to understand the language fully, then you will see how design patterns can help solve common problems and often solve them better. But definitely don't get obsessed by patterns, until you know the language well enough. If fact don't get obsessed by patterns at all!

I'd say the Josh Bloch book is the best book to concentrate on 1st - it's excellent and introduces you to all the key concepts (common methods such as equals and hashcode, enums, concurrency) and also introduces patterns which you'll get day to day benefits from e.g. Builder pattern.

like image 168
planetjones Avatar answered Aug 09 '26 13:08

planetjones


However I am confused as to "how should I read the texts so that it makes the most sense?"

My only advice is to avoid overkill and over-engineering. Some experienced OOP (and Java) programmers that learn design patters taking them as they were the Bible often create fuzzy and useless code. That seems contradictory, but if you think about it, it isn't.

When the goal of programming is no longer resolving a problem, producing useful tools, and having measurable results, but becomes the exposition of one's great sophistication, cleverness, and sometimes smartass egotism, then the code becomes just a bunch of tricky brainwave that is useless to anybody, excluding the one who wrote the code and feels good looking at his crazy "white elephant".

Many times I've seen useless applications of them. The most abused is the factory pattern, that in this moment is quite trendy and in fact put everywhere like a food dressing.

Many times I've seen proliferation of classes and interfaces, useless generalizations, which are pointless: in some cases I've seen packages with 2 useful classes, and 10 interfaces and/or abstract classes. I too feel the need of making the code "generic" and "reusable" but there has to be a limit.

Many times I've seen "religious wars" about these topics.

Read all the books you want, and take from them what you need. But after that, write reasonable code. Write useful stuff, that's the original reason why you started programming.

like image 30
gd1 Avatar answered Aug 09 '26 13:08

gd1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!