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. Useless...

Useless...

Scheduled Pinned Locked Moved The Weird and The Wonderful
javaruby
17 Posts 12 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.
  • B BadKarma

    This is to catch the possibility of that the function failed to return. The code in the catch should then be

    protected void Foo()
    {
      //...
      PreProcess(arg);
      //...
    }
    
    
    private void PreProcess(string arg)
    {
      try
      {
        return;
      }
      catch(Exception ex)
      {
        // failed to return, run (fake restart) the program again
        main();
      }
    }
    

    codito ergo sum

    D Offline
    D Offline
    Dave Sexton
    wrote on last edited by
    #7

    The function will ALWAYS return. The try{ return; } are the first 3 lines in the method & where the PreProcess() is called is already wrapped in a try..catch block.

    But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
    Because programming is an art, not a science. Marc Clifton

    1 Reply Last reply
    0
    • D Dave Sexton

      Recently came across this gem. protected void Foo() { //... PreProcess(arg); //... } private void PreProcess(string arg) { try { return; } catch(Exception ex) { //.... } } :doh:

      But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
      Because programming is an art, not a science. Marc Clifton

      S Offline
      S Offline
      StM0n
      wrote on last edited by
      #8

      like it... try to return... if you fail, catch the exception and return... if you can... ;)

      (yes|no|maybe)*

      1 Reply Last reply
      0
      • D Dave Sexton

        Recently came across this gem. protected void Foo() { //... PreProcess(arg); //... } private void PreProcess(string arg) { try { return; } catch(Exception ex) { //.... } } :doh:

        But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
        Because programming is an art, not a science. Marc Clifton

        M Offline
        M Offline
        MarkB777
        wrote on last edited by
        #9

        I cannot begin to imagine how the person who wrote this code thinks...

        Mark Brock Click here to view my blog

        P 1 Reply Last reply
        0
        • S Spunky Coder

          probably the coder wants the program to do nothing..:)

          .....

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #10

          Spunky Coder wrote:

          probably the coder wants the program to do nothing..

          Just because it does nothing doesn't mean nothing can go wrong! ;)

          Steve

          1 Reply Last reply
          0
          • M MarkB777

            I cannot begin to imagine how the person who wrote this code thinks...

            Mark Brock Click here to view my blog

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

            MarkBrock wrote:

            I cannot begin to imagine how the person who wrote this code thinks...

            A couple of judicious edits and, voila: "I cannot imagine the person who wrote this code thinks."

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            1 Reply Last reply
            0
            • D Dave Sexton

              Recently came across this gem. protected void Foo() { //... PreProcess(arg); //... } private void PreProcess(string arg) { try { return; } catch(Exception ex) { //.... } } :doh:

              But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
              Because programming is an art, not a science. Marc Clifton

              S Offline
              S Offline
              Saurabh Garg
              wrote on last edited by
              #12

              Don't be so hard on the programmer. There might be couple of reasons for this. May be code skeleton was written to be filled later. Maybe there was function body was well but over time it was removed but function itself was not removed. -Saurabh

              D 1 Reply Last reply
              0
              • S Saurabh Garg

                Don't be so hard on the programmer. There might be couple of reasons for this. May be code skeleton was written to be filled later. Maybe there was function body was well but over time it was removed but function itself was not removed. -Saurabh

                D Offline
                D Offline
                Dave Sexton
                wrote on last edited by
                #13

                Saurabh.Garg wrote:

                it was removed but function itself was not removed

                Don't you think that's a little dangerous? At best it's careless & sloppy. I don't want careless, sloppy devs on my team - do you?

                But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                Because programming is an art, not a science. Marc Clifton

                S 1 Reply Last reply
                0
                • D Dave Sexton

                  Saurabh.Garg wrote:

                  it was removed but function itself was not removed

                  Don't you think that's a little dangerous? At best it's careless & sloppy. I don't want careless, sloppy devs on my team - do you?

                  But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                  Because programming is an art, not a science. Marc Clifton

                  S Offline
                  S Offline
                  Saurabh Garg
                  wrote on last edited by
                  #14

                  I agree that it shows carelessness but how is it dangerous? Actually since I knew nothing about code base and its history I was giving benefit of doubt to the developer. -Saurabh

                  D 1 Reply Last reply
                  0
                  • S Saurabh Garg

                    I agree that it shows carelessness but how is it dangerous? Actually since I knew nothing about code base and its history I was giving benefit of doubt to the developer. -Saurabh

                    D Offline
                    D Offline
                    Dave Sexton
                    wrote on last edited by
                    #15

                    Saurabh.Garg wrote:

                    since I knew nothing about code base

                    Granted. Suffice it to say that this code forms part of a banking simulator. Dangerous in that it sets a precedent. This kind of sloppy code shouldn't be checked back into source control. Seriously, if the dev who wrote this was too lazy to clean this up there's a real danger that he'll take shortcuts in other places too. This in itself is already bad & poses a danger to our product as a whole. So yeah... In my book that's dangerous :)

                    But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                    Because programming is an art, not a science. Marc Clifton

                    1 Reply Last reply
                    0
                    • D Dave Sexton

                      Recently came across this gem. protected void Foo() { //... PreProcess(arg); //... } private void PreProcess(string arg) { try { return; } catch(Exception ex) { //.... } } :doh:

                      But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                      Because programming is an art, not a science. Marc Clifton

                      S Offline
                      S Offline
                      Spacix One
                      wrote on last edited by
                      #16

                      least there isn't a performance hit. It could have been throwing exceptions :-D

                      protected void Foo()
                      {
                      //...
                      PreProcess(arg);
                      //...
                      }

                      private void PreProcess(string arg)
                      {
                      try
                      {
                      throw new Exception("Still being worked on..");
                      }
                      catch(Exception ex)
                      {
                      //....
                      }
                      return;
                      }


                      -Spacix All your skynet questions[^] belong to solved

                      Y 1 Reply Last reply
                      0
                      • S Spacix One

                        least there isn't a performance hit. It could have been throwing exceptions :-D

                        protected void Foo()
                        {
                        //...
                        PreProcess(arg);
                        //...
                        }

                        private void PreProcess(string arg)
                        {
                        try
                        {
                        throw new Exception("Still being worked on..");
                        }
                        catch(Exception ex)
                        {
                        //....
                        }
                        return;
                        }


                        -Spacix All your skynet questions[^] belong to solved

                        Y Offline
                        Y Offline
                        Yasser Azeem
                        wrote on last edited by
                        #17

                        :-O

                        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