Using the speicifcation pattern as a validation layer?
I have only seen the specification pattern used to retrieve data, but not to validate it. A colleague suggested I can use the specification pattern to “validate” an object so it does not become invalid when saving changes.
As an example, say we have a root Customer object that has a value for Address. We can track 开发者_JAVA百科the changes to the object and create a specification that can be sent to the unit of work to make sure the address is valid (Has a physical address, city, and state) before changes are saved.
Any thoughts about this?
Following is a good read regarding differences between a specification and a validaton http://lostechies.com/jimmybogard/2007/10/25/specifications-versus-validators/
精彩评论