Exforsys
+ Reply to Thread
Results 1 to 3 of 3

patterns that apply when software treatments depends on data kind

This is a discussion on patterns that apply when software treatments depends on data kind within the Software Patterns forums, part of the Testing category; Hello, I'm facing a traditional problem on how to model objects when the treatments depends on data kind. For instance ...

  1. #1
    Olivier STEINBERG Guest

    patterns that apply when software treatments depends on data kind

    Hello, I'm facing a traditional problem on how to model objects when
    the treatments depends on data kind.

    For instance we have customers and price lists. The pricing strategy
    is an algorythm specific to each custormer or group of customers.

    My question is, is there a specific pattern that answer that kind of
    problem ?
    How to attach some method to a specific instance of a class ?

    Any idea or clue would be appreciated.

    Thank's


    Olivier



  2. #2
    Joshua Frank Guest

    Re: patterns that apply when software treatments depends on datakind

    If you mean how do you model this in software, I think the standard
    answer would be to use inheritance. In pseudo VB code:

    Class Customer
    Function GetPrice() As Integer
    'do calculation
    End Function
    End Class

    Class ThisCustomer
    Inherits Customer

    Overrides Function GetPrice() As Integer
    'do calculation specific to this customer
    End Function
    End Class

    On the other hand, if there are lots of customers, this gets unwieldy,
    and you would probably need to make it table driven and keep it in the
    Customer class.

    Olivier STEINBERG wrote:

    > Hello, I'm facing a traditional problem on how to model objects when
    > the treatments depends on data kind.
    >
    > For instance we have customers and price lists. The pricing strategy
    > is an algorythm specific to each custormer or group of customers.
    >
    > My question is, is there a specific pattern that answer that kind of
    > problem ?
    > How to attach some method to a specific instance of a class ?
    >
    > Any idea or clue would be appreciated.
    >
    > Thank's
    >
    >
    > Olivier




  3. #3
    Doug Pardee Guest

    Re: patterns that apply when software treatments depends on data kind

    olivier@stelog.com (Olivier STEINBERG) wrote:
    > Hello, I'm facing a traditional problem on how to model objects when
    > the treatments depends on data kind.
    >
    > For instance we have customers and price lists. The pricing strategy
    > is an algorythm specific to each custormer or group of customers.
    >
    > My question is, is there a specific pattern that answer that kind of
    > problem ?


    You already answered your own question, but didn't notice it:

    > The pricing strategy is an algorythm specific to each custormer

    ========

    The Strategy pattern handles this.



    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...