0

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?

PDuarte
  • 111
  • 5
  • Place the changes in a Queue then at the end of day move the Queue to production. – TheBetaProgrammer Jul 14 '14 at 18:24
  • Your implication that Sales tends to "mess up with production" seems ... way too accurate. – ajb Jul 14 '14 at 18:32
  • Thanks for the suggestion TheBetaProgrammer. I think your idea works but I also see some limitations and risks. Using a queue I cannot retrieve data from the updates so easily, for example if Sales need to consult their changes. The risk appears when the queue is flushed to the database. This operation can lead to many problems of data inconsistency. – PDuarte Jul 15 '14 at 10:13

1 Answers1

0

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.

Jonathan
  • 81
  • 4
  • That's a great suggestion. I think working with post dates and expire dates is the way to go. The code remains clear and I don't have to deal with post updates, which can easily lead to inconsistent data. Thanks, Jonathan. – PDuarte Jul 15 '14 at 10:05