Advertisement

need opinions on OOP

Started by March 14, 2003 01:37 PM
0 comments, last by angrytofu 21 years, 8 months ago
I have been trying to understand the proper way to do this progra at work. Here is the situation There is a USER who has ZONES and each zone contains CROSSINGS So in my USER class there is a ZONE class. And in the ZONE class there is a CROSSING class. So that is all fine. So if I want to return records of the zones for a user I could say datatable = user.userzones OR should I say datatable = user.zones.select_zones(userid) OR datatable = user.zones(userid) if the 1st and 3rd case I would have to have a property that acutally calls a method in the ZONE class and then to get a record of the crossings of a zone I could say datatable = user.zones.crossing.select_crossings(zoneid) etc.... so befor eI go to far I need to know the best way to go aoubt doing this or it will be a mess. HELP
http://www.mattherb.com now with CATCAM!
Heya

I'm no expert, but at first glance, my initial thought is that you will need an array of zones, and an array of crossings (since you imply more than one of each) I apologize in advance if you wrote it too fast to use arrays

Secondly, I think option 2 or 3 would be better. I'm not sure how you would know which user to get the zones from, without some kind of key value (in this case, the user ID)

And finally, your last line:

datatable = user.zones.crossing.select_crossings(zoneid)

looks a little bit messy. I haven't looked at lot of other people's code, but generally, I like to keep my methods? down to a minimum. Otherwise you end up with something really nasty like animal.mammal.large.elephant.foot.toe I mean, it works, but it's just really... wordy. Maybe it's more of a style issue though; don't listen to me, lol.

Peon

[edited by - Peon on March 14, 2003 12:29:45 AM]
Peon

This topic is closed to new replies.

Advertisement