Monday, August 20, 2018

ERP: Is there a design pattern for updating data for a department while keeping the old data for a second department during a certain time?

Not so complicated as the title suggests. Imagine two departments in a Company: Sales and Manufacture. While data (in an ERP software) in Sales may represent contracts, Manufacture has to deal with the production established by these contracts (ex: produce 1,000 pens/month). The challenge here is that Sales should be able to update a contract in any business hour but must not mess up with production until the end of the day. In other words, for Manufacture the contract data should appear as the old one, before update. For Sales, the contract must appear as the new updated one. Manufacture should "see" the update only in the next day.

This is a Java ERP application. How to deal with this kind of situation using a best practice or design pattern?

Solved

This sounds like a model-view-controller pattern to me. I think it would be best if you made a class to store the actual data, and it serves that data to the Sales and Manufacture classes.

What you would do then is whenever the Sales class wants to update a contract, it is internally labeled with the business hour it was posted. Then, whenever the Manufacture class wants to get contract information, anything that was posted within that business day is ignored, and not returned.

How you want to do this is pretty much up to you. TheBetaProgrammer's idea works nicely, but is complicated by how you want different visibility for different departments. You might want to make a class that stores the contract and visibility permissions, and when data is requested, check if the requester is allowed to see that version of the contract before returning it.


No comments:

Post a Comment