I'll say again I'm no expert but I'm not sure it's a good hierarchy you're 
embarking on (but its hard to tell with no details) and think your 
ContentService should probably have an association to an ImageService instead.
Then your contentService would just use <cfreturn 
variables.ImageService.getImageByGallery() />
This also means you can use your imageService in other services using the same 
association.

Although the sentence 'an image service IS-A content service' sounds correct in 
the real world it doesn't mean it works at a design level. If your 
contentService is full of methods that your ImageService can use then perhaps 
it is a candidate for a parent / child relationship.
If ImageService would only ever use one or two of ContntService's methods then 
it definately IS NOT a good candidate for a subclass.

And thinking along the lines of parents accessing methods in a subclass I don't 
think helps either. A good way that inheritance hierarchies evolve is when you 
have a class then you realise you need something similar but slightly 
different. Then you realise that some methods in both classes can be shared. 
Then you refactor by creating a parent class, copying the dupe methods up into 
it and taking the dupes out of the child classes. Add an extends="path to 
parent" and you've refactored. And you'll want to unit test this all the way of 
course :-)

Hope this helps and I'm sure some will disagree with me!
________________________________________
From: [email protected] [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] 
[EMAIL PROTECTED]
Sent: 01 May 2008 18:27
To: CFCDev
Subject: [CFCDEV] accessing sub-class methods

I need to know if I can access the methods in a child object from its
parent class and if so, how I might do that.

I have a contentService object that is getting fairly full of
functions, many having to do with images so I was thinking of creating
a sub-class of content and call it imageService. What I have is a
getImageGallerys() function and a getImageByGallery function(), among
others. I plan to create a function that gets a single gallery from
getImageGallerys(), then uses the gallery's id to retrieve its images
from getImageByGallery() returning that query to the view.

I guess I was thinking this function would be in the contentService
object, but I suppose it should be in the imageService sub-class I
will create. What are your guys thoughts on this, and can I access
methods in a sub-class from a class?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to