• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

need comments/suggestions for my A&D

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My programming experience is mostly in ASP & PHP, but I will be asked soon to work with Java (probably JSP and servlets). I've started studying, and now I want to build a sample application for my own learning purposes. I chose an application that I built in PHP, and decided to convert it to Java.
As you may have guessed, I'm new to OO, even if I have the SCJP for 1.4. Therefore, I need a little help with the design of my application. The application is something we use on our portal to maintain links suggested by our members.
A member may suggest a link, and the administrator will approve, modify or reject it. The admin may also create, modify and delete links in the db. In addition, before a link is created, the app must check if the link already exists in the db, and if it does, give the admin the chance to synchronize the information (maybe changing the title of the web site).
Would you please have a look at the rough sketch of classes below and give me your opinion?
super-class:
Link
-title
-url
-category
-description
-createLink()
sub-class:
MemberLink
-isApproved
sub-class:
AdminLink
-deleteLink()
-modifyLink()
-approveSubmittedLink()
-rejectSubmittedLink()
-synchronizeLink()
-------------------------
What I'm not too sure about is the sub-class AdminLink. For example, the only difference between deleteLink() and rejectSubmittedLink() is that deleteLink() deletes a link that was already approved, while rejectSubmittedLink() deletes a link that was never approved. Should they be two separate functions?
I don't think so because the functionality is almost the same...
Any comments/suggestions would be deeply appreciated.
Thanks,
Marie
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me that what you can do with a link isn't dependend on the type of the link, but on its *current state* and on *who is trying to do it*. So I'd think that you shouldn't use inheritance here...
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree.
You should be thinking in terms of responsability.
Keep it simple: A link is just an url.
"Who has the responsability to manipulate the links (approve, reject, delete, submit new, etc)?"
is better than
"what can be done with this link?"
greetings.
 
Marie Mazerolle
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the comments, it's very much appreciated!
 
mooooooo ..... tiny ad ....
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic