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. Happy new year... kind of...

Happy new year... kind of...

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasequestion
11 Posts 9 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.
  • H hoernchenmeister

    After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

    public const string SELECT = "SELECT";
    public const string DISTINCT = "DISTINCT";
    public const string FROM = "FROM";
    public const string WHERE = "WHERE";
    public const string HAVING = "HAVING";
    public const string AND = "AND";
    public const string OR = "OR";
    public const string IN = "IN";
    public const string ON = "ON";
    public const string AS = "AS";
    public const string GROUP_BY = "GROUP BY";
    public const string ORDER_BY = "ORDER BY";
    public const string DESC = "DESC";
    public const string ASC = "ASC";

    this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

    sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
    {
    SqlConsts.SELECT,
    SqlConsts.DISTINCT,
    SqlConsts.TBL1,
    SqlConsts.OBJECT_NO,
    SqlConsts.OBJECT_ID,
    SqlConsts.COUNTRY,
    SqlConsts.REGION,
    SqlConsts.SUBREGION,
    SqlConsts.TOURAREA,
    SqlConsts.LATITUDE,
    SqlConsts.LONGITUDE,
    SqlConsts.CITY,
    SqlConsts.COUNT_ANY,
    SqlConsts.AS,
    SqlConsts.UNIT_COUNT,
    SqlConsts.FROM,
    SqlConsts.WHERE,
    SqlConsts.YEAR
    });

    ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #2

    :omg: Great Zarquon! Thermite the disk immediately before that corrupts something else. Not even I would do that*. :wtf: There is absolutely nothing good about that and all sorts of bad. The worst thing I can think of now (no coffee yet) is that you can't copy and paste it to SSMS (or similar) to test it. Just below that would be lack of syntax colouring if available. You just ruined my day. Thanks for sharing. * If I did, I'd use an enumeration.

    H 1 Reply Last reply
    0
    • P PIEBALDconsult

      :omg: Great Zarquon! Thermite the disk immediately before that corrupts something else. Not even I would do that*. :wtf: There is absolutely nothing good about that and all sorts of bad. The worst thing I can think of now (no coffee yet) is that you can't copy and paste it to SSMS (or similar) to test it. Just below that would be lack of syntax colouring if available. You just ruined my day. Thanks for sharing. * If I did, I'd use an enumeration.

      H Offline
      H Offline
      hoernchenmeister
      wrote on last edited by
      #3

      I like the "thermiting" idea of you... And this is just a small snippet of the project... it's like a "Coding Horror" blog that came to live... As a grown up man I am not ashamed of my tears :)

      1 Reply Last reply
      0
      • H hoernchenmeister

        After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

        public const string SELECT = "SELECT";
        public const string DISTINCT = "DISTINCT";
        public const string FROM = "FROM";
        public const string WHERE = "WHERE";
        public const string HAVING = "HAVING";
        public const string AND = "AND";
        public const string OR = "OR";
        public const string IN = "IN";
        public const string ON = "ON";
        public const string AS = "AS";
        public const string GROUP_BY = "GROUP BY";
        public const string ORDER_BY = "ORDER BY";
        public const string DESC = "DESC";
        public const string ASC = "ASC";

        this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

        sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
        {
        SqlConsts.SELECT,
        SqlConsts.DISTINCT,
        SqlConsts.TBL1,
        SqlConsts.OBJECT_NO,
        SqlConsts.OBJECT_ID,
        SqlConsts.COUNTRY,
        SqlConsts.REGION,
        SqlConsts.SUBREGION,
        SqlConsts.TOURAREA,
        SqlConsts.LATITUDE,
        SqlConsts.LONGITUDE,
        SqlConsts.CITY,
        SqlConsts.COUNT_ANY,
        SqlConsts.AS,
        SqlConsts.UNIT_COUNT,
        SqlConsts.FROM,
        SqlConsts.WHERE,
        SqlConsts.YEAR
        });

        ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

        M Offline
        M Offline
        Matthys Terblanche
        wrote on last edited by
        #4

        Good heavens. Shoot the purp!

        1 Reply Last reply
        0
        • H hoernchenmeister

          After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

          public const string SELECT = "SELECT";
          public const string DISTINCT = "DISTINCT";
          public const string FROM = "FROM";
          public const string WHERE = "WHERE";
          public const string HAVING = "HAVING";
          public const string AND = "AND";
          public const string OR = "OR";
          public const string IN = "IN";
          public const string ON = "ON";
          public const string AS = "AS";
          public const string GROUP_BY = "GROUP BY";
          public const string ORDER_BY = "ORDER BY";
          public const string DESC = "DESC";
          public const string ASC = "ASC";

          this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

          sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
          {
          SqlConsts.SELECT,
          SqlConsts.DISTINCT,
          SqlConsts.TBL1,
          SqlConsts.OBJECT_NO,
          SqlConsts.OBJECT_ID,
          SqlConsts.COUNTRY,
          SqlConsts.REGION,
          SqlConsts.SUBREGION,
          SqlConsts.TOURAREA,
          SqlConsts.LATITUDE,
          SqlConsts.LONGITUDE,
          SqlConsts.CITY,
          SqlConsts.COUNT_ANY,
          SqlConsts.AS,
          SqlConsts.UNIT_COUNT,
          SqlConsts.FROM,
          SqlConsts.WHERE,
          SqlConsts.YEAR
          });

          ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

          G Offline
          G Offline
          Gary Huck
          wrote on last edited by
          #5

          Oh my god. What did I just read about "my eyes are bleeding"? "some externals from a country far far away" ... indeed. And to think they were all public constants ;)

          1 Reply Last reply
          0
          • H hoernchenmeister

            After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

            public const string SELECT = "SELECT";
            public const string DISTINCT = "DISTINCT";
            public const string FROM = "FROM";
            public const string WHERE = "WHERE";
            public const string HAVING = "HAVING";
            public const string AND = "AND";
            public const string OR = "OR";
            public const string IN = "IN";
            public const string ON = "ON";
            public const string AS = "AS";
            public const string GROUP_BY = "GROUP BY";
            public const string ORDER_BY = "ORDER BY";
            public const string DESC = "DESC";
            public const string ASC = "ASC";

            this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

            sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
            {
            SqlConsts.SELECT,
            SqlConsts.DISTINCT,
            SqlConsts.TBL1,
            SqlConsts.OBJECT_NO,
            SqlConsts.OBJECT_ID,
            SqlConsts.COUNTRY,
            SqlConsts.REGION,
            SqlConsts.SUBREGION,
            SqlConsts.TOURAREA,
            SqlConsts.LATITUDE,
            SqlConsts.LONGITUDE,
            SqlConsts.CITY,
            SqlConsts.COUNT_ANY,
            SqlConsts.AS,
            SqlConsts.UNIT_COUNT,
            SqlConsts.FROM,
            SqlConsts.WHERE,
            SqlConsts.YEAR
            });

            ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #6

            Were they getting paid by the line of code?! :wtf: This is what happens when you remove the "adult supervision" from a bunch of idiots writing code.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            1 Reply Last reply
            0
            • H hoernchenmeister

              After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

              public const string SELECT = "SELECT";
              public const string DISTINCT = "DISTINCT";
              public const string FROM = "FROM";
              public const string WHERE = "WHERE";
              public const string HAVING = "HAVING";
              public const string AND = "AND";
              public const string OR = "OR";
              public const string IN = "IN";
              public const string ON = "ON";
              public const string AS = "AS";
              public const string GROUP_BY = "GROUP BY";
              public const string ORDER_BY = "ORDER BY";
              public const string DESC = "DESC";
              public const string ASC = "ASC";

              this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

              sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
              {
              SqlConsts.SELECT,
              SqlConsts.DISTINCT,
              SqlConsts.TBL1,
              SqlConsts.OBJECT_NO,
              SqlConsts.OBJECT_ID,
              SqlConsts.COUNTRY,
              SqlConsts.REGION,
              SqlConsts.SUBREGION,
              SqlConsts.TOURAREA,
              SqlConsts.LATITUDE,
              SqlConsts.LONGITUDE,
              SqlConsts.CITY,
              SqlConsts.COUNT_ANY,
              SqlConsts.AS,
              SqlConsts.UNIT_COUNT,
              SqlConsts.FROM,
              SqlConsts.WHERE,
              SqlConsts.YEAR
              });

              ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

              J Offline
              J Offline
              Jorgen Andersson
              wrote on last edited by
              #7

              My best guess is misuse of intellisense. Maybe the perpetrator (amongst other) is dyslexic and has invented his own spellchecker.

              People say nothing is impossible, but I do nothing every day.

              1 Reply Last reply
              0
              • H hoernchenmeister

                After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

                public const string SELECT = "SELECT";
                public const string DISTINCT = "DISTINCT";
                public const string FROM = "FROM";
                public const string WHERE = "WHERE";
                public const string HAVING = "HAVING";
                public const string AND = "AND";
                public const string OR = "OR";
                public const string IN = "IN";
                public const string ON = "ON";
                public const string AS = "AS";
                public const string GROUP_BY = "GROUP BY";
                public const string ORDER_BY = "ORDER BY";
                public const string DESC = "DESC";
                public const string ASC = "ASC";

                this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

                sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
                {
                SqlConsts.SELECT,
                SqlConsts.DISTINCT,
                SqlConsts.TBL1,
                SqlConsts.OBJECT_NO,
                SqlConsts.OBJECT_ID,
                SqlConsts.COUNTRY,
                SqlConsts.REGION,
                SqlConsts.SUBREGION,
                SqlConsts.TOURAREA,
                SqlConsts.LATITUDE,
                SqlConsts.LONGITUDE,
                SqlConsts.CITY,
                SqlConsts.COUNT_ANY,
                SqlConsts.AS,
                SqlConsts.UNIT_COUNT,
                SqlConsts.FROM,
                SqlConsts.WHERE,
                SqlConsts.YEAR
                });

                ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

                B Offline
                B Offline
                Brisingr Aerowing
                wrote on last edited by
                #8

                MY EYES! THEY BURN! THE GOGGLES! THEY DO NOTHING!!!

                Bob Dole

                The internet is a great way to get on the net.

                :doh: 2.0.82.7292 SP6a

                1 Reply Last reply
                0
                • H hoernchenmeister

                  After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

                  public const string SELECT = "SELECT";
                  public const string DISTINCT = "DISTINCT";
                  public const string FROM = "FROM";
                  public const string WHERE = "WHERE";
                  public const string HAVING = "HAVING";
                  public const string AND = "AND";
                  public const string OR = "OR";
                  public const string IN = "IN";
                  public const string ON = "ON";
                  public const string AS = "AS";
                  public const string GROUP_BY = "GROUP BY";
                  public const string ORDER_BY = "ORDER BY";
                  public const string DESC = "DESC";
                  public const string ASC = "ASC";

                  this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

                  sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
                  {
                  SqlConsts.SELECT,
                  SqlConsts.DISTINCT,
                  SqlConsts.TBL1,
                  SqlConsts.OBJECT_NO,
                  SqlConsts.OBJECT_ID,
                  SqlConsts.COUNTRY,
                  SqlConsts.REGION,
                  SqlConsts.SUBREGION,
                  SqlConsts.TOURAREA,
                  SqlConsts.LATITUDE,
                  SqlConsts.LONGITUDE,
                  SqlConsts.CITY,
                  SqlConsts.COUNT_ANY,
                  SqlConsts.AS,
                  SqlConsts.UNIT_COUNT,
                  SqlConsts.FROM,
                  SqlConsts.WHERE,
                  SqlConsts.YEAR
                  });

                  ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

                  P Offline
                  P Offline
                  peterchen
                  wrote on last edited by
                  #9

                  Yes, this is the first normal form of the so called "Bakers Binding". It's very robust and flexible,you know! provide excellent abstraction without too much complexity! In the second normal form, you introduce a

                  public const string COLUMNSEPARATORFORSELECTSTATEMENT = ",";


                  To be fair, hunting down select statements when the db scheme changes is painful; you have to exercise every code paht that contains a select. That solution is akin to smashing your toe to forget a flea bite, though.

                  ORDER BY what user wants

                  H 1 Reply Last reply
                  0
                  • P peterchen

                    Yes, this is the first normal form of the so called "Bakers Binding". It's very robust and flexible,you know! provide excellent abstraction without too much complexity! In the second normal form, you introduce a

                    public const string COLUMNSEPARATORFORSELECTSTATEMENT = ",";


                    To be fair, hunting down select statements when the db scheme changes is painful; you have to exercise every code paht that contains a select. That solution is akin to smashing your toe to forget a flea bite, though.

                    ORDER BY what user wants

                    H Offline
                    H Offline
                    hoernchenmeister
                    wrote on last edited by
                    #10

                    ...good one though ;) there actually exists such a seperator iuhasdfhu,gvsd.fgzdfjhb (sorry, I just had to smash my head into the keyboard... it reliefs the pain)

                    1 Reply Last reply
                    0
                    • H hoernchenmeister

                      After my well deserved vacation I returned to work. Beeing happy I received a task to modify a DotNetNuke module, made by some externals from a country far far away. Happyness didn't last long when I came along a SearchEngine class:

                      public const string SELECT = "SELECT";
                      public const string DISTINCT = "DISTINCT";
                      public const string FROM = "FROM";
                      public const string WHERE = "WHERE";
                      public const string HAVING = "HAVING";
                      public const string AND = "AND";
                      public const string OR = "OR";
                      public const string IN = "IN";
                      public const string ON = "ON";
                      public const string AS = "AS";
                      public const string GROUP_BY = "GROUP BY";
                      public const string ORDER_BY = "ORDER BY";
                      public const string DESC = "DESC";
                      public const string ASC = "ASC";

                      this continues for about 1500 lines of code declaring every possible table/column etc I could think of. 90% of the consts aren't even in use... and it all ends up in statements like that:

                      sqlString.AppendFormat("{0} {1} {2}.{3},{2}.{4},{2}.{5},{2}.{6},{2}.{7},{2}.{8},{2}.{9},{2}.{10},{2}.{11},{12} {13} {14} {15} {2} {16} {17} = @{17}",new string[]
                      {
                      SqlConsts.SELECT,
                      SqlConsts.DISTINCT,
                      SqlConsts.TBL1,
                      SqlConsts.OBJECT_NO,
                      SqlConsts.OBJECT_ID,
                      SqlConsts.COUNTRY,
                      SqlConsts.REGION,
                      SqlConsts.SUBREGION,
                      SqlConsts.TOURAREA,
                      SqlConsts.LATITUDE,
                      SqlConsts.LONGITUDE,
                      SqlConsts.CITY,
                      SqlConsts.COUNT_ANY,
                      SqlConsts.AS,
                      SqlConsts.UNIT_COUNT,
                      SqlConsts.FROM,
                      SqlConsts.WHERE,
                      SqlConsts.YEAR
                      });

                      ...am I missing something or is this an acceptable way of solving database related tasks? Can you spot a reason for this? If so, please make my happiness return... somehow... please... Happy new year Andy

                      V Offline
                      V Offline
                      Vladimir Svyatski
                      wrote on last edited by
                      #11

                      An attempt to create new, better LINQ to SQL?

                      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