Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refactoring to Patterns - reader questions

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the different between pattern and anti-pattern ?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are the common design pattern that we normally use in s/w development ?
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which ide support all refactoring methods ?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, i try put another thread !!
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure on refactoring improvement, but it doest faster as compare previous version
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic