0

Application A has an api setAge(String staffName). Application B and C both call this api. If a staff Jack has different names in A, B, C: JackA, JackB, JackC, so how to design application A to map JackB=>JackA and JackC=>JackA?

Cœur
  • 32,421
  • 21
  • 173
  • 232
Charlot
  • 151
  • 1
  • 8

1 Answers1

1

You need to model identity in some way. If your business objects (e.g. staff members) are persisted in a relational db you can use the table's primary key, but this is a rather bad practice, as technical keys should not be relied upon on the application level. Instead use a unique business-id for your entities. That can be a String or a UUID for example. When accessing the entities in your API, clients have to pass that business-id as a parameter.

If you are in an OO language like Java, you might have to consider implementing object equality through equals and hashCode contracts (see here).

Community
  • 1
  • 1
nansen
  • 2,846
  • 1
  • 17
  • 32