Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

RE: RE: RE: RE: Object Heirarchy / Design

by jreades (Friar)
on Nov 15, 2000 at 21:37 UTC ( [id://41806]=note: print w/replies, xml ) Need Help??


in reply to RE: RE: RE: Object Heirarchy / Design
in thread Object Heirarchy / Design

While I agree with this in principle, I'm not sure I agree with the execution.

I think that you'd really want Obj to return an instance of a subclass (e.g. Obj::DB or Obj::FlatFile).

Then you maintain the consistency of the interface -- so that your objects all share the same methods and simply overload them as necessary, but the implementation specific to each type of object occurs in seperate classes/objects.

I thought I remembered seeing something in Fastolfe's node, but I a quick look didn't come up with anything.

Replies are listed 'Best First'.
RE (a lot) tilly: Object Heirarchy / Design
by tilly (Archbishop) on Nov 15, 2000 at 23:23 UTC
    The execution is fine.

    The constructor for Obj as chromatic wrote it will cheerfully construct things for subclasses.

    However his very good point is that there appears to be no point in having your readers and writers have the methods in Obj, or vica versa. It is very easy to just say, "inherit", but inheritance used too often loses the point.

    For serious food for thought, look through how LWP works. You will find a lot of classes, but things of different types (eg user agents, requests, responses) don't inherit from each other even though they interact quite a bit. And the design of the whole benefits from that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://41806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-29 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found