"composed with"

Generics have been in C# for a long time now, and I have been using them, but I have had trouble explaining them to new developers, or at least how to read the code. That is, until just the other day. Using generic lists is easy to understand,

var customers = List<Customer>();

can be read as customers is a List of type Customer. But we often do something like

class ManageUsersPresenter  : basePresenter<IManageUsersView>
{}

What the hell is that? A ManageUsersPresenter of Type ManageUsersView? That just doesn’t make sense a presenter of type View, and then it came to me. What we are doing is composition. I can replace the “of Type” with “composed with”.

A ManageUsersPresenter composed with ManageUsersView. Now that makes sense. When you see an object that has a generic of another type then most likely we are composing these 2 objects to be used together.

Of course you probably want to make sure that your are composing the 2 objects together but it makes reading the code a little easier