Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. The Whole Codebase I inherited [again]

The Whole Codebase I inherited [again]

Scheduled Pinned Locked Moved The Weird and The Wonderful
com
12 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Keith Barrow
    wrote on last edited by
    #1

    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 of FacultyDean:

    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[^]

    N P A J 4 Replies Last reply
    0
    • K Keith Barrow

      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 of FacultyDean:

      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[^]

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      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

      K B 2 Replies Last reply
      0
      • N Nagy Vilmos

        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

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #3

        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[^]

        1 Reply Last reply
        0
        • K Keith Barrow

          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 of FacultyDean:

          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[^]

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • P Pete OHanlon

            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

            K Offline
            K Offline
            Keith Barrow
            wrote on last edited by
            #5

            Just a basic ASP.NET effort!

            Sort of a cross between Lawrence of Arabia and Dilbert.[^]
            -Or-
            A Dead ringer for Kate Winslett[^]

            1 Reply Last reply
            0
            • K Keith Barrow

              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 of FacultyDean:

              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[^]

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • K Keith Barrow

                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 of FacultyDean:

                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[^]

                J Offline
                J Offline
                JV9999
                wrote on last edited by
                #7

                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

                K 1 Reply Last reply
                0
                • J JV9999

                  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

                  K Offline
                  K Offline
                  Keith Barrow
                  wrote on last edited by
                  #8

                  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[^]

                  J L 2 Replies Last reply
                  0
                  • K Keith Barrow

                    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[^]

                    J Offline
                    J Offline
                    JV9999
                    wrote on last edited by
                    #9

                    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)

                    K 1 Reply Last reply
                    0
                    • N Nagy Vilmos

                      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

                      B Offline
                      B Offline
                      BobJanova
                      wrote on last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0
                      • K Keith Barrow

                        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[^]

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        • J JV9999

                          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)

                          K Offline
                          K Offline
                          Keith Barrow
                          wrote on last edited by
                          #12

                          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[^]

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups