*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Design Patterns Practical Implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Design Patterns Practical Implementation " Watch "Design Patterns Practical Implementation " New topic
Author

Design Patterns Practical Implementation

Nik Shergill
Greenhorn

Joined: Sep 17, 2013
Posts: 7
Dear Everyone,

I am new on subject of Design Patterns. I am currently using Head First Design Patterns. I just completed with observer pattern.
I was looking forward to know the best possible way to implement the patterns or we can start with a shopping cart application and
implement whatever i learn in design patterns. If anyone is willing to join, please let me know.

Best Regards,
NS


Phoenix3,
Phoenix3, Like Us On Facebook
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

I consider that approach an *Anti-Pattern* for applying patterns, actually. What you're doing amounts to saying something like "Ok, now I've learned how to use a hammer, let me go out and try to build a house." Good luck with that, right? You need more than just a hammer to build a house.

Patterns are things you should keep in your "toolbox" until such time that you recognize that you are facing a problem that has been solved before (the context). Recognizing the context, you sift through your toolbox and pull out the pattern that is best applied to the problem at hand. Otherwise, if you just start walking around with a pattern in hand, looking for a problem to "solve" with it, you'll be like a crazy guy on the construction site just aimlessly walking around and flailing a chainsaw: you're more liable to cause damage and/or hurt someone than you are likely to help build anything.

A better approach would be to go breadth-first and become familiar with a number of patterns, paying particular attention not to the details of their implementations but to the *context* in which each can be applied. Then work on a project, without any preconceived notions of using patterns at all, and try to recognize the kinds of problems that you can solve with a proper application of an appropriate pattern.


Junilu - [How to Ask Questions] [How to Answer Questions]
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1006
    
    3
Junilu Lacar wrote:I consider that approach an *Anti-Pattern* for applying patterns, actually. What you're doing amounts to saying something like "Ok, now I've learned how to use a hammer, let me go out and try to build a house." Good luck with that, right? You need more than just a hammer to build a house.


I disagree. I think Nik's approach is analogous to having a hammer and trying to find a few small pieces of wood to nail together in the shape of a doll house.

Patterns are things you should keep in your "toolbox" until such time that you recognize that you are facing a problem that has been solved before (the context).


Patterns are things you keep in your toolbox once you know how to use them. Until then, there is some benefit to getting to them in a controlled environment. By trying various patterns out on toy applications, one gets an intuitive feel for the pros and cons of each pattern, as opposed to just the "Applicability" (or whatever) paragraph memorized by rote from the book.

A better approach would be to go breadth-first and become familiar with a number of patterns, paying particular attention not to the details of their implementations but to the *context* in which each can be applied. Then work on a project, without any preconceived notions of using patterns at all, and try to recognize the kinds of problems that you can solve with a proper application of an appropriate pattern.


I would suggest that approach after one has had a chance to get to know each one.

Bigger picture...
Our two approaches are probably just reflective of our individual learning styles. Some people can get a good feel for things such as design patterns, including when each one is applicable, just from reading a book. For others, a lot of the information in the books just leaks out unless/until we have a concrete experience to which to attach the information. My suggestions may well not work for you, Junilu, and it's possible that neither of our approaches will work for Nik. At least now Nik has two possible approaches, both of which seem reasonable.
Stijn De Mulder
Greenhorn

Joined: Apr 09, 2014
Posts: 3

Hi,

Design patterns are meant to solve specific problems. So you should be thinking "I'm gonna solve my design problems using patterns" and not "I'm create a design using design patterns".

So go ahead and create your initial design for the shopping cart application.

Personally it helps when i create my designs on paper first and think about them a little bit before i start the coding.
When you run into specific problems, you can always look at the patterns to find a solution.

It's of course meaningful to get an overview of the different patterns and specially what problems they solve.

There are a number of great resources on the web:

1. Nice overview of a number of patterns SourceMaking
2. Specific patterns for J2EE Core J2EE pattrns
3. Java design patterns video course on udemy Java Design Patterns

Hopes this info gives you a good head start. If you have a design you may contact me and i'll give you a review.


Follow me

Learn Design Patterns
 
wood burning stoves
 
subject: Design Patterns Practical Implementation
 
Similar Threads
Design Patterm Doubt
Design visualisation
Book for GoF
ConnectionPool
I am trying to decide which will be the best design pattern for my game