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.
OOP mapping customer - server
Moderator: General Moderators
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.
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
)
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?
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?