Page 1 of 1

OOP mapping customer - server

Posted: Wed Aug 23, 2006 9:29 am
by jmut
Let us say customer bought server(it could be anything really.)

How do you make this connection in OOP manner.

In DB you will probably have server_table with customer_id for each server record to represent to whome this server belongs.

Now taking OOP approache we will try to achive max decoupling...meaning Customer is a customer...server is a server (entities on their own)

How do you translete this in objects so you can easily answer these questions:
- get all servers for customer_id "N"
- get the customer who owns server "Server_Name"
- and other search capapbilities.


And mind that one customer has a lot of stuff associated with it.... there are servers, settings, other stuff. So just having a reference in the customer object to server_objects and vice verse could get very hard to maintain. Or is this normal coupling.

Posted: Wed Aug 23, 2006 9:35 am
by feyd
Sounds like standard normalization to me.

viewtopic.php?t=54174

Posted: Wed Aug 23, 2006 9:42 am
by jmut
feyd wrote:Sounds like standard normalization to me.

viewtopic.php?t=54174
speaking DB
I don't see how much normalized it could get

server_table
server_id server_name customer_id


customer_table
customer_id customer_name


I speak for objects though...
If you mean that mapping when it comes to OOP is the same and follows same rulz as DB relations and normalization, this is another question.

Posted: Thu Aug 24, 2006 9:49 am
by GM
I'm not the world expert on OOP, but I'd do something like this - (and I'd also appreciate feedback from the guys here on this - I'm learning too :lol: )

I'd have an "Owner" class, and an "Ownable" class, and each "Owner" can own one or more Ownables, to be stored in an array within the Owner class

Probably, you could have your customer class extend the Owner class, and the Server class extend the Ownable class.

Am I on the right sort of track here?