object oriented question

  • Thread starter Thread starter Russell
  • Start date Start date
R

Russell

Hello all,

I have an object in business layer called
JPPage
Which has the properties:
id
title
content
parent
level

what I want to know is. I have a crumb trail on my front end which
only requires the properties id and title. So do I use a collection of
JPPage objects (even though the JPPage object has more properties that
I need for my crumb trail) or do I create a crumb trail object with
properties id and title? If I do this then in essense I have duplicate
code.

Or do I create an object, for example, called JPSimplePage with the
properties id and title and then create an object JPPage which
inherits JPSimplePage and has the additional properties of content,
parent and level?

Thanks in advance, just want to get my OO methology correct.

thanks
Russ
 
Russell,
First off, I don't see anything overly wrong with having a collection of
JPPage objects which only have a couple of their properties set. The only
real problem I see is that people might try to access other properties -
since it's fairly reasonable to expect the entire set of properties to be
properly set.

I think your inheritance idea is the way to go. This way there's no
confusion about what data is available when.

KArl
 
cheers Karl.. I thought you might say that. Im loving OO. no more
spagetti code!!

RuSs
 
Russell if you have duplicate code then you may need a further level in your
hierarchy

How about:

BaseObject
id

CrumbObject : BaseObject
title

JPPage : CrumObject
content
parent
level

MattC
 
Back
Top