0

I'm trying to figure out what to do here. I have customer data in two different 3rd party apps that I need to organize into some reasonable data structure before making changes. I currently have two sub-classes of customer, one for each 3rd party app.

Public MustInherit Class Customer
     Public ID as String
     Public Name as String
     Public.... more shared members here
End Class

Public Class Application1Customer
     Inherits Customer

     Public Application1SpecificData....
End Class

Public Class Application2Customer
     Inherits Customer

     Public Application2SpeceficData.....
End Class

I need to map all instances of Customer1 to their respective Customer2s. I have an algorithm that has the logic to given an instance of Customer1 and a list of Customer2s find the appropriate match.

Here's where I'm looking for design ideas... Customers aren't the only data being matched between the two applications. I've also got two Item classes, two Payment classes, two Invoice classes, etc. Each of these classes has its own algorithm to match instances...I'd like to maximize the amount of reusable code.

Questions:

  • What is a good design pattern for matching portion?

  • What data structure do I store a matched object pair in?

My current thought:

  • These subclasses implement some kind of Matchable Interface. This interface contains a method that looks like:

    Public Function matchToApp(Collection Matchable) As Matchable

  • A new object type with two properties, one for each app's matchable...

I'm sure there's some more creative ways to do this out there. Any suggestions?

Thanks

Jonathan
  • 3,464
  • 9
  • 46
  • 54

1 Answers1

0

you don't need to invent you custom interfaces for it. To compare 2 instances you can implement system IComparable (Of T ) interface but i think in your case since you going to map instances probably in HashTable or Dictionaly containers you need overrride GetHashCode() and Equals() methods. Please look there

Community
  • 1
  • 1
Arseny
  • 7,251
  • 4
  • 37
  • 52