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. The Lounge
  3. Programming's Foul Language

Programming's Foul Language

Scheduled Pinned Locked Moved The Lounge
tutorialquestion
111 Posts 61 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.
  • V Vikram A Punathambekar

    Valid point, but if your library is very volatile, you can wrap all exceptions that happen in your method into a YourCustomException and throw the wrapper instance.

    Cheers, Vikram. (Proud to have finally cracked a CCC!)

    D Offline
    D Offline
    Dan Neely
    wrote on last edited by
    #100

    throws Exception, throws MyCustomExceptionWhichWrapsEverything, and lack of a throws statement; are equally useless at providing meaningful information to the consumer.

    The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.

    V 1 Reply Last reply
    0
    • P PIEBALDconsult

      Oh, yeah, I forgot about partial when I wrote that, but then I use partial even when I don't need it. I actually feel that classes should be partial by default and that there should be no keyword for it. Trying to compile an actual partial class with C# 1.0 will break even if there is no keyword, so I don't see the need. And I think the word I really wanted was "profligate"; I'm not sure which word works best in the context.

      D Offline
      D Offline
      Dan Neely
      wrote on last edited by
      #101

      Unless you're suggesting replacing it with a new keyword eg singlefile that does the opposite I'm strongly opposed because it means I don't have any mandatory information about if a class is fully contained in a single file or if it's got implementation spread among several. If you are suggesting singlefile instead of partial then I disagree because you're changing the implicit behavior of legacy code. The only change I'd make would be to add a warning if there was *not* a second instance of a partial class eg if you ooopsed and only renamed/renamespaced the class in one of the files instead of all of them.

      The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.

      P 1 Reply Last reply
      0
      • D Dan Neely

        Unless you're suggesting replacing it with a new keyword eg singlefile that does the opposite I'm strongly opposed because it means I don't have any mandatory information about if a class is fully contained in a single file or if it's got implementation spread among several. If you are suggesting singlefile instead of partial then I disagree because you're changing the implicit behavior of legacy code. The only change I'd make would be to add a warning if there was *not* a second instance of a partial class eg if you ooopsed and only renamed/renamespaced the class in one of the files instead of all of them.

        The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.

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

        dan neely wrote:

        a new keyword eg singlefile

        No.

        dan neely wrote:

        if a class is fully contained in a single file or if it's got implementation spread among several

        I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit. The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file. If I leave off partial, they have to add it even though they're using partial in an effort to not alter my file. Partial classes enable such easy additions to code, but the partial keyword hinders that ease. All classes should be partial without needing a new keyword.

        D 1 Reply Last reply
        0
        • P PIEBALDconsult

          dan neely wrote:

          a new keyword eg singlefile

          No.

          dan neely wrote:

          if a class is fully contained in a single file or if it's got implementation spread among several

          I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit. The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file. If I leave off partial, they have to add it even though they're using partial in an effort to not alter my file. Partial classes enable such easy additions to code, but the partial keyword hinders that ease. All classes should be partial without needing a new keyword.

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #103

          PIEBALDconsult wrote:

          I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit.

          I disagree about it's utility; and while I'll admit that's annoying and an obvious place for intellisence improvement, but having to search for partial class MyClass with a partial class to find the rest of it is less of a hassle than having to search for class MyClass with every class to find out if it's partial or not.

          PIEBALDconsult wrote:

          The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file.

          Within my codebase; if anything I see this as a feature since the changelog for my class will indicate that it's no longer contained in a single file. If anything I think the weakness is that adding a 3rd+ partial class file doesn't do anything to obviously indicate that the class has changed in the repositories history. So far it's never been an issue for me since I've only used partial to isolate my code from code autogenerated by a tool/designer of some sort.

          The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.

          1 Reply Last reply
          0
          • O Owen37

            goto can actually be useful (if used extremely sparingly - so sparingly that I haven't used it in over 10 years!) One example where goto is very helpful is in programming an efficient state-machine. Oh, I know you can do it without gotos by using functions and/or block escapes, but the goto is much more efficient -- and, in the case of a state-machine, actually HELPS understanding of what is going on.... FWIW (getting ready for all the thumbs-down).

            E Offline
            E Offline
            Edwin Smith
            wrote on last edited by
            #104

            Since I barely knew Dartmouth Basic when I started designing state machines for hardware controllers i didn't know there was anything like "goto" or "gosub". In all of the microcontrollers I've ever coded all we had were JMP, CALL, and sometimes SKIP for controlling program flow. Goto and Gosub were all higher level code which had to be interpreted or compiled into code the CPU could understand. I've also made state machines with NO ALU at all and one in particular out of PLD's that had NO compiler at all. I had to design the program flow by burning fuses in the PLD. No memory, no eproms, no disks, no keyboard and no display. Also, mine is bigger than yours. :-) Edwin

            O 1 Reply Last reply
            0
            • C Corporal Agarn

              Microsoft

              G Offline
              G Offline
              gstolarov
              wrote on last edited by
              #105

              You really picked the wrong forum for that :-)

              1 Reply Last reply
              0
              • E Edwin Smith

                Since I barely knew Dartmouth Basic when I started designing state machines for hardware controllers i didn't know there was anything like "goto" or "gosub". In all of the microcontrollers I've ever coded all we had were JMP, CALL, and sometimes SKIP for controlling program flow. Goto and Gosub were all higher level code which had to be interpreted or compiled into code the CPU could understand. I've also made state machines with NO ALU at all and one in particular out of PLD's that had NO compiler at all. I had to design the program flow by burning fuses in the PLD. No memory, no eproms, no disks, no keyboard and no display. Also, mine is bigger than yours. :-) Edwin

                O Offline
                O Offline
                Owen37
                wrote on last edited by
                #106

                DROOOOOoooooollllll,,,,,,, ;P

                1 Reply Last reply
                0
                • D Dan Neely

                  throws Exception, throws MyCustomExceptionWhichWrapsEverything, and lack of a throws statement; are equally useless at providing meaningful information to the consumer.

                  The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.

                  V Offline
                  V Offline
                  Vikram A Punathambekar
                  wrote on last edited by
                  #107

                  Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything. You think having a list of exceptions a method can throw is worthless? :~

                  Cheers, Vikram. (Proud to have finally cracked a CCC!)

                  T 1 Reply Last reply
                  0
                  • T TNCaver

                    One defense for the goto I've heard is from people whose programming policies require that functions have a single exit point. Aiming for a single Exit Sub/Function/Return point without goto can easily make for some complex and hard to maintain control paths, often with multiple levels of nested if/then blocks.

                    V Offline
                    V Offline
                    Victor Ortuondo
                    wrote on last edited by
                    #108

                    Unnecessary if you have try/finally constructs in your language.

                    1 Reply Last reply
                    0
                    • V Vikram A Punathambekar

                      Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything. You think having a list of exceptions a method can throw is worthless? :~

                      Cheers, Vikram. (Proud to have finally cracked a CCC!)

                      T Offline
                      T Offline
                      thomas michaud
                      wrote on last edited by
                      #109

                      Vikram A Punathambekar wrote:

                      Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything.

                      Not quite true - there are checked and unchecked exceptions. (NullPointer exception are unchecked...they can always be thrown)

                      V 1 Reply Last reply
                      0
                      • T thomas michaud

                        Vikram A Punathambekar wrote:

                        Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything.

                        Not quite true - there are checked and unchecked exceptions. (NullPointer exception are unchecked...they can always be thrown)

                        V Offline
                        V Offline
                        Vikram A Punathambekar
                        wrote on last edited by
                        #110

                        Yes, I know, but we are talking about checked exceptions.

                        Cheers, Vikram. (Proud to have finally cracked a CCC!)

                        1 Reply Last reply
                        0
                        • D Dalek Dave

                          COBOL!

                          ------------------------------------ "When Belly Full, Chin Hit Chest" Confucius 502BC

                          J Offline
                          J Offline
                          Jane Williams
                          wrote on last edited by
                          #111

                          "alter goto" Variables with two-character names An IT department that makes both of the above mandatory. Yes, I am that old, and the programs I was working on were even older.

                          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