Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

OO design question

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like some advice on making my program more object oriented. Also, any help in developing a better system for documenting my design would be appreciated. I am currently using a text file (not follwing any type of template). I have Rational available, but have not figured this tool out yet.
Overall, I want to refresh the cache for a portal. This will be scheduled daily. I put what I want to happen inside a method the app server provides.
I have started by creating a new class called RefreshCache.
For four basic areas, I want to make a connection to a 3rd party tool and retrieve a resultset. These are four different areas because
1. the way I make the connection will be different for each type
2. I need to do separate logic on each tye of resultset.
RefreshCache
getBasics()
gc = new GetConnection()
results = gc.getResults()
gc.close()
//do calculation
Store results in hashtable for cache
Put hashtable into cache
getType1()
gc = new GetConnection()
results = gc.getResults()
gc.close()
//do calculation
Store results in hashtable for cache
Put hashtable into cache
getType2()
gc = new GetConnection()
results = gc.getResults()
gc.close()
//do calculation
Store results in hashtable for cache
Put hashtable into cache
getType3()
gc = new GetConnection()
results = gc.getResults()
gc.close()
//do calculation
Store results in hashtable for cache
Put hashtable into cache

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Johanna,
Just wanted to give this a try as an OO exercise.

------------------
~James Baud
Talk, does not cook rice. - Chinese Proverb

[This message has been edited by James Baud (edited January 16, 2001).]
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it looks like James has created a very good implementation for you. Consider buying UML Distilled which is an easy, but comprehensive manual on UML which is indispensable when doing OOAD and what Rational is designed for. You'll find it incredibly helpful.
 
Judy Herilla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,
Thanks for your reply.
Am I understanding this correctly to mean that by using the Connectionable interface, one is forced to follow the same pattern for each type of connection?
I am unclear about Connection2 having the same members as in Connection1.
For the main method in RefreshCache, I see how you suggest cycling through each type of Connectionable, but am unclear how getConnection might generate the type of Connectionable to use.
Any more comments are welcomed, this has been very interesting!
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BlueJ is an IDE that was developed to teach people OO design with Java. It's free and you can download it from: http://bluej.monash.edu/
Joe
 
James Baud
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johanna,
1) By using Interface the implementing classes are forced to implement the methods defined by that interface
2) Whatever members you see in Connection1 are defined in Connection2 to ..4.
3) I wasn't quite sure what you meant by "..different for each type" so I assumed it was the type of connection. The Connectionable type is generated depending on this difference, and it denotes a reference to an object of the corresponding implementing class, Connection1, 2, 3 or 4. Whatever properties this connection have will be designated as attributes for that Connectionable object.
I'm a rookie at this stuff so any comments or suggestions are most welcome. I'd also like to see some reactions from the experts.
------------------
~James Baud
Talk, does not cook rice. - Chinese Proverb
 
Judy Herilla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Connection1,2, and 3 are different classes, right?
How can Connection2 have the same members as Connection1?
The connections are to the same source, but they have different connection parameters.
 
James Baud
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I wasn't too clear about the meaning of "same members". Basically, I was trying to replicate the common members in Connection1 by putting comments instead of copying and pasting the whole set of members from Connection1 to 2..4. These should not be taken to mean that we're no longer free to extend the class by defining attributes w/in each class to capture the different connection parameters, or defining other methods.

------------------
~James Baud
Talk, does not cook rice. - Chinese Proverb
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic