File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes refactoring to pattern - howto choose pattern ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "refactoring to pattern - howto choose pattern ?" Watch "refactoring to pattern - howto choose pattern ?" New topic
Author

refactoring to pattern - howto choose pattern ?

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, wondering how to you guy choosing pattern, is it based on scenario? so before choose, do your have a very deep understanding on every pattern before choose the best suit pattern?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
is it possible the IDE will support pattern as well ?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Alvin chew:
hi, wondering how to you guy choosing pattern, is it based on scenario? so before choose, do your have a very deep understanding on every pattern before choose the best suit pattern?

Yes, it's supposed to be based on a scenario you're facing. The idea is to look for known solutions for a problem you have, not to look for a problem to apply your known solution to.

Originally posted by Alvin chew:
is it possible the IDE will support pattern as well ?
Yes, to some degree. For example, Rational's XDE has some kind of "design pattern wizards" that you can use to convert your source code to use patterns etc. based on templates. I have to say I'm very sceptical regarding those features -- it makes it too easy for a developer new to design patterns to auto-apply design patterns all around the codebase without giving it any thought and essentially making the codebase "instant legacy" a bit like many GUI builders have done.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Alvin chew:
hi, wondering how to you guy choosing pattern, is it based on scenario? so before choose, do your have a very deep understanding on every pattern before choose the best suit pattern?


One definition of a pattern is a known solution to a recurring problem, so identifying it is some kind of scenario.

./pope


blog - InfoQ.com
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Alvin chew:
is it possible the IDE will support pattern as well ?


Some IDEs offer templates for creating simple patterns (singleton, factory method, etc).

./pope
Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
Originally posted by Ali Pope:


Some IDEs offer templates for creating simple patterns (singleton, factory method, etc).

./pope


Notice, though, that a pattern typically should be adapted to the concrete problem at hand.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

wondering how to you guy choosing pattern, is it based on scenario?

YES. You need to fully understand what you needed, based on what system you are using.

For example, if your system dont have multiple views, like internal data transfer, with a single success/fail with reason return, why border with MVC?


so before choose, do your have a very deep understanding on every pattern before choose the best suit pattern?

Not necessary, you may regard it as a case study of your system. See the system requirement, and try to find out any patterns which match with the requirement.

Of course, if you have some ideas on patterns, you can work it out more easily.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Joshua Kerievsky
author
Greenhorn

Joined: Sep 08, 2004
Posts: 14
I think that to be good at refactoring to, towards or away from patterns you need to understand design smell and design solutions. You can learn about smell by studying the Coding Smells chapter in my book and in Fowler's Refactoring. I can't stress enough how important it is to understand these smells. Without knowing what is wrong with designs, it is really hard to know how to improve them. Once you get comfortable with the smells, you can then study the patterns literature. Some say that it is easier to learn patterns by studying pattern-directed refactorings, like the few you'll find in Fowler's Refactoring and the many you'll find in my book. However, it is also useful to study books like Design Patterns, or well-written patterns workbooks, like the ones by Steve Metsker. I know there are many books for us all to read -- yet it really is vital to read the best patterns and refactorings texts, for they address the very heart of design.


Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0321213351/ref=jranch-20" target="_blank" rel="nofollow">Refactoring to Patterns</a>
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I know there are many books for us all to read -- yet it really is vital to read the best patterns and refactorings texts, for they address the very heart of design.

Any recommendation on these books that are good to read?

Nick
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Nicholas Cheung:

Any recommendation on these books that are good to read?

Nick


I think Joshua is talking about this book This book would be a great book about patterns, more than refactoring...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Does the book an exercise book?

btw, I have read this book long time ago.

Nick
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Nicholas Cheung:
Does the book an exercise book?


I haven't read the book as well... The name "Design Patterns Java Workbook" seems it's an exercise book... :roll:
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Nicholas Cheung:
Does the book an exercise book?

btw, I have read this book long time ago.

Nick


I did too, but wasn't really helpfull after GoF.

./pope
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I haven't read the book as well... The name "Design Patterns Java Workbook" seems it's an exercise book...

I guess so. Maybe we should read the classic book: Design Patterns

Nick
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
It is very difficult to beat GoF.

Nick
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Nicholas Cheung:
It is very difficult to beat GoF.

I would say it's rather easy to beat GoF, if you're targeting a Java audience.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Lasse Koskela:

I would say it's rather easy to beat GoF, if you're targeting a Java audience.


On what? Implementation details? What is left for us, for our brains and pleasure?

./pope
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I would say it's rather easy to beat GoF, if you're targeting a Java audience.

Really? Even Core J2EE patterns are somehow based on GoF.

Nick
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Ali Pope:
On what? Implementation details? What is left for us, for our brains and pleasure?
Well, I've heard plenty of people state that they found GoF a bit akward read while books like "Applied Java Patterns" have received praise for their readability.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Nicholas Cheung:
Really? Even Core J2EE patterns are somehow based on GoF.
Yes, they may be, but that doesn't make GoF any easier to read and doesn't translate the C++ code examples to Java.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I've heard plenty of people state that they found GoF a bit akward read while books like "Applied Java Patterns" have received praise for their readability.

Does this because GoF is too generic that makes it becomes more difficult to understand and read?

Nick
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Does this because GoF is too generic that makes it becomes more difficult to understand and read


I feel that GOF explanation is not easy to understand. One needs to read it several times to understand, at least me.


Groovy
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Lasse Koskela:
Yes, they may be, but that doesn't make GoF any easier to read and doesn't translate the C++ code examples to Java.


I consider it enough generic and not so complicated reading (i've read it in english which is not my native). It is the 1st ranked for me :-).

./pope
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Some of the concepts are difficult to understand clearly.

I feel J2EE patterns are more comfortable for me to read.

Nick
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Nicholas Cheung:
Some of the concepts are difficult to understand clearly.

I feel J2EE patterns are more comfortable for me to read.

Nick


The years of experience gained in expressing/describing patterns are prooven in J2EE patterns. Another thing that ease their understanding is their direct applicability expressed through examples.

./pope

but I still believe the GoF is the best :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: refactoring to pattern - howto choose pattern ?
 
Similar Threads
Exam doubt
MVC is a design pattern or an architecture ?
Design pattern questions in SCWCD
Design Patterns Questions
url matching doubt