Functional Principles - Immutability

 






Temporal coupling occurs when the correct sequence and timing of method calls are crucial for the program's correctness.

Example:  CreateAddress must be called before CreateCustomer and both must be called before SaveCustomer.

Solution: now CreateCustomer cannot be built unless address exists, therefore the incorrect order will not compile.  Also the code is clearer as we immediately understand their dependencies and output.

It is not possible to remove mutability entirely, but it should be minimised.  




Comments

Popular posts from this blog

Microservices and Service-Oriented Architecture

Version control and Continuous Integration/Continuous Deployment (CI/CD)

Delegates