The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Model OO question

Hello, I'm working on some ORM modelling and I came up with a design issue. Example:

Class1
Class2

Both these classes will need to "use" a third Class - Class3. They will not extend it. Class1 and Class2 represent entities on the program.

Class3 will do introspection (reflection) on objects of one of the other classes to get property information.

I'm working on this starting from an interface (the way I want ppl to be able to use this because it's API like).

The three classes could be independent and used like:

$c1 = new Class1();
$c3 = new Class3();

$c3.work($c1);

One other detail: since Class3 does introspection, it doesn't need to know if it's given a Class1 or a Class2. So the same Class3 object could be used:

$c3.work($c2);

But I think it would be better for the user to be abstracted of the Class3 and just use:

$c1 = new Class1();

$c1.work();

So my question is, what would be the relation C1-C3 and C2-C3?

Inheritance? Aggregate?

I dont think any of those actually makes sense in the problem space. Class1 and Class2 are not "natural" subclasses of Class3. Also since they represent "entities", its not very "natural" for the entity to have an "instrospector".

I'm guestimating that the usage as:

$c1 = new Class1();
$c3 = new Class3();

$c3.work($c1);

It seams to make more sense for the C3 to "have" a C1 or C2 that it will introspect.

would make the most sense. Comments?
Secret
Friday, August 10, 2007
 
 
IMO, briefly, C1 and C2 should conform to a same interface, say "Introspectable". Then you make C3 expect an Introspectable object to work wiht.
Berislav Lopac Send private email
Monday, August 13, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz