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.
  • D dmitri_sps

    Kidding ? :omg: Coding without it is like using FORTRAN: do not catch anything, or enclose all code in try/catch, just in case ;P

    E Offline
    E Offline
    ely_bob
    wrote on last edited by
    #83

    You should be able to code it without raising exceptions.. if you can't you should go back to school. :)

    1 Reply Last reply
    0
    • T Todd Smith

      What programming terms would you consider equivalent to foul language? For example: Legacy Code

      Todd Smith

      B Offline
      B Offline
      Bob work
      wrote on last edited by
      #84

      VBA: On Error Resume Next DoEvents

      -Bob

      1 Reply Last reply
      0
      • I Ian Shlasko

        Drop the semi-colon? And be forced _ to resort to VB's _ horrible style of _ line continuations!?!? No thanks. Though the case sensitivity... I wouldn't have to deal with code where people name the private variables the same as the exposed properties, with just case differences... Or better yet, gems like:

        int num = Num + NUM;

        Thankfully, I've never actually seen a line that bad, but imagine a program written like that... There's something you can't do in VB.

        Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

        E Offline
        E Offline
        ely_bob
        wrote on last edited by
        #85

        GOD, I FUC^N HATE THAT and they do it in textbooks, tutorials, samples --- yeah that's right Microsoft I'm talking to you.... I propose anyone caught doing this gets paper cuts on the tips of all of their digits... that will teach them. (try typing now you sick B@$$+@rd$ I slept last night so i feel good today, try me again in 24 hours I won't be so plucky.

        1 Reply Last reply
        0
        • C Corporal Agarn

          Microsoft

          E Offline
          E Offline
          etkid84
          wrote on last edited by
          #86

          to your list

          David

          1 Reply Last reply
          0
          • F Fabio Franco

            I agree with that, despite knowing that at Assembly level, that's exactly what your code will do.

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #87

            Fabio Franco wrote:

            knowing that at Assembly level, that's exactly what your code will do.

            True, I have programmed in both languages and for some reason it seems natural (maybe because there's no choice?) in assembler and completely out of place in C++.

            F 1 Reply Last reply
            0
            • J jeron1

              goto X|

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

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

              J D T E 4 Replies 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).

                J Offline
                J Offline
                jeron1
                wrote on last edited by
                #89

                Owen37 wrote:

                if used extremely sparingly - so sparingly that I haven't used it in over 10 years!)

                I guess I'm not saying that they can NEVER be useful, it's just that whenever I've seen it used abused, it had no business in the code and it's always at least a red flag.

                Owen37 wrote:

                (getting ready for all the thumbs-down).

                Not from me. :)

                O 1 Reply Last reply
                0
                • D Dan Neely

                  .... right up until something changes in the library and it can throw a new exception at which point the library author has to either break every single app that consumes it, cast the new exception into a different type defeating the purpose of typed exceptions in the first place, or just have every method throw exception from the start defeating the purpose of checked exceptions from the start. X|

                  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
                  #90

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

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

                    How is using goto better than a switch statement in a while(true) loop?

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

                    O 1 Reply Last reply
                    0
                    • D Dan Neely

                      How is using goto better than a switch statement in a while(true) loop?

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

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

                      Well, like I said, I haven't used goto in over 10 years. Almost always switch or while or some other construct is better. However, the one time I used it was in a very large state-machine (decoding a satellite signal) where switch just did not work.

                      1 Reply Last reply
                      0
                      • J jeron1

                        Owen37 wrote:

                        if used extremely sparingly - so sparingly that I haven't used it in over 10 years!)

                        I guess I'm not saying that they can NEVER be useful, it's just that whenever I've seen it used abused, it had no business in the code and it's always at least a red flag.

                        Owen37 wrote:

                        (getting ready for all the thumbs-down).

                        Not from me. :)

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

                        jeron1 wrote:

                        I guess I'm not saying that they can NEVER be useful, it's just that whenever I've seen it used abused, it had no business in the code and it's always at least a red flag.

                        Oh yeah! ALWAYS a RED FLAG! Even when I did have to use it (in the large state-machine) I felt dirty and wanted to run home and take a shower every time I looked at it. After numerous code reviews (some by the VP of development), it held up as the most efficient way to handle the data stream. And, it's in the comments/documentation for the code.

                        1 Reply Last reply
                        0
                        • C csharphacker

                          You do realize you can mark up which exceptions are thrown in XML comments? I forget if that junk shows up in the intellisense though...

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

                          Yes, it does.

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

                            T Offline
                            T Offline
                            TNCaver
                            wrote on last edited by
                            #95

                            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 1 Reply Last reply
                            0
                            • B Brady Kelly

                              Prolific maybe, but between them and partial classes, I get quite extended.

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

                              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.

                              B D 2 Replies 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.

                                B Offline
                                B Offline
                                Brady Kelly
                                wrote on last edited by
                                #97

                                I like to know when I'm partial to something.

                                P 1 Reply Last reply
                                0
                                • B Brady Kelly

                                  I like to know when I'm partial to something.

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

                                  I'm not partial to needless keywords and syntax changes.

                                  1 Reply Last reply
                                  0
                                  • J jeron1

                                    Fabio Franco wrote:

                                    knowing that at Assembly level, that's exactly what your code will do.

                                    True, I have programmed in both languages and for some reason it seems natural (maybe because there's no choice?) in assembler and completely out of place in C++.

                                    F Offline
                                    F Offline
                                    Fabio Franco
                                    wrote on last edited by
                                    #99

                                    jeron1 wrote:

                                    it seems natural (maybe because there's no choice?)

                                    Yep, there is no choice. The program counter (PC) points which statement will execute next. The processor looks that up in the memory and if nothing is done, it will simply execute the next item in the stack. So in order to perform conditional tasks (if) or loops (for/while) the processor understands the MOV command which is exactly what the "goto" command does. All your ifs, whiles and fors become nothing when compiled to native machine language. They all become "goto's". Thank God nowadays we are not required to go assembly in most cases, things can get ugly. Cheers Fábio

                                    1 Reply Last reply
                                    0
                                    • 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
                                          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