Stairway Pattern

How do you feel when you invite your friend for a private family function and he brings along a dozen strangers (his friends) ?


Entourage Anti-Pattern

This is similar to the scenario when you want to add a library as reference and in turn ends up referring a different set of libraries which you are not directly dependent. This scenario is perfectly defined by the Entourage Anti-Pattern. The Entourage pattern also describes the (avoidable) practice of packaging the abstraction and implementation in the same assembly.

The Stairway Pattern

The stairway pattern describes a better alternative by organizing your abstractions and implementations in separate assemblies, which in turn allows both to evolve and vary independently.

It also means the references now doesn’t bring an entire entourage of assemblies along. One of the thumb rules you can adhere too is to ensure the abstraction assembly doesn’t depend on any external references.

CLSCompliant Attribute

While developing a library in .Net which could be used by another programming language than it was originally designed in, it is important to remember that the .Net Languages offers a subset of CLR/CTS while offering a superset of CLS. And, if you want to develop a library that could be used by any programming language supported by .Net, you have additional responsibility to ensure that your code doesn’t take of care of any features outside the CLS.

Thankfully, .Net provides us an easier way to check the same using the CLSCompliant Attribute.

[assembly: CLSCompliant(true)]
namespace ConsoleApp3
    public class TestClass
        public int Method1() => 1;
        public int method1() => 2;
        private int mEthod1() => 3;

The above code would raise warning “Warning CS3005 Identifier ‘TestClass.method1()’ differing only in case is not CLS-compliant” to help us identify the non-compliance. Do note that mEthod1 doesn’t raise a warning as it is a private method and is not exposed outside the assembly.