The Artima Developer Community
Sponsored Link •

Design Forum
Swing Design Patterns

2 replies on 1 page. Most recent reply: Dec 20, 2002 4:40 PM by Ramzi Ben Yahia

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Ramzi Ben Yahia

Posts: 23
Nickname: miccheck
Registered: Jul, 2002

Swing Design Patterns Posted: Dec 20, 2002 7:13 AM
Reply to this message Reply
Advertisement
Hi,

I need some help to refactor a desktop application using swing and collecting data from two databases. What I've tried to do first is locating the bad smells in some thousand lines of code. And I noticed that there's many copy/pastes of code specially in the swing's part. I've already done a nice work with the database's part by refactoring all of the database access code and splitting it into a business part and a framework part.
For the Swing's part I'm willing to introduce the chain of responsabilities pattern and the command pattern.
the goal is to have the User's Action handled as a Request
by a chain of handlers , the handlers can add some information to the request, the request then will be executed as a command in background ( SwingWorker ) . and finally the UI will be updated. If you have some suggestion or if you think that this solution stinks more than the copy/pastes actually existing please don't hesitate to reply to this topic.

Ramzi from Paris


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Swing Design Patterns Posted: Dec 20, 2002 1:52 PM
Reply to this message Reply
It is an interesting question, because someone who knows Swing can probably understand the cut-and-pasted code, but not be able to as quickly understand your Chain of Responsibility implementation. I would say, if it makes the code more complex (try to imagine it from the point of view of someone you just hired to maintain the code after your refactorings), then you need to think some more about how to make it clean and simple, without all the cut-and-paste duplication. It if seems like it will be more clear, then of course, go for it. Sometimes a lot of duplicate code can be removed by simply creating a few helper objects or methods.

Ramzi Ben Yahia

Posts: 23
Nickname: miccheck
Registered: Jul, 2002

Re: Swing Design Patterns Posted: Dec 20, 2002 4:40 PM
Reply to this message Reply
> It is an interesting question, because someone who knows
> Swing can probably understand the cut-and-pasted code, but
> not be able to as quickly understand your Chain of
> Responsibility implementation. I would say, if it makes
> the code more complex (try to imagine it from the point of
> view of someone you just hired to maintain the code after
> your refactorings), then you need to think some more about
> how to make it clean and simple, without all the
> cut-and-paste duplication. It if seems like it will be
> more clear, then of course, go for it. Sometimes a lot
> of duplicate code can be removed by simply creating a few
> helper objects or methods.

thx for your reply.
in fact the goal of this refactoring is to make the user's Action(s) pluggable into the GUI by means of configuration file.
think of Struts , this kind of separation between view and actions and the chaining of handlers once understood becomes a powerful tool, and adding features to the application becomes more easy . Helper classes could be a first step in the refactoring and I've already done half of the work. but it seems to me that at certain level of a development cycle, it's important to have the core of the application stabilized once for all and that addition of features does'nt affect this core with any change.that's my point of view

Flat View: This topic has 2 replies on 1 page
Topic: Beautiful EJB? Previous Topic   Next Topic Topic: Question about MVC

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use