Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business object and OOP
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00832637
Message ID:
00836978
Views:
22
Study the Law of Demeter: http://www.wikipedia.org/wiki/Law_of_Demeter
"Only talk to your immediate friends".

In my estimation, you should be calling the container object Item.Save(). It should be smart enough to figure out there are no changes to itself so it does not needlessly call the database. Then it just delegates the Save to the child objects. If you are calling Item.oSerialNo.Save() and you change the implementation of the Item object (What if you rename oSerialNo to oSerialNumber?), then your code breaks.

You may have a business reason for calling Item.oSerialNo.Save() directly, but try to avoid it.

Its a very important question. Design your classes with high cohesion and low coupling.

>Hi,
>Thank you for your reply.
>
>In my aplication design, serial no (like mobile phone serial no) only will be created while stock in, but item record will be created at the beginning.
>
>So, do you meant I should call Item.Save() instead of Item.oSerialNo.Save()?
>If I call Item.Save(), it will re-save item info and some related records either. Should I?
>
>Sorry for my innocent question.
>
>Thank you
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform