I was talking to a friend, and we were discussing generics, interfaces, of that sort, and he showed me a clip of code:
IVehicle vehicle = IoCFactory.GetInstance<IVehicle>();
And through methods such as those, you could be a DRY programmer.
I realized, that I will take no part in that. That's a lot of stress, to have to write a program, and not ever repeat yourself. If I understand correctly, I can have only one string in my entire application. Why?
Well its simple, I like to show by example:
Lets pretend we have 2 pieces of text, that we we want to combine. For instance, a first and a last name.
string fName;
st... ohz noes, I violated DRY. I had almost typed that 2nd string. This is exactly the predicament I don't want to be in.
Being a DRY programmer is a very intense job. While your code is vastly reusable, it's a lot to get keep track of. I can only suppose his code has one module, because of course, in DRY, you can't click Project -> Add New item more then once.
So I created this post to promote DRY Awareness. Also known as DARE, you may have seen the shirts, DRY Abuse Resistance Education.
Classy, Intelligible Code would for the Vehicle example would look like this:
public class Vehicle
{
public Vehicle()
{ }
public static ArrayList GetAllVehicles()
{
...
}
public static ArrayList GetAllTrucks()
{
...
}
public static ArrayList GetAllCars()
{
...
}
public static ArrayList GetCarID1()
{
...
}
public static ArrayList GetCarID3()
{
...
}
....
}
DRY is for the lazy. The hard working use WET. Write Everything Twice.