Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Business object and OOP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00832637
Message ID:
00839367
Vues:
21
>Hi,
>Thank you for reply.
>After read the article and some others like decoration, I "think" I should "hide" everything behind the main BO?

Yes, as much as you can. That is the idea of a facade, simplify the interface to a group of complex objects and hide the details.

>
>So, I would like to clarify,
>If I have the BO hierarchy as following
>
>
>BizItem
>  |
>  ---oSerial      && SerialNo. BO
>  |
>  ---oMatrix      && BO of Matrix (colour/size)
>  |
>  ---oMOutlet     && Bo which handle Item info that based on different outlet
>     |
>     ---oMPPU     && BO/Table which handle multi selling price, for each outlet
>
>
>1. If I need to know, what is the prices available for ItemA at OutletB, where should I place the code/method, BizItem.GetPPUByOutlet() ?
>

This is an issue. I would put it on BizItem, but the name of the method itself suggests a specific internal structure. At some point your business objects have to know about each other and there will be coupling.

>2. The method above will return more than one price, and it will be stored as collection in oMPPU.oItem. Should I manipulate the collection directly by Bizitem.oMOutlet(1).oMPPU.Price? Or, BizItem should create a collection which stored the result?
>

I would manipulate it directly. Do not duplicate the data.

>3. Similar question as above, If I wan to add new price for ItemA at Outlet B, should I create a method of AddPriceByOutlet(ItemCode, OutletID) or BizItem.oMOutlet(1).oMPPU.New()?
>

The Law of Demeter does not say you can never drill down into a collection. Just realize that when you do that, you are coding to a specific implementation and your code may break in the future. Just try to make sure your data structure is aligned well with the real world.

Let me ask you this: Are you going to do any databinding to the data stored in these collections? If you are going to just manipulate these collections programatically then it is fine to use collections. However, if you are going to present these collections to the user for editing, I don't think collections will work very well in FoxPro. Is VFP8 able to databind directly to a collection? I don't know. I don't want to lead you down the wrong path. Sometime you have to sacrifice pure object-oriented programming because the tools you are working with do not allow it. You may find out later that you should be using Dataenvironments and cursors instead of collections.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform