User Tools

Site Tools


why_must_roles_be_stateless

Why must roles be stateless?

i.e. why are they allowed to contain only methods, and not their own data properties?

We all know that RoleMethods can invoke (data) methods of self. If RoleMethods don't invoke data class methods then they can stand alone: there is no need to inject them into any object. (Remember that we decided to call this the “data class” rather than the “domain class.”) Turned around, the object must supply the implementation of the data methods expected by the Role. So there is a method symbiosis between the data and the Role: we can view the data class as holding the data for the RoleMethods. That's kind of “DCI 101”.

why_must_roles_be_stateless.txt · Last modified: 2014/01/26 21:11 by jcoplien