aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Refactoring to Patterns - reader questions 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 "Refactoring to Patterns - reader questions" Watch "Refactoring to Patterns - reader questions" New topic
Author

Refactoring to Patterns - reader questions

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, good day, mr.Joshua Kerievsky , what is the big different in your book as compare to martin fowler refactoring book ? thank you !
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
what is the different between pattern and anti-pattern ?
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Joshua's book focus on the refactoring methods. Inside his book, he has quote 27 methods for refactoring.

Details can be found from:
http://www.industriallogic.com/xp/refactoring/catalog.html

Martin's book focus on various areas, in addition to the refactoring methods, such as the theory of refactoring, basic background, testing, and refactoring tools.

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)
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Alvin chew:
what is the different between pattern and anti-pattern ?

In general, anti-patterns are problems that happen frequently in computer programming and that should be avoided in good practice. In other words, while design patterns are good examples, anti-pattern is negative examples.

Hope it helps...


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

what is the different between pattern and anti-pattern ?

Pattern is, some people in the past using a good idea to develop a certain kind of system successfully, and thus, we reuse his idea (pattern) to build systems with similar nature.

Anti-pattern explains you why a pattern solving a problem looks good, but finally it comes up with a bad solution.

Details for anti pattern can be found from:
http://c2.com/cgi/wiki?AntiPattern

Nick
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
what are the common design pattern that we normally use in s/w development ?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
which ide support all refactoring methods ?
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

what are the common design pattern that we normally use in s/w development ?

For Web based: Model View Controller, Front Controller, Interceptor
For Distributed systems: Services Locator, Session Facade

In general, Factory, Singleton, Command etc.

Usually, a project will make use of more than 1 pattern on different components. Based on the needs, you will choose those suitable patterns.

Nick
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Originally
which ide support all refactoring methods ?

It depends on the level of refactoring.

For simple refactoring, like changing methods, etc, WSAD and NetBean.

For more complicated, maybe we need some refactoring logic, you may consider IntelliJ Idea.

A detail list can be found from:
http://www.refactoring.com/tools.html

Nick
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
i have a scenario, let assume we have 10 web pages, with each contains html form in web application, and these 10 page having same functionality, which are allow user to keyin data, and when user click button, it will save user entered data into database with different respective tables, and finally diplay the message either success or fail to save.

now, i want to build a component for this scenario, what design pattern and perhaps steps you recommend? thank you , Nicholas !
[ September 07, 2004: Message edited by: Alvin chew ]
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
please guide me if i wrong, is refactoring more focus on methods/functions and design pattern focus on structure on classes ?
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

i have a scenario, let assume we have 10 web pages, with each contains html form in web application, and these 10 page having same functionality, which are allow user to keyin data, and when user click button, it will save user entered data into database with different respective tables, and finally diplay the message either success or fail to save.

now, i want to build a component for this scenario, what design pattern and perhaps steps you recommend? thank you , Nicholas !

You may consider to use Model View Controller.

If you are using J2EE, those 10 web pages (or JSP) are Views, while the Servlet, as the controller, receives requests (submit action) and forward to the corresponding modules to process the request. Upon processing, it also determines which View to show the data retrieve (Model), no matter success or not.

Nick
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

please guide me if i wrong, is refactoring more focus on methods/functions and design pattern focus on structure on classes ?

By refering to Fowler's definition:
Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.

Details can be found from:
http://www.refactoring.com

Nick
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
i actually applying this scenario into struts framework, and i thinking of come out a component to help me to do this job..

generally, i want this component to do following tasks:
1)detect the user clicked form button (so we know what form are coming in)

2)form data accepted and save into DB(believe have to apply design pattern here..what design pattern recommend ?)

3)generate result message(success/fail)

for information, this is school project for testing idea on writing component..

:-further description on struts flow

i design every page using DIFFERENT action paths(href) but SAME action type(actual class for action), i design this because i want every page make sure cross over the component which i planning to do ...

is there anyone have comments and advice of these ? thank you very much on time !!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Alvin, please don't post all your questoins inside the same thread. That makes it very hard to notice when there is a new question, which question was already answered etc.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
sorry, i try put another thread !!
Ko Ko Naing
Ranch Hand

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

