Reputation: 1
I am designing a class for an employee management system.
Class Employee has following fields:
:Employee
id:int
firstName:String
lastName:String
contract:Contract
Class Contract has following fields:
:Contract
-contractNo:int
-contractDate:Date
-contractType:Type
-rate:Double
-function:Function
-contractCopy:File
When an individual becomes employed within the company, he/she signs a contract with an agreed rate, function etc. From time to time, management revises the contract and changes rate and/or function.
Could somebody advise how to design a class that stores revisions of the contract? The user needs to view the original information and all revisions.
Upvotes: 0
Views: 476
Reputation: 111
You can use Event Sourcing Pattern. It will allow you to track the change history.
In short you create an event for each change and thanks to this you may review it whenever you want.
You can find more information here:
Upvotes: 0
Reputation: 7867
You already have two nice entities to create classes for: Contract
and Employee
, both of which also make nice tables to store data.
I would create a ContactRevision
class, that has fields of the Contract
that can be revised.
For example:
:ContactRevision
-contractType
-rate
-modifiedOn
-modifiedBy
You could then add a property to your Contract
entity called revisions
of type List<ContractRevisions>
, with operations like addRevision
or getAllRevisions
to show the changed values if desired.
Upvotes: 2