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. General Programming
  3. C#
  4. visual C# 2005 exiting

visual C# 2005 exiting

Scheduled Pinned Locked Moved C#
csharphelptutorial
56 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.
  • N Not Active

    Ennis Ray Lynch, Jr. wrote:

    Return is not allowed

    Not allowed, or not recommended? Two different things. I don't know of any language that places a restriction on the number of return statements that can be used in a block of code. However, yes, good design principles dictate that you should have as few exit points as possible. The original question only asked what the equivalent of VB's exit sub was, not how it should be used. Both Mike and I answered that direct question. Saying "Don't listen to anyone else" is a bit over the top.


    only two letters away from being an asset

    E Offline
    E Offline
    Ennis Ray Lynch Jr
    wrote on last edited by
    #36

    Anyone with the experience and judgment to disregard my statement would do so. Telling a novice not to do it is perfectly inline. A lot of the advice I give is structured to introductory programmers as more experienced developers have the experience to know when it is hogwash. By biasing my response towards less experienced developers I increase the value of the statements. I will repeat my statement with the inferred subtext: "Return is not allowed unless you have the experience and judgment to properly identify cases for its use and understand the consequences both positive and negative"

    Need a C# Consultant? I'm available.
    Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

    1 Reply Last reply
    0
    • X xxmikexx

      we dont have an "admissions office" also in high school you dont have a major...

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #37

      xxmikexx wrote:

      high school

      Well that explains a lot. Now, go do your homework and leave this to the adults.


      only two letters away from being an asset

      X 1 Reply Last reply
      0
      • N Not Active

        xxmikexx wrote:

        better yet just go die

        Well eventually I will, immortality would get boring after the first millennium anyway.


        only two letters away from being an asset

        X Offline
        X Offline
        xxmikexx
        wrote on last edited by
        #38

        seem to disregard the message i sent you

        1 Reply Last reply
        0
        • N Not Active

          xxmikexx wrote:

          high school

          Well that explains a lot. Now, go do your homework and leave this to the adults.


          only two letters away from being an asset

          X Offline
          X Offline
          xxmikexx
          wrote on last edited by
          #39

          http://mansoftdev.com/Resume/Mark%20Nischalke.doc[^] i believe i found that guys problem... he seems to be upset most likely because he has no people skills and by the looks of it cant seem to hold down a job... maybe just me but maybe no one else seems to like him, idk just throwing that out there

          N 1 Reply Last reply
          0
          • X xxmikexx

            thanks for that it is really hard to explain what i mean tho, i know about that but since it is a timer once it is executed it will set off all of the others that is what i want it to do but i want to go through one if statement each time the timer is used. i am making a program with a group of 16 buttons and when they click one it changes the colors of those around it and i want to send out a wave effect so the only practical way i could think of was finding something similiar to that break thing other wise all of them will go off i just dont really know how to explain what i need thanks for the help tho

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

            It sounds like you need to rethink your logic a bit. The requirements you just spelled out shouldn't require such a complex if statement.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            X 1 Reply Last reply
            0
            • X xxmikexx

              http://mansoftdev.com/Resume/Mark%20Nischalke.doc[^] i believe i found that guys problem... he seems to be upset most likely because he has no people skills and by the looks of it cant seem to hold down a job... maybe just me but maybe no one else seems to like him, idk just throwing that out there

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #41

              Wow, you found my resume online. I'm impressed and awed by your skills. I see that not only are you an experienced developer, but also a psychologist. So tell me Dr., why do I hate my mother? Speaking of mothers, I think yours is calling. It's past your bedtime anyway, so run along little one.


              only two letters away from being an asset

              X R 2 Replies Last reply
              0
              • D Dave Kreskowiak

                It sounds like you need to rethink your logic a bit. The requirements you just spelled out shouldn't require such a complex if statement.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                X Offline
                X Offline
                xxmikexx
                wrote on last edited by
                #42

                o really lol i guess there would be a better way

                1 Reply Last reply
                0
                • N Not Active

                  Wow, you found my resume online. I'm impressed and awed by your skills. I see that not only are you an experienced developer, but also a psychologist. So tell me Dr., why do I hate my mother? Speaking of mothers, I think yours is calling. It's past your bedtime anyway, so run along little one.


                  only two letters away from being an asset

                  X Offline
                  X Offline
                  xxmikexx
                  wrote on last edited by
                  #43

                  haha for a "big mature adult" which for whatever you seem to think you are, you behave much more imaturely than my little sister, i cant explain y you hate your mother but probably because you are a failure to what you truly want to be have average skills and think that towering over younger people and imposing your measly imaginitive power deep down inside this makes you feel better and people liek you need to grow up and are just dispicable.

                  1 Reply Last reply
                  0
                  • N Not Active

                    Wow, you found my resume online. I'm impressed and awed by your skills. I see that not only are you an experienced developer, but also a psychologist. So tell me Dr., why do I hate my mother? Speaking of mothers, I think yours is calling. It's past your bedtime anyway, so run along little one.


                    only two letters away from being an asset

                    R Offline
                    R Offline
                    rockNroll
                    wrote on last edited by
                    #44

                    Looking at your experience, i am sure you are definitely over 30 yrs of age. And mike is a kid in front of you...Common man..chill out now. It's not making you any better. Be nice with others and they ll be nice with you. ***Simple golden rule*** :)

                    X N M 3 Replies Last reply
                    0
                    • R rockNroll

                      Looking at your experience, i am sure you are definitely over 30 yrs of age. And mike is a kid in front of you...Common man..chill out now. It's not making you any better. Be nice with others and they ll be nice with you. ***Simple golden rule*** :)

                      X Offline
                      X Offline
                      xxmikexx
                      wrote on last edited by
                      #45

                      haha ya i agree i probably should of just ignored everthing he said but it is funny since he is getting mad over nothing i dont care lol

                      1 Reply Last reply
                      0
                      • R rockNroll

                        Looking at your experience, i am sure you are definitely over 30 yrs of age. And mike is a kid in front of you...Common man..chill out now. It's not making you any better. Be nice with others and they ll be nice with you. ***Simple golden rule*** :)

                        N Offline
                        N Offline
                        Not Active
                        wrote on last edited by
                        #46

                        Oh come on, it sure is fun and certainly made the day go by :laugh:


                        only two letters away from being an asset

                        X 1 Reply Last reply
                        0
                        • N Not Active

                          Oh come on, it sure is fun and certainly made the day go by :laugh:


                          only two letters away from being an asset

                          X Offline
                          X Offline
                          xxmikexx
                          wrote on last edited by
                          #47

                          haha he is trying to act like he doesnt care well he is probably about ready to run home to mommy to lick his wounds

                          R 1 Reply Last reply
                          0
                          • X xxmikexx

                            haha he is trying to act like he doesnt care well he is probably about ready to run home to mommy to lick his wounds

                            R Offline
                            R Offline
                            rockNroll
                            wrote on last edited by
                            #48

                            Anyway mike you need to stop replying back now. Finish it now. He is quite elder to you..so you can take a initiative to be good with him by not stretching this more... All the best.

                            X 1 Reply Last reply
                            0
                            • R rockNroll

                              Anyway mike you need to stop replying back now. Finish it now. He is quite elder to you..so you can take a initiative to be good with him by not stretching this more... All the best.

                              X Offline
                              X Offline
                              xxmikexx
                              wrote on last edited by
                              #49

                              ya you are right thank you all for helping me with my problem

                              1 Reply Last reply
                              0
                              • R rockNroll

                                Looking at your experience, i am sure you are definitely over 30 yrs of age. And mike is a kid in front of you...Common man..chill out now. It's not making you any better. Be nice with others and they ll be nice with you. ***Simple golden rule*** :)

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

                                I think its funny :)

                                1 Reply Last reply
                                0
                                • E Ennis Ray Lynch Jr

                                  Unfortunately, the nature of business software development causes me to recommend against this. Using structured exists simplifies debugging and serves as a preventative measure from a junior programmer going haywire with a 10 page method. While I can say a deeply nested conditional does breed defects the case is made to follow Fowler on this one and refactor into more simpler methods.

                                  Need a C# Consultant? I'm available.
                                  Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                  L Offline
                                  L Offline
                                  led mike
                                  wrote on last edited by
                                  #51

                                  Ennis Ray Lynch, Jr. wrote:

                                  Unfortunately, the nature of business software development

                                  That book is specifically directed at business software. Again, I highly recommend it. There is no way I am going believe my perspective is more reliable than someone like Kent Beck. Following the advice of experts in the industry like Beck is what I have always done, I am not about to change that now.

                                  Ennis Ray Lynch, Jr. wrote:

                                  the case is made to follow Fowler on this one

                                  This is from the first page of the book: "Many people don't realize how readable code can be and how valuable that readability is. Kent has taught me so much, I'm glad this book gives everyone the chance to learn from him." - Martin Fowler, chief scientist, ThoughtWorks There are six people endorsing the book on that first page, one of them besides Fowler is Erich Gamma.

                                  Ennis Ray Lynch, Jr. wrote:

                                  and refactor into more simpler methods.

                                  The small excerpt I posted does not provide his entire discussion on the subject of Guard Clauses nor the context for the entire book nor the books discussion of refactoring into smaller methods. Perhaps before concluding his reasoning is wrong, you might want to read the book so you can know what his reasoning is before you decide to dismiss it.

                                  led mike

                                  E 1 Reply Last reply
                                  0
                                  • L led mike

                                    Ennis Ray Lynch, Jr. wrote:

                                    Unfortunately, the nature of business software development

                                    That book is specifically directed at business software. Again, I highly recommend it. There is no way I am going believe my perspective is more reliable than someone like Kent Beck. Following the advice of experts in the industry like Beck is what I have always done, I am not about to change that now.

                                    Ennis Ray Lynch, Jr. wrote:

                                    the case is made to follow Fowler on this one

                                    This is from the first page of the book: "Many people don't realize how readable code can be and how valuable that readability is. Kent has taught me so much, I'm glad this book gives everyone the chance to learn from him." - Martin Fowler, chief scientist, ThoughtWorks There are six people endorsing the book on that first page, one of them besides Fowler is Erich Gamma.

                                    Ennis Ray Lynch, Jr. wrote:

                                    and refactor into more simpler methods.

                                    The small excerpt I posted does not provide his entire discussion on the subject of Guard Clauses nor the context for the entire book nor the books discussion of refactoring into smaller methods. Perhaps before concluding his reasoning is wrong, you might want to read the book so you can know what his reasoning is before you decide to dismiss it.

                                    led mike

                                    E Offline
                                    E Offline
                                    Ennis Ray Lynch Jr
                                    wrote on last edited by
                                    #52

                                    I have read both books and I agree with the authors on many precepts, however, the books suffer from the fundamental flaw of assuming expert level developers or developers with motivation to develop good code. Most business environments I go to love to say, "We don't have blame here" or "No one owns the code". Those two premises invalidate both books as they lead to engineering disasters. My advice is not necessarily aimed at the ideal art of development because the ideal environment is usually corrupted. With respect to guard classes there is another refactor that suggests it would be more appropriate to use inheritance to make a decision like this. Furthermore, in a guard class is is presumed that the early returns have a very low weighted value and are exceptional and not normal flow actions. The very reason for the guard clause is to illustrate the importance. Unfortunately, what I usually end up correcting is massive series of if-then-else statements spanning many pages littered with returns. I guess to put my opinion in context: if I came across a method with a well thought out series of guard clauses I would leave it alone. Unfortunately, I have seen virtually no methods that fall into the narrow scope of guard clauses and I have been around the block a few times.

                                    Need a C# Consultant? I'm available.
                                    Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                    L 1 Reply Last reply
                                    0
                                    • E Ennis Ray Lynch Jr

                                      I have read both books and I agree with the authors on many precepts, however, the books suffer from the fundamental flaw of assuming expert level developers or developers with motivation to develop good code. Most business environments I go to love to say, "We don't have blame here" or "No one owns the code". Those two premises invalidate both books as they lead to engineering disasters. My advice is not necessarily aimed at the ideal art of development because the ideal environment is usually corrupted. With respect to guard classes there is another refactor that suggests it would be more appropriate to use inheritance to make a decision like this. Furthermore, in a guard class is is presumed that the early returns have a very low weighted value and are exceptional and not normal flow actions. The very reason for the guard clause is to illustrate the importance. Unfortunately, what I usually end up correcting is massive series of if-then-else statements spanning many pages littered with returns. I guess to put my opinion in context: if I came across a method with a well thought out series of guard clauses I would leave it alone. Unfortunately, I have seen virtually no methods that fall into the narrow scope of guard clauses and I have been around the block a few times.

                                      Need a C# Consultant? I'm available.
                                      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                      L Offline
                                      L Offline
                                      led mike
                                      wrote on last edited by
                                      #53

                                      Ennis Ray Lynch, Jr. wrote:

                                      Most business environments I go to love to say, "We don't have blame here" or "No one owns the code".

                                      Ok, I understand you believe there are special circumstances ( though widely implemented) that make you believe it might not be practical, but that's not what you said:

                                      Ennis Ray Lynch, Jr. wrote:

                                      Return is not allowed inside of methods more than once and should not be used by any method that does not have a functional result. Doing so is a poor programming practice that violates the one-in, one-out principle.

                                      It's not poor programming practice. What you described is actually poor programming practice, you just think it's more practical given your stated circumstances. Or have I misunderstood your point?

                                      led mike

                                      E 1 Reply Last reply
                                      0
                                      • L led mike

                                        Ennis Ray Lynch, Jr. wrote:

                                        Most business environments I go to love to say, "We don't have blame here" or "No one owns the code".

                                        Ok, I understand you believe there are special circumstances ( though widely implemented) that make you believe it might not be practical, but that's not what you said:

                                        Ennis Ray Lynch, Jr. wrote:

                                        Return is not allowed inside of methods more than once and should not be used by any method that does not have a functional result. Doing so is a poor programming practice that violates the one-in, one-out principle.

                                        It's not poor programming practice. What you described is actually poor programming practice, you just think it's more practical given your stated circumstances. Or have I misunderstood your point?

                                        led mike

                                        E Offline
                                        E Offline
                                        Ennis Ray Lynch Jr
                                        wrote on last edited by
                                        #54

                                        I think we are beginning to understand. However, the point of my blanket statement is the fact that when introducing novice, inexperienced, or lazy programmers to the concept you cannot provide options. The allowance for violating the rule, is in my opinion, an advanced concept that a developer will naturally get on their own. My blanket statement will be ignored by anyone with the experience to do so and should be headed by anyone without the experience. Maybe my error was in the presentation by saying not to listen to anyone else. However, experienced developers encouraging an inexperienced developer down the wrong path risks much. Sometimes I am a condescending A**, so you must forgive me :p

                                        Need a C# Consultant? I'm available.
                                        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                        L 1 Reply Last reply
                                        0
                                        • E Ennis Ray Lynch Jr

                                          I think we are beginning to understand. However, the point of my blanket statement is the fact that when introducing novice, inexperienced, or lazy programmers to the concept you cannot provide options. The allowance for violating the rule, is in my opinion, an advanced concept that a developer will naturally get on their own. My blanket statement will be ignored by anyone with the experience to do so and should be headed by anyone without the experience. Maybe my error was in the presentation by saying not to listen to anyone else. However, experienced developers encouraging an inexperienced developer down the wrong path risks much. Sometimes I am a condescending A**, so you must forgive me :p

                                          Need a C# Consultant? I'm available.
                                          Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                          L Offline
                                          L Offline
                                          led mike
                                          wrote on last edited by
                                          #55

                                          Ennis Ray Lynch, Jr. wrote:

                                          Sometimes I am a condescending A**, so you must forgive me

                                          And I'm not :laugh: Yeah I wasn't concerned with that, just the statement of it being bad practice is all. No doubt the way the original poster was about to use it actually would  be bad practice. :-D

                                          led mike

                                          X 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