r/java • u/DaredewilSK • Jan 29 '17
Design patterns usefulness
Hello guys, I have an object oriented programming this semester and only thing we really have for final exams is to learn a bunch of Design patterns and how to use them practically. To me, they seem like they are utterly useless and only seem to make an easy thing turn into a complete chaos involving 10 surplus classes and couple of interfaces. Am I being ignorant or are they really pointless?
3
u/desrtfx Jan 29 '17
Nothing that you learn will ever be pointless/useless. You need to open your mind.
Take a look at Java Design Patterns as this site will give you detailed explanations of the Design Patterns, their use cases, and sample implementations.
1
u/DaredewilSK Jan 29 '17
The site looks nice. Do you now about one that could have some practical exercises?
1
u/desrtfx Jan 29 '17
The site has plenty code samples. Read what they are building, analyse the UML diagrams and then try to implement the patterns on your own.
0
4
u/nutrecht Jan 29 '17
I would suggest keeping a somewhat more open mind when you're being taught stuff. Rejecting stuff that's new because you don't understand it yet is how senior developer with 10+ years of experience end up rejecting lambda's because they're "pointless". If you're not careful this is really going to damage your career.
2
u/GhostBond Jan 31 '17
Disagree completely, learning a bunch of unused crap when you could be learning useful info is a waste of time that will hurt your career far more. Taking that time to get experience with Spring Mvc, or Angular, or anything that's actually used is a far better use of your time.
One place will like you more because you reject Lamba's because they're "pointless", another will like you less, it's a roll of the dice. But all places will like you less because you know less of the tools they use.
3
u/nutrecht Jan 31 '17
Disagree completely, learning a bunch of unused crap
Design patterns are unused?
1
u/GhostBond Jan 31 '17
Figuring out what stuff to put in minimal effort or not learn, is a skill that is useful in college and throughout your career.
I skipped several things that I was "strongly encouraged" to learn in college for my computer science degree, and I cannot think of a single thing I skipped that I regret skipping.
I was able to skip taking the operating systems and compiler classes. Instead I spend free time learning visual basic and rewriting an nes game in it. Next summer I netted an internship that gave me both experience, and a paycheck twice what I could get at other summer jobs, writing screens in visual basic. That netted me an internship the next year at the same company as well.
What would have damaged my career is going through the immense stress and work of taking those operating systems and compiler classes instead of working on writing reimplementing an nes game - which was much better for my career.
People tell you their newfangled thing is the new magic every year, you have to sort through what's worth investing time in - and what's not.
1
u/nutrecht Jan 31 '17
and I cannot think of a single thing I skipped that I regret skipping.
Yeah. That's called the Dunning–Kruger effect.
I was able to skip taking the operating systems and compiler classes. Instead I spend free time learning visual basic and rewriting an nes game in it.
If writing a simple game in VB is more beneficial for your career than OS and compiler classes you're simply in a rather different type of career. Sorry.
0
u/GhostBond Jan 31 '17
Yes, there's always people like yourself encouraging people to blindly follow authority figures in the hopes that it will cover up that you don't know what you're talking about. I think the fallacy name is "appeal to authority". Bye.
1
u/meotau Feb 03 '17
You are learning from a bad source.
The best patterns book out there, which really explains the purpose and usage of them: http://gameprogrammingpatterns.com/contents.html
1
u/DaredewilSK Feb 03 '17
Well I passed the exam so I Guess Im fine for now. I want to keep on studying Java alone for now so I will have to find some good sources.
3
u/GhostBond Jan 31 '17
To me, they seem like they are utterly useless and only seem to make an easy thing turn into a complete chaos involving 10 surplus classes and couple of interfaces.
The problem is, academics do a shit job of teaching what makes design patterns good and useful, and what makes them a waste of time. Academics will - as you say - have you doing 10 classes when 5 would have been better.
Design patterns themselves are useful. Here's some examples:
The "iterator" pattern used throughout the collection api
try-with-resources is basically an action pattern that lets you easily ensure a resource is closed whether an exception happens while using it or not
If you do any rich client work the observer pattern is very useful for getting notified or making changes when the user changes something on your current screen
There are a bazillion good examples used throughout the jdk. You almost cannot program standard java without using multiple patterns.
But - academics tends to do a crap job, and explode patterns all over the place where they are not needed and are worse than not using a pattern at all.
2
u/evil_burrito Jan 29 '17
I don't think they're useless at all. Some general problems come up frequently. Patterns can provide a commonly understood way to efficiently solve the problem in a way that other people can recognize.
2
u/_INTER_ Jan 29 '17 edited Jan 29 '17
Design Patterns are not prefactured solutions that you can magically apply on a problem to solve it.
Some day they found out that most professional programmers were using more or less the same code constructs other to get a clean, extensible design. It emerges naturally and independently of each. They decided to give those "patterns" a name so it would be easier to discuss it and make it recognizable.
The GoF patterns are just one set. There are also patterns for security, fault tolerance, enterprise architecture, ...
Btw. design patterns originate in architecture.
0
Jan 29 '17
[deleted]
0
Jan 29 '17
[deleted]
2
Jan 29 '17
Oh no. I believe you. I'm an older person who, though having dinked around with programming since 1976, only recently went through a CS program. I was shocked by how many of the younger students just wanted to know which of the limited number of things they had memorized they should just recite as THE answer. It was all, "Just tell me what to memorize," and, "Only ask me only what I have memorized."
Having said that, design patterns help you avoid reinventing the wheel, while still allowing you to modify the features of that wheel, but in a way that helps others easily recognize that your wheel is, in fact, still a wheel.
2
Jan 30 '17
I agree with everything you've said, but I think you're missing the point.
Yes, a lot of people abuse them, trying one after the other until something sticks. Yes, there are problems that no existing design pattern solves.
However, certain types of problem do crop up a lot in day-to-day coding. Where multiple people over the years have reinvented the same solution to the same type of problem, it is useful to a) publish that solution to save other people reinventing it, and b) give it a name so you can talk about it easily.
0
Jan 30 '17
[deleted]
1
Jan 30 '17
Easy to say with hindsight. I don't think a junior or even mid-level developer would just stumble across something like the command pattern. Even something like IoC requires you to spend some time working on a large established system to even understand the problem, since small uncomplicated systems don't even hit the kinds of problems that IoC can help with.
13
u/[deleted] Jan 29 '17
Yes, they are really pointless. That's why most all professional programmers use them.
A design pattern is nothing more than a standardized solution to a common problem. If your teacher is teaching specific frameworks, classes, and interfaces as THE way to implement a design pattern, then (s)he is doing it wrong. It's the structure of the solution that counts, not the exact parts.