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. Would you laugh or cry?

Would you laugh or cry?

Scheduled Pinned Locked Moved The Weird and The Wonderful
rubyquestion
13 Posts 8 Posters 2 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.
  • A AspDotNetDev

    Lol, awesome. Though I can imagine at least a few reasons why this would sort of make sense.

    • If somebody moved all the string handling functions to a single class so they don't have to remember the location of all of them, that would make some sense. Not much, but some.
    • If somebody was working with a tool that requires a function be exposed by a custom class in order to make use of it. For example, I work with an open source tool called Umbraco, and it makes heavy use of XSLT. In order to use a built-in .Net Framework function from XSLT, I have to create a wrapper function and change some configuration settings to let the XSLT know which DLL to use.
    • IsNullOrEmpty was new to .Net Framework 2.0. If they were using a version of .Net before 2.0, they may have created their own implementation, then replaced it with the .Net version.

    [Forum Guidelines]

    V Offline
    V Offline
    vnmatt
    wrote on last edited by
    #3

    Option #1: If I were the boss and this was the case, the guy who did this would be gone (if I could find out who it was, that is) :-D Option #2: Pretty sure that's not the case here; it is actually a class inside a framework used for building other apps. Option #3: Perhaps yes. I suppose this could explain it. Although as far as I am aware, I believe it was originally written in .NET 2 already. Maybe the guy came from using .NET 1 and didn't realise this was there in 2.0. :-s LOL.

    R 1 Reply Last reply
    0
    • V vnmatt

      Not so long ago, I came across this:

      public class StringUtils
      {
      public bool IsNullOrEmpty(string s)
      {
      return string.IsNullOrEmpty(s);
      }
      }

      What a gem, hey? I don't know whether to laugh or cry...

      _ Offline
      _ Offline
      _Erik_
      wrote on last edited by
      #4

      The simple idea of making this kind of stuff is simply horrid, but the fact that this horrid method is not static is still more horrifying.

      V 1 Reply Last reply
      0
      • _ _Erik_

        The simple idea of making this kind of stuff is simply horrid, but the fact that this horrid method is not static is still more horrifying.

        V Offline
        V Offline
        vnmatt
        wrote on last edited by
        #5

        LOL. Actually, my bad; I was quickly writing it up out of memory - I do believe it was static. I dont think anyone can be that idiotic. If I find someone like that, I'm definitely packing my bags and moving on to other things! :-D

        F Z 2 Replies Last reply
        0
        • V vnmatt

          LOL. Actually, my bad; I was quickly writing it up out of memory - I do believe it was static. I dont think anyone can be that idiotic. If I find someone like that, I'm definitely packing my bags and moving on to other things! :-D

          F Offline
          F Offline
          fjdiewornncalwe
          wrote on last edited by
          #6

          gordon_matt wrote:

          I dont think anyone can be that idiotic.

          Be careful when you say that. Code is like the Darwin Awards... You never know when some moron with a PhD comes up with what they "think" is a great idea...

          I wasn't, now I am, then I won't be anymore.

          1 Reply Last reply
          0
          • V vnmatt

            LOL. Actually, my bad; I was quickly writing it up out of memory - I do believe it was static. I dont think anyone can be that idiotic. If I find someone like that, I'm definitely packing my bags and moving on to other things! :-D

            Z Offline
            Z Offline
            Zdeslav Vojkovic
            wrote on last edited by
            #7

            in that case, could it be that it was written like this:

            public static class StringUtils
            {
            public static bool IsNullOrEmpty(this string s)
            {
            return string.IsNullOrEmpty(s);
            }
            }

            then you can simplify the calling code a bit:

            string a = "11";
            string b = "";
            string c = null;
            Console.Out.WriteLine("a -> {0}, b -> {1}, c -> {2}", a.IsNullOrEmpty(), b.IsNullOrEmpty(), c.IsNullOrEmpty());

            instead of

            Console.Out.WriteLine("a -> {0}, b -> {1}, c -> {2}", string.IsNullOrEmpty(a), string.IsNullOrEmpty(b), string.IsNullOrEmpty(c));

            I wouldn't argue if this is a bad practice or not, but it makes some sense at least (ignoring the issue of calling a seemingly instance method on null reference)

            V 1 Reply Last reply
            0
            • Z Zdeslav Vojkovic

              in that case, could it be that it was written like this:

              public static class StringUtils
              {
              public static bool IsNullOrEmpty(this string s)
              {
              return string.IsNullOrEmpty(s);
              }
              }

              then you can simplify the calling code a bit:

              string a = "11";
              string b = "";
              string c = null;
              Console.Out.WriteLine("a -> {0}, b -> {1}, c -> {2}", a.IsNullOrEmpty(), b.IsNullOrEmpty(), c.IsNullOrEmpty());

              instead of

              Console.Out.WriteLine("a -> {0}, b -> {1}, c -> {2}", string.IsNullOrEmpty(a), string.IsNullOrEmpty(b), string.IsNullOrEmpty(c));

              I wouldn't argue if this is a bad practice or not, but it makes some sense at least (ignoring the issue of calling a seemingly instance method on null reference)

              V Offline
              V Offline
              vnmatt
              wrote on last edited by
              #8

              No; it was definitely NOT an extension method. Even that would make some sense, but this was just completely pointless...

              1 Reply Last reply
              0
              • V vnmatt

                Not so long ago, I came across this:

                public class StringUtils
                {
                public bool IsNullOrEmpty(string s)
                {
                return string.IsNullOrEmpty(s);
                }
                }

                What a gem, hey? I don't know whether to laugh or cry...

                V Offline
                V Offline
                vnmatt
                wrote on last edited by
                #9

                As it turns out, the company was using this framework for building apps for a particular customer, but that wasn't good enough, they wanted to sell the framework as well, so basically the devs were told to beef up the package a bit... *speechless* This certainly explains a few oddities in this "Framework"... Moral of the story: if you're going to outsource, get a dev to review the code before paying for anything. LOL & shaking head at same time...

                B 1 Reply Last reply
                0
                • V vnmatt

                  As it turns out, the company was using this framework for building apps for a particular customer, but that wasn't good enough, they wanted to sell the framework as well, so basically the devs were told to beef up the package a bit... *speechless* This certainly explains a few oddities in this "Framework"... Moral of the story: if you're going to outsource, get a dev to review the code before paying for anything. LOL & shaking head at same time...

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

                  Well, that does explain it. Design by upper management strikes again! ;) :laugh:

                  Just because the code works, it doesn't mean that it is good code.

                  1 Reply Last reply
                  0
                  • V vnmatt

                    Option #1: If I were the boss and this was the case, the guy who did this would be gone (if I could find out who it was, that is) :-D Option #2: Pretty sure that's not the case here; it is actually a class inside a framework used for building other apps. Option #3: Perhaps yes. I suppose this could explain it. Although as far as I am aware, I believe it was originally written in .NET 2 already. Maybe the guy came from using .NET 1 and didn't realise this was there in 2.0. :-s LOL.

                    R Offline
                    R Offline
                    RobCroll
                    wrote on last edited by
                    #11

                    Option 1: If you can't find out who did it, the code is the least of your problems. Has your boss ever heard of source control :omg:

                    V 1 Reply Last reply
                    0
                    • R RobCroll

                      Option 1: If you can't find out who did it, the code is the least of your problems. Has your boss ever heard of source control :omg:

                      V Offline
                      V Offline
                      vnmatt
                      wrote on last edited by
                      #12

                      LOL. It's a HUGE company and the code is from a different team and from a couple years back... not to mention everyone where I live is named "Nguyen", so I wouldn't have a clue. Hehe :-D

                      1 Reply Last reply
                      0
                      • V vnmatt

                        Not so long ago, I came across this:

                        public class StringUtils
                        {
                        public bool IsNullOrEmpty(string s)
                        {
                        return string.IsNullOrEmpty(s);
                        }
                        }

                        What a gem, hey? I don't know whether to laugh or cry...

                        R Offline
                        R Offline
                        Ravi Sant
                        wrote on last edited by
                        #13

                        LOL it made me laugh enough.

                        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