>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.
>
http://en.wikipedia.org/wiki/Dependency_injectionI don't see VFP explanations of this.
>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?
If it's not broken, fix it until it is.
My Blog