Exforsys

Online Training

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 ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-26-2004, 07:14 AM
Olivier STEINBERG
Guest
 
Posts: n/a
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-26-2004, 03:38 PM
Joshua Frank
Guest
 
Posts: n/a
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-27-2004, 02:44 PM
Doug Pardee
Guest
 
Posts: n/a
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:46 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.