Inheritence Hierarchy

Dzmitry Huba wrote the following here about Inheritence:

If two or more classes share only common data (no common behavior), then that common data should be placed in a class that will be contained by each sharing class.

If two or more classes have common data and behavior (i.e., methods), then those classes should each inherit from a common base class that captures those data and methods.

If two or more classes share only a common interface (i.e., messages, not methods), then they should inherit from a common base class only if they will be used polymorphically.

… Just something I want to ponder at some point soon.


Repository Pattern

Updated 2009-12-30 – Adjusted  the title to be a general post about the Repository pattern, added links to other posts, forum entries and information, slightly re-organized.

I’ve been looking at the general problem of developing an API and the issues that result, and this is in the context of the repository pattern particularly. Though I don’t think the issues are any different when not using the repository pattern. You still need to be able to load the data you need and avoid issues like: If I Eager load I’ll have way to much data, if I load it when i need it I’ll be opening connections all over the place. With the repository pattern you break the practice of separation of concerns if you inject a reference to any required repositories or services etc. If you actually just provide somewhere on an entity to put it’s sub-entity or a collection and only load it when you need it… well that just doesn’t feel right at all…

Definition of the Repository Pattern

The lazy Loading Approach

The Non Lazy Loading Approach

Use the Repository Pattern

Don’t Use the Repository Pattern

Examples and others

Design Pattern Resources

Here are some links to Design Patterns that I’ve gathered together. This post is more of a research post to gather together indexes and examples of patterns for future study and as a resource.

Indexes of Design Patterns

  • Design Patterns – Wikipedia – Patterns usually have examples in different languages
  • Design Patterns – Data and Object Factory – Has C# Code samples

Dot Net Cube

Small Series on Dot Net Cube about some patterns


Structure Patterns Category

Decorator Pattern

  • A Curious Mind – Simple example of implementing Logging using the Decorator Patter

Should I Blog?

This is interesting. A few minutes into this Scott Hanselman makes the point that “all professional developers should have a blog”. Some of the benefits specified were that it exercises your brain to write better documentation, and it reduces your typing as you can put something in one a blog and you get to more people. All this knowledge is in our head, and if we put it in an email, then we simply waste it (and probable then write it again later!)

Suggested listening material!