Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dependency Injection ... What is it?
Message
De
02/02/2009 13:36:16
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Dependency Injection ... What is it?
Divers
Thread ID:
01378811
Message ID:
01378811
Vues:
69
As I've studied OOP a little more recently, I hear of this matter of depency injection. Can someone help explain this to me, from a VFP perspective.

I think my question here may be associated to it... On my form class, I have a method that will calculate the total amount of the invoice, by summing the line item costs based on the parent key.

So, I have a method on the form called CalculateLineItemCost().

Now, I could architect this thing where the method assumes the current parent key from a form property which is (kept updated by the navigation of the form), or I could architect it to where the parent key value has to be passed into the method by the calling method.

pseudo code of each example to follow:

Assume parent key from a form property:
Method CalculateLineItemCost()

 liParentKey=thisform.iParentKey
 select sum(qty*cost) from LineItems where ifkey=liParentKey into array laTotalValue
 return laTotalValue

EndMethod
or, I could require the parent key value to be passed in, like this:
Method CalculateLineItemCost()
lparameters tiParentKey

 select sum(qty*cost) from LineItems where ifkey=tiParentKey into array laTotalValue
 return laTotalValue

EndMethod
So, which way is considered the best practice?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform