object oriented question

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
 
K

Karl Seguin

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
 
R

russell mccloy

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

RuSs
 
M

MattC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top