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 Suggestion on choosing a right pattern !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Suggestion on choosing a right pattern !!" Watch "Suggestion on choosing a right pattern !!" New topic
Author

Suggestion on choosing a right pattern !!

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, i'm developing a component to customise a database for a website, the following functions/methods may included :

1) DBconnection - connect db
2) getDbData - get data from db and generate table
3) displayDBdata - display table to webpage
4) setPrimarykey - set primary key for certain column in specify table
5) unsetPrimary - unset primary key
5) setIndexKey - set index key for certain column in specify table
6) unsetIndexkey - unset index
7) renamecolumn - rename db table's column name
8) renametable - rename specify table
9) addColumn - add column to table
10)deleteColumn - delete column in table

let assume that are basic functions which a component do, can someone pls suggest a suitable design pattern in my case ? thank you very much for your time and suggestion
[ November 30, 2004: Message edited by: Alvin chew ]
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
For database access, you might use Data Access Object, and as you need to have some properties change, you might use Transfer Object as well.

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)
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
if not using DAO, any suggestion on pattern for this case ? thank you !
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
http://faq.javaranch.com/view?WhenToApplyDesignPatterns


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
Joao Vitor Guimaraes
Greenhorn

Joined: Nov 02, 2002
Posts: 4
You should use DAO.
Take a look at Spring DAO facilities.
[]'s


Joao Vitor Lacerda Guimaraes<br />SCJP 1.4, SCJP 5.0<br />Belo Horizonte - Minas Gerais - Brazil
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
i running on time on current project ..and i totally new to DAO, if that is the case, what is the best book to get ?

however, i still hope any volunteer to take a look on how my design should be ..say about what class , interfaces involve or design pattern
[ December 02, 2004: Message edited by: Alvin chew ]
Sathya Srinivasan
Ranch Hand

Joined: Jan 29, 2002
Posts: 379
Originally posted by Alvin chew:
i running on time on current project ..and i totally new to DAO, if that is the case, what is the best book to get ?



If you are running short of time, you should probably be more concerned about getting the functionality right in the application rather than worrying about which design pattern to use. In most cases, you will end up with something close to a good design pattern. You can always refactor the code once you are sure that your program does what you want it to do (assuming you have good tests, of course).

The general rule is "Make it work, Make it right, Make it fast".


Cheers, Sathya Srinivasan - SCJP 1.2, SCWCD 1.2, SCMAD 1.0
Co-Author of Whizlabs SCMAD Certification Exam Simulator and SCMAD Exam Guide Book
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
Hello Alvin,

If you're running out of time I suggest you generate your DAOs rather than hand write them.

FireStorm/DAO imports database schema definitions from SQL scripts or from live databases via JDBC and then generates a complete persistence tier based on the Data Access Object (DAO) design pattern.

http://www.codefutures.com/products/firestorm/download/

Email support after you download - I'll be happy to arrange an unrestricted license key to help you meet your deadline.


PJ Murray
CodeFutures
http://www.codefutures.com
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
thank you very much for your help, PJ Murray ..which version you advice to download ? i definitely need your help

between, why not you introduce your product here? .. some brief intro may help all developer get known of this value and useful product
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suggestion on choosing a right pattern !!