Hi all,
This is a slightly weird situation but given this codebase (http://github.com/pedrosmmoreira/digibankdemo) and the following notes, could you give me some feedback? Feel free to bring on all the pain Thank you!
āI opted to go with as minimal a implementation of a double entry book keeping system. Since we were only concerned with Transfers at a UI level, I used a form object to keep a layer of indirection between the stored data and the interface. My intent with that is to put in place an object that, given a set of data, will be able to generate the necessary objects to execute a transaction. Again, using a template/strategy pattern to specialise and properly encapsulate an operation. The ground work for this is already in place in the form of the DepositTeller object: given an symbol representing the operation, it is can initialize the proper object, in this case only a deposit. That is the reason for that object not presenting a cohesive api - the public API is the ādepositā method, which just calls to the generalised builder method, guarded by the allowed operations constant. I would also prefer to scope the call to constantize in a module (i.e. āOperations::#{request_operation.to_s.classifyā.constantize) thus ensuring that only objects in that module can get instantiated (a lot of surprises could occur if we had a :queue operation for instance ).
Finally, the industry standard in banking is moving this logic to stored procedures on the db and Iād like to play with that, but realistically, regarding persistence of data, Iām keen to stop depending on ActiveRecord callbacks to update account balance. Given the importance, Iād like to have that logic live on an object I can call .new on and have full API control over.ā