For simple refactoring, like changing methods, etc, WSAD and NetBean.

For more complicated, maybe we need some refactoring logic, you may consider IntelliJ Idea.


I heard that WSAD's refactoring feature is even better than JBuilder, which is more expensive than WSAD... but I've never tried InteliJ Idea before...

Just my $0.02
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Ko Ko Naing:


I heard that WSAD's refactoring feature is even better than JBuilder, which is more expensive than WSAD... but I've never tried InteliJ Idea before...

Just my $0.02



Refactoring with InteliJ

http://www.jetbrains.com/idea/training/refactoring.html

http://www.ociweb.com/jnb/jnbFeb2002.html


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Alvin chew:
what is the different between pattern and anti-pattern ?


Pattern
A pattern describes a proven solution to a recurring design problem, placing particular emphasis on the context and forces surrounding the problem, and the consequences and impact of the solution.



Anti-pattern
An anti-pattern is either...

A pattern that tells how to go from a problem to a bad solution, or
A pattern that tells how to go from a bad solution to a good solution.
"Or vice-versa"


Pattern
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Alvin chew:
what are the common design pattern that we normally use in s/w development ?



This picture will help you




Reference Website
http://www.corej2eepatterns.com/Patterns2ndEd/index.htm
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I heard that WSAD's refactoring feature is even better than JBuilder, which is more expensive than WSAD... but I've never tried InteliJ Idea before...

As I focus on WSAD development, I highly reliy on WSAD refactoring. If time is allowed, I may try to read other tools.

Nick
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Alvin chew:
what are the common design pattern that we normally use in s/w development ?


The most important: those described by GoF. For multi-tier application you can check the J2EE design patterns. For different application domains you will find a long list of design patterns (enterprise integration patterns, concurrent system patterns, etc.).

There is not possible (my 2c) to create an exhaustive list of patterns.

./pope


blog - InfoQ.com
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Alvin chew:
which ide support all refactoring methods ?


I found most of the most used already existing in IntelliJ IDEA and Eclipse. Also Netbeans has a plugin offered by RefactorIT which offers a nice set of out-of-the-box refactorings.
Joshua Kerievsky
author
Greenhorn

Joined: Sep 08, 2004
Posts: 14
I've been using Eclipse for some time now -- the refactoring support continues to get better and better. For example, if you do an Extract Method, Eclipse can notice if the same code you are extracting is also duplicated in other parts of the class. If so, it can automatically replace all of the duplicated code fragments with a call to the extracted method -- my jaw dropped when I first saw the tool do this.


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

Joined: Jul 12, 2004
Posts: 995
Originally posted by Joshua Kerievsky:
I've been using Eclipse for some time now [...] Extract Method [...]


Yep. This one is one my favourites and it works very smooth.

./pope
Ko Ko Naing
Ranch Hand

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

As I focus on WSAD development, I highly reliy on WSAD refactoring. If time is allowed, I may try to read other tools.

Nick


Nick, you don't need other tools, since you expertized the WSAD already...

Since I've been using JBuilder, since my university life... I'm facing a bit difficult to move to WSAD right away...
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Joshua Kerievsky:
I've been using Eclipse for some time now -- the refactoring support continues to get better and better. For example, if you do an Extract Method, Eclipse can notice if the same code you are extracting is also duplicated in other parts of the class. If so, it can automatically replace all of the duplicated code fragments with a call to the extracted method -- my jaw dropped when I first saw the tool do this.


The Eclipse feature that you talked about is pretty interesting for me... Is that built-in in Eclipse? Or do we need some kinda plug-in to get such feature in Eclipse?

BTW, I heard from one of my freinds that Eclipse 3.0 got a lot of improvements in refactoring feature... Is it true?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
not sure on refactoring improvement, but it doest faster as compare previous version
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Ko Ko Naing:
The Eclipse feature that you talked about is pretty interesting for me... Is that built-in in Eclipse? Or do we need some kinda plug-in to get such feature in Eclipse?
Yes, refactoring support is built-in in Eclipse.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refactoring to Patterns - reader questions