The Whole Codebase I inherited [again]
-
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
//Snip ... Some properties methods ctors
}Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it
Dean
but there it is. Here comes the complete listing for a subclass ofFacultyDean
:public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing. Oh and we have tens of classes like this all over:
public class DeanCollection : List
{
}Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
//Snip ... Some properties methods ctors
}Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it
Dean
but there it is. Here comes the complete listing for a subclass ofFacultyDean
:public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing. Oh and we have tens of classes like this all over:
public class DeanCollection : List
{
}Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Keith Barrow wrote:
public class DeanCollection : List<FacultyDean> { }
This could make sense if you are using reflection. Which I guess you are not.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
Keith Barrow wrote:
public class DeanCollection : List<FacultyDean> { }
This could make sense if you are using reflection. Which I guess you are not.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
I doubt the "expert" that wrote this code was capable of self-reflection never mind the kind you mean :laugh: I also discovered today that we are passing down UI element objects into what I laughingly call our database layer just so we don't have to pass down paging information. At least this has a nice degree of symmetry about it: the UI has plenty of data access in it X|
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
//Snip ... Some properties methods ctors
}Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it
Dean
but there it is. Here comes the complete listing for a subclass ofFacultyDean
:public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing. Oh and we have tens of classes like this all over:
public class DeanCollection : List
{
}Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Is this a WPF app by any chance, and are there DataTemplates involved? This type of trick is a common hack to get around the apparent inability to apply a DataTemplate to a generic item (there are other ways, but this is the lazy-hack way to do it).
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Is this a WPF app by any chance, and are there DataTemplates involved? This type of trick is a common hack to get around the apparent inability to apply a DataTemplate to a generic item (there are other ways, but this is the lazy-hack way to do it).
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Just a basic ASP.NET effort!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
//Snip ... Some properties methods ctors
}Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it
Dean
but there it is. Here comes the complete listing for a subclass ofFacultyDean
:public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing. Oh and we have tens of classes like this all over:
public class DeanCollection : List
{
}Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Maybe they did that instead of this:
using DeanCollection = List<FacultyDean>;
It makes a certain sort of sense. You can then later change what DeanCollection is (e.g., to SortedList) without changing code that makes use of that type. Also makes adding functionality easier. Not that I think that's what they were doing.
Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.
-
It starts off, OK (if you ignore the Data Access stuff inside the "Object Model", so it doesn't start OK, but OK is relative in our codebase):
public class FacultyDean
{
//Snip ... Some properties methods ctors
}Nothing too contenious, unless you want to argue about the use of the word Faculty: all faculties have one dean, and all deans belong to 1..* Faculties so it is not necessary. I'd have called it
Dean
but there it is. Here comes the complete listing for a subclass ofFacultyDean
:public class NullFacultyDean : FacultyDean
{
public NullFacultyDean()
{
ID = -1;
}
}A whole subclass for an uninitialised dean, what luxury! There is no flag to say that the Dean is null, so I'm not 100% sure what this is doing. Oh and we have tens of classes like this all over:
public class DeanCollection : List
{
}Again this is the full class, and 99% of them are uneccessary (Hurray! I Can't just remove theem en-masse, I have to check each!). Notice this time we have a DeanCollection rather than FacultyDeanCollection. Nice, consistent naming!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Keith Barrow wrote:
public class DeanCollection : List<FacultyDean> { }
That's actually not a really strange one. In certain languages you had to define your own lists if you wanted to have them typesafe. Eg; you did have a list of objects, but if you wanted a list of person you had to create your own class. Lots of those programmers who did that in the past took that way of working over in .NET. Ofcourse with Generic this makes no sense, but those people tend to argue that using the "DeanCollection" abstracts away the "FacultyDean", so that you can always replace it with a different class. I do wonder why you would want that though...
Keith Barrow wrote:
public class NullFacultyDean : FacultyDean { public NullFacultyDean() { ID = -1; } }
I have done that in the past also, only then the other way around :). I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common:
public FacultyDean Empty
{
get {
return new FacultyDean() { ID = -1 };
}
}Ofcourse this code example also doesn't work out of the box, unless you compare the ID's. A normal equal won't work :P It's always something with code you inherit ;) I for once got the comments the code was to hard; It had to much inheritance. I could also just have copied the code in all the classes. Much easier to understand! ;x
-
Keith Barrow wrote:
public class DeanCollection : List<FacultyDean> { }
That's actually not a really strange one. In certain languages you had to define your own lists if you wanted to have them typesafe. Eg; you did have a list of objects, but if you wanted a list of person you had to create your own class. Lots of those programmers who did that in the past took that way of working over in .NET. Ofcourse with Generic this makes no sense, but those people tend to argue that using the "DeanCollection" abstracts away the "FacultyDean", so that you can always replace it with a different class. I do wonder why you would want that though...
Keith Barrow wrote:
public class NullFacultyDean : FacultyDean { public NullFacultyDean() { ID = -1; } }
I have done that in the past also, only then the other way around :). I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common:
public FacultyDean Empty
{
get {
return new FacultyDean() { ID = -1 };
}
}Ofcourse this code example also doesn't work out of the box, unless you compare the ID's. A normal equal won't work :P It's always something with code you inherit ;) I for once got the comments the code was to hard; It had to much inheritance. I could also just have copied the code in all the classes. Much easier to understand! ;x
JV9999 wrote:
I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common
Nope, I checked. It really just means an "uninitialised dean". I do like the idea of a Null Deanthough, just the sort of thing you'd expect at the Unseen University [^] :laugh:
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
JV9999 wrote:
I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common
Nope, I checked. It really just means an "uninitialised dean". I do like the idea of a Null Deanthough, just the sort of thing you'd expect at the Unseen University [^] :laugh:
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]I think I didn't wrote it correctly what I wanted to say. I actually meant it might act as a "unsaved"/"new" dean. If you use -1 for unsaved values, having an (static)object which represents could help, but there are far easier solutions for that which are also much more common. Null should ofcourse be eh... null? :) (and not some weird nulldeanobject)
-
Keith Barrow wrote:
public class DeanCollection : List<FacultyDean> { }
This could make sense if you are using reflection. Which I guess you are not.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
You can reflect generic classes, though it takes a bit of effort for those of us brought up on .Net 1.1 who learnt how it works before generics existed. There is a reason to do something similar to this: for UI classes, the VS designer can't get its tiny mind around generic control classes, so if you want to be able to drag-drop controls onto the form, you have to make a non-generic subclass. Thus I have this class in a real system:
/// /// A picker for PlotIcon values. We only need to create this because /// the VS designer can't deal with generics. /// public class PlotIconPicker : PickerBase { }
I haven't come across a reason to do it with things that don't live in the designer, though.
-
JV9999 wrote:
I guess they needed something which represents an empty "FacultyDean" and created it this way instead of a more common
Nope, I checked. It really just means an "uninitialised dean". I do like the idea of a Null Deanthough, just the sort of thing you'd expect at the Unseen University [^] :laugh:
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Then let me congratulate you to your uncommonly complete collection of deans :)
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011 -
I think I didn't wrote it correctly what I wanted to say. I actually meant it might act as a "unsaved"/"new" dean. If you use -1 for unsaved values, having an (static)object which represents could help, but there are far easier solutions for that which are also much more common. Null should ofcourse be eh... null? :) (and not some weird nulldeanobject)
JV9999 wrote:
but there are far easier solutions for that which are also much more common.
Kind of the definition of a coding Horror :)
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]