Question

In my model a user entity has three attributes : ID, name, hasBoyfriend. I want now to change hasBoyfriend to boyFriendsNames which is an array of names . The user entity is used by many services.

The question is: Should I keep the deprecated hasBoyfriend attribute and gradually remove it Or should I remove it completely and force all current services to use the new model, which means more development time ? What is the best practice on these kind of matters ? How is this process called ? Any resource in that matter would be greatly appreciated .

For the picky reader I use a database and code(java, javascript etc) for interacting with the database .

Was it helpful?

Solution

In principe you should have build your code on well encapsulated domain objects. In this case:

  • The only code that would rely on database attributes would be in the persistence layer/data access layer/data source layer (depending on your architectural model).
  • You could change the database attributes as you want and limit the propagation of changes to the rest of the code (everywhere else, the code would just invoke hasPartner() regardless if this just returns a hasBoyFriend attribute or if it checks that boyFriendsNames is not an empty set.
  • The only constraint for removing the hasBoyFreind attribute would be that you have all the related names available. If the code is well encapsulated, you could btw easily use an "Unknown" name added in the set if the names are not yet known, and add a isPartnerUnknown() method, to provide the appropriate bahavior when hasPartner() is true but the name is yet unknown and neesds completion.

If it's too late and the database attribute already pouted all your code, then use FrustatedWithFormDesigner's solution. THe latest bullet can be adapted to his/her solution to give more flexibility.

OTHER TIPS

The "nice" thing to do is to post a news item on your website (or whatever channel you use to communicate to the users of your service) that the hasBoyfriend attribute will eventually be replaced by the boyFriendsNames attribute. Give your users a timeline for when this change will occur so they can modify their code accordingly. There should probably be a period of time where both attributes exist, in case some users haven't finished the transition yet. It's more work, but your users will appreciate it.

Licensed under: CC-BY-SA with attribution
scroll top