Professionalism, Craftsmanship, Discipline

I’m using the terms “class” and “data structure” in an abstract sense here, indicating their purpose rather than the language feature that implements them. Data structures, in C# at least, can be implemented using either classes or structs. “Classes” in the abstract sense are more directly relatable to C# classes.

Tell, don’t ask

Classes carry data and logic together. From the outside looking in classes have no variables i.e. fields are private.

Exposing getters and particularly setters is a big deal, use them sparingly. We want the “how” in a class to be as hidden as possible. We tell a class what do do by calling its functions.

Where getters and setters are exposed I try and make them as abstract as possible. e.g. I might expose a property called “FuelLevel”, rather than gallons. “FuelLevel” works equally well for gallons or litres or even electric charge.

What, not how.

Don’t expose implementation detail. Looking at a class from the outside it should be obvious what is does but how it does it should be kept from prying eyes. This allows the maximum modularity and facilitates polymorphism.

Coding Standards