Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 14th, 2005, 08:00 PM
techcode's Avatar
techcode techcode is offline
Sysadm1n
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2004
Location: Beograd
Posts: 1,190 techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)  Folding Points: 1130 Folding Title: Novice Folder
Time spent in forums: 3 Days 22 h 25 m 8 sec
Reputation Power: 176
Send a message via Yahoo to techcode
Can't decide which design pattern to use on a problem.

I have a system that does some stuff - and among other things it gets info about products from osCommerce's (famous web store software) database.

The trick is that I need to make sure system can easily take that data from other sources if needed. Obviosly data is more or less the same wherever I get it from - but in diferent format.

Specificly first thing to be added to the system is product management - in case someone doesn't already have osCommerce.


As I've been reading "Design Patterns Explained" book and I came to conclusion that number of patterns could be used to tackle this problem. Adapter, Bridge, Strategy or most likely Abstract Factory.


To sum it up. My plan is to write a "driver" for each type of data source that would all output the data in same format - format that application would understand.

Is this the right aproach? Is Abstract Factory right match for that?


PS. Asked this question in Perl forum, but no answer so far - so if some admin decides this is double post. Please move one from Perl forum into this one, or delete ones in Perl forum - thanks.
__________________

----------------------------------------------------------------------------------------------------
Are you a freelancer - looking for some extra/side income or full time work? Do you need someone to finish a programming or design project for you? Know just the place - I've been finding work using it since 2003. Check it out on www.scriptlance.com
----------------------------------------------------------------------------------------------------
Web Design & Development - Vasa veza za posao

Reply With Quote
  #2  
Old December 15th, 2005, 02:24 AM
NovaX NovaX is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Bay Area, California
Posts: 490 NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level)NovaX User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 1 h 26 m 20 sec
Reputation Power: 241
Send a message via ICQ to NovaX
The Factory pattern: You want to use it when creating (like) objects and don't want to expose the recipient to managing a mess of dependencies. Think of it as having a class that maintains the necessary configuration info, so 10 distinct classes don't need to get it as well and can focus on their business logic. You generally use factories with constructor dependencies, rather then setter injected ones.

The Strategy pattern: Its good when you are passing back an object with the SAME interface. The recipient doesn't need to know how its being done to effect their business logic and its determined at run time where you get to choose what is most appropriate. Imagine writing a chess game, where the computer competitor was trying to tune itself to be challenging (but not impossible). As it analyzed your moves, it determined on the fly what expert personalities to use against you and how good of a player you are. This strategy changes repeatedly at run time, but maintains a constant interface. (Sorry, this is a bit of a tough one to find a great example for)

The Bridge pattern: This one is tough to get your head around. Its all about allowing the abstraction and implementation to vary independantly. I like the example of a household switch (the abstraction) and the light/fan/etc (the implementation). The switch can be implemented in many ways, from a two-position to a dimmer to a clapper. However, it does need to have a reference to the implementator to tell it what to do. However, that's a standard interface (perhaps just a "On/Off" signal or a hard cut to the power). What it drives doesn't matter and can change over time. Some day you decide to switch from a two-position to a voice activated one and later have it change from turning on the closet light to the indoor spa (you renovated). This is the same pattern, but in software.

The Adapter pattern: This one just acts as, well, an adapter. It converts from a U.S. power socket to a European one. It lets your VGA monitor plug into the DVI port. It lets two software systems (with similar intents) share information without having to know how the other handles data. For example, both may maintain student records, but have different views on what a "student" is. It can be as trivial as one maintaining rank as "freshman" and the other by year. Neither need to know about the existance of the other and screw with its business logic. An adapter is the only one knowing both and handles the conversion process.

***
It sounds to me as if you want an Adapter pattern. Depending on what format it gets, it converts it to a standardized one. When looking at patterns, try to distill what their intent is and then try to match it to your own. Many are only subtly different, but that's because the intent (goal) has only slightly changed.

Last edited by NovaX : December 15th, 2005 at 02:30 AM.

Reply With Quote
  #3  
Old December 15th, 2005, 09:27 AM
techcode's Avatar
techcode techcode is offline
Sysadm1n
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2004
Location: Beograd
Posts: 1,190 techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)techcode User rank is First Lieutenant (10000 - 20000 Reputation Level)  Folding Points: 1130 Folding Title: Novice Folder
Time spent in forums: 3 Days 22 h 25 m 8 sec
Reputation Power: 176
Send a message via Yahoo to techcode
Thanks for clarifying the things. And from your explanation I also concluded that Adapter seems like best pick.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Can't decide which design pattern to use on a problem.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT