Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Say I have a class that implements multiple interfaces. I pass the same instance around using a different interface, depending on what the consumer is interested in.

I am trying to remember what this is called. I know there is a fancy name for it - I thought it was "interface partitioning", but I'm not finding any hits. The official name and perhaps a link to a site explaining what it is would be handy.

In case I haven't explained myself well enough, here is a real world example. I have a class, call it ContextManager, that is responsible for providing access to configuration settings, session variables, user information and other utilities. Instead of passing the object around as a ContextManager, I might pass it around as an IConfigurationManager in one spot and as a IUserManager in another. This prevents the client from accessing things they shouldn't care about and allows me to reuse code within the class.

I just want to know what it is called?

share|improve this question
    
You're not thinking of polymorphism are you? –  paul Mar 28 '13 at 19:38
1  
@paul No. I was sure there was a term specifically for splitting a class out into multiple interfaces for the purpose of limiting how other classes could use it. –  Travis Parks Mar 28 '13 at 19:44
    
Are you talking about multiple inheritance? –  markyd13 Mar 28 '13 at 19:52
3  
This sounds like it might be related to the Interface Segregation Principle - maybe this will spark your memory. –  Nate W. Mar 28 '13 at 21:35
2  
It's called "a class that implements multiple interfaces." Not everything on the planet needs a fifty-cent word. –  Blrfl Mar 29 '13 at 14:56
show 3 more comments

1 Answer

up vote 10 down vote accepted

You're describing the facet pattern, which is used to restrict an interface to obtain a smaller interface that provides less authority. Inheriting multiple interfaces is one common way to implement this pattern.

This is related, but not identical, to the Interface Segregation Principle, which is the 'I' in SOLID. That principle states that no client should be forced to depend on methods it does not use. The facet pattern is a way to adapt that principle to a large class. However, there are other more common ways to follow the interface segregation principle, such as creating smaller classes.

share|improve this answer
    
I'm struggling to accept your answer. @shakedown's answer is actually what I was looking for but I am not seeing a distinction. –  Travis Parks Mar 28 '13 at 22:07
    
@TravisParks: I believe the distinction between the Facet Pattern and the ISP is the former has a god interface and the latter doesn't. –  Nate W. Mar 28 '13 at 23:49
    
@shakedown Agreed. I have a hard time believing one of the SOLID principles would involve God classes. –  Travis Parks Mar 29 '13 at 0:28
1  
@Travis, since Shakedown apparently declined to create his own answer, I have incorporated his comment into mine. –  Karl Bielefeldt Mar 29 '13 at 14:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.