Chain of inheritance - adding in "features"

One thing I dont see that often in code thats in production, is what I like to call a "Chain of Inheritance" - where classes inherit from one another, to add features to them, but only where those features will only benefit certain items, let me explain:

For one of the features for my resharper plugin, we have at the top of the chain, a "BaseBulbItem" which contains all the gubbins of the system:

From that, a Case Sensitivity bulb item inherits, also an abstract class. A reason for making this into its own abstract class is because I might not need Case Sensitivity for ALL of my coding standards (Not ALL coding standards are about case sensitivity after all):

For this to work, the interface HAS to implement IElement, IModifiersOwner and IDeclaration (Because IDeclaration gives you the DeclaredElement, which you need to refactor, IElement is the actual element, and what isnt listed above is the IModifiersOwner, which gives you the access rights)

From there, we can create a concrete class like the following:

Which gives us :

PropertyDeclarationCaseSensitiveBulbItem : CaseSensitiveBaseBulbItem : BaseBulbItem 

Which will finally give us the ability to work on Property Declarations, with very minimal code (infact I only wrote the class name, and the inheritance, VS.NET did the rest (except the text string). Its alot smoother and easier to create multiple bulb items now based around the same idea, which I had done for Method declarations etc...

Leave a comment

Please be polite and on topic. Your e-mail will never be published.

Please add 7 and 8 and type the answer here: