April 14, 2009
Make Roles Explicit: Another Brand New Idea From the Distant PastOne of the more frustrating consequences of having been a programmer for a certain number of years is that you've been around long enough to see the wheel being reinvented several times.
I was watching a video of someone speaking at this year's QCon in London about a "new" design principle: make roles explicit.
What he describes in his talk sounds very much like Interface Segregation. Classes should present multiple small client-specific (and by implication, role-specific) interfaces so that a change to one role it plays with respect to one client doesn't affect clients who depend on other methods relating to other roles. (e.g., the role of an Employee played by a Person with respect to an Organisation, which might use public methods like appraise() or calculateBonus() vs. the role of Parent played by the same Person class with respect to a School, which might use methods like inviteToParentsEvening() or requestPermissionForSchoolTrip() and so on).
Curiously, he describes how he learned this "new" principle from an "old" programmer. That should have been his first clue :-)
Also of interest is the use of generics, which tends to have the reverse effect he's seeking (instead of just having an ICollection, you specify an ICollection of Wotnots, which is less easy to substitute.)
Posted 9 years, 7 months ago on April 14, 2009