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. Other peoples code

Other peoples code

Scheduled Pinned Locked Moved The Lounge
csswpfquestion
28 Posts 17 Posters 6 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 Andrew Torrance

    We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    You are not alone. Having one exit point for a function is good practice IMHO, and I too default any returned params just to be safe. :)


    Faith. Believing in something you *know* isn't true.

    E 1 Reply Last reply
    0
    • A Andrew Torrance

      We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #3

      i think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments if someone can't figure out whats going on fromthe code itself then the code itself is the problem. Something which should be taken into account at the time of writing, not later on :) Readable code is something which needs to be worked on as you code :) cheers Bryce

      M realJSOPR M M 4 Replies Last reply
      0
      • A Andrew Torrance

        We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

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

        I also preffer to have one exit point. You have only one place to cleanup what you allocated in the function. /Magnus


        - I don't necessarily agree with everything I say

        E 1 Reply Last reply
        0
        • A Andrew Torrance

          We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

          P Offline
          P Offline
          Paul Riley
          wrote on last edited by
          #5

          Andrew Torrance wrote: I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Doesn't sound all that quirky to me. :-D Paul I think there're pieces of me you've never seen - Tori Amos, Tear in Your Hand

          D A 2 Replies Last reply
          0
          • P Paul Riley

            Andrew Torrance wrote: I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Doesn't sound all that quirky to me. :-D Paul I think there're pieces of me you've never seen - Tori Amos, Tear in Your Hand

            D Offline
            D Offline
            Davy Mitchell
            wrote on last edited by
            #6

            I find writing the comments first helps me plan out a function :) Davy Weblog, Ramblings and more... www.latedecember.com

            1 Reply Last reply
            0
            • A Andrew Torrance

              We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

              B Offline
              B Offline
              Brad Jennings
              wrote on last edited by
              #7

              I also like one exit point. Just seems like good coding technique. My quirk is that I use "temp" as a variable far too often i.e. temp1, temp2,... Very bad habit but I'm not as bad about it as I used to be. Later. Brad Jennings

              realJSOPR 1 Reply Last reply
              0
              • A Andrew Torrance

                We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #8

                I mostly agree with Bryce's comment below about comments (no pun intended), that code should be written in a way to be self documenting, which is achieved primarily through useful class, function, and variable names. However, I occasionally have to write some "algorithmic" code which is not obvious. My own quirk regarding comments is that I think they mostly make the code unreadable. Therefore, if the code is non-intuitive, I put comments just above the function name, and I comment important lines within the function or class. However, I still encounter companies where the rule is "don't go past 80 characters", so comments wrap (as does code!), and are placed inbetween lines of code. Argh! :mad: What is this? The days of teletype terminals? I typically place my comments way out beyond the right margin (at least 150 chars). But then, I also use screen resolutions of at least 1280x1024, and I set my text font to 8 pt. Of course, I'm probably going blind too! :rolleyes: I like the embedded XML comment capability of C#, but I find myself spending more time writing documentation than code. (Oh, that's the way it's supposed to be, isn't it). Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

                1 Reply Last reply
                0
                • M Michael P Butler

                  bryce wrote: think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments Comments aren't there for describing what the code does, they are there for describing why you are doing something. All code should be commented, so that in 3 months time you don't say "Why the **** did I do it like this" bryce wrote: Readable code is something which needs to be worked on as you code Quiet agree. Michael "I've died for a living in the movies and tv. But the hardest thing I'll ever do is watch my leading ladies, Kiss some other guy while I'm bandaging my knee." -- The Unknown Stuntman

                  B Offline
                  B Offline
                  bryce
                  wrote on last edited by
                  #9

                  Michael P Butler wrote: Comments aren't there for describing what the code does, they are there for describing why you are doing something. All code should be commented, so that in 3 months time you don't say "Why the **** did I do it like this" i dont know if i agree with this if the code is easy to read then you dont need comments do you? (added) a line of comment before each function is about all you need and to keep your functions short - 25 lines of code is all you need , anything more and it increases % of bugs and makesit harder to read/keep track of. course, that being said i'm not showing you my code ;) Bryce

                  realJSOPR 1 Reply Last reply
                  0
                  • B bryce

                    i think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments if someone can't figure out whats going on fromthe code itself then the code itself is the problem. Something which should be taken into account at the time of writing, not later on :) Readable code is something which needs to be worked on as you code :) cheers Bryce

                    M Offline
                    M Offline
                    Michael P Butler
                    wrote on last edited by
                    #10

                    bryce wrote: think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments Comments aren't there for describing what the code does, they are there for describing why you are doing something. All code should be commented, so that in 3 months time you don't say "Why the **** did I do it like this" bryce wrote: Readable code is something which needs to be worked on as you code Quiet agree. Michael "I've died for a living in the movies and tv. But the hardest thing I'll ever do is watch my leading ladies, Kiss some other guy while I'm bandaging my knee." -- The Unknown Stuntman

                    B 1 Reply Last reply
                    0
                    • B bryce

                      i think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments if someone can't figure out whats going on fromthe code itself then the code itself is the problem. Something which should be taken into account at the time of writing, not later on :) Readable code is something which needs to be worked on as you code :) cheers Bryce

                      realJSOPR Offline
                      realJSOPR Offline
                      realJSOP
                      wrote on last edited by
                      #11

                      "Self-documenting" code is a myth. There's no such thing. I don't care how careful you are, reading comprehension and perception of almost EVERYBODY else will be all over the scale. I'm currently dealing with numerous projects where there is little/no comments in the code, and it's driving everybody working on those projects absolutely NUTS. Comment well, and comment often. Use complete sentences and spell correctly to lessen the chances of misinterpretation. Do NOT rely on external tools or the promise of external documentation. Even better, don't rely on anyone else to follow up and comment your code for you when they happen to have to look at it. As far as coding style, don't get any fancier than you need to get. Fancy usually means complex, and complex always means unmaintainable by new team members. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                      B D B 3 Replies Last reply
                      0
                      • B bryce

                        Michael P Butler wrote: Comments aren't there for describing what the code does, they are there for describing why you are doing something. All code should be commented, so that in 3 months time you don't say "Why the **** did I do it like this" i dont know if i agree with this if the code is easy to read then you dont need comments do you? (added) a line of comment before each function is about all you need and to keep your functions short - 25 lines of code is all you need , anything more and it increases % of bugs and makesit harder to read/keep track of. course, that being said i'm not showing you my code ;) Bryce

                        realJSOPR Offline
                        realJSOPR Offline
                        realJSOP
                        wrote on last edited by
                        #12

                        I'll save my reply to this for his reply to my post. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                        1 Reply Last reply
                        0
                        • B Brad Jennings

                          I also like one exit point. Just seems like good coding technique. My quirk is that I use "temp" as a variable far too often i.e. temp1, temp2,... Very bad habit but I'm not as bad about it as I used to be. Later. Brad Jennings

                          realJSOPR Offline
                          realJSOPR Offline
                          realJSOP
                          wrote on last edited by
                          #13

                          I like one exit point too, but a lot of times, that just makes the code hard to follow. Get the exceptions out of the way as early as possible, and then write the business end of the function. Otherwise, you'll have deeply nested code that is a bitch to follow. My rule is that if there's more than three levels of nesting needed to support the desire for a single exit point, it's best not to do it. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                          M A 2 Replies Last reply
                          0
                          • realJSOPR realJSOP

                            "Self-documenting" code is a myth. There's no such thing. I don't care how careful you are, reading comprehension and perception of almost EVERYBODY else will be all over the scale. I'm currently dealing with numerous projects where there is little/no comments in the code, and it's driving everybody working on those projects absolutely NUTS. Comment well, and comment often. Use complete sentences and spell correctly to lessen the chances of misinterpretation. Do NOT rely on external tools or the promise of external documentation. Even better, don't rely on anyone else to follow up and comment your code for you when they happen to have to look at it. As far as coding style, don't get any fancier than you need to get. Fancy usually means complex, and complex always means unmaintainable by new team members. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                            B Offline
                            B Offline
                            bryce
                            wrote on last edited by
                            #14

                            John Simmons / outlaw programmer wrote: 'm currently dealing with numerous projects where there is little/no comments in the code, and it's driving everybody working on those projects absolutely NUTS. sounds like you're saying the code is unreadable? John Simmons / outlaw programmer wrote: As far as coding style, don't get any fancier than you need to get. Fancy usually means complex, and complex always means unmaintainable by new team members. i'll agree with this :) simple stuff is nearly always better Bryce

                            1 Reply Last reply
                            0
                            • A Andrew Torrance

                              We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                              J Offline
                              J Offline
                              Justin Hallet
                              wrote on last edited by
                              #15

                              I used to be a style fanatic, wanting everyone to use my coding standards, but over the years I have come to realize the following to be true. Can you read the code and understand its intent? Yes, coding style is good enough. No, something has to change. There are different levels to examine here, layout/names/spacing is the minor, and logic is the major. As long as the code is understandable and the logic is correct don't stress and worry over the minor. Unless its your own code and you are not proud of how it looks! :-D

                              A 1 Reply Last reply
                              0
                              • B bryce

                                i think the best thing to do for your own coding is to ake it self documenting ergo needing little or no comments if someone can't figure out whats going on fromthe code itself then the code itself is the problem. Something which should be taken into account at the time of writing, not later on :) Readable code is something which needs to be worked on as you code :) cheers Bryce

                                M Offline
                                M Offline
                                Michael A Barnhart
                                wrote on last edited by
                                #16

                                I totaly agree with John Simmons. Self documenting code is a myth. There is no way for the code to explain why you did it this way. Other than trivial functions you must explain why and what assumptions you are making. It is amazing how smart your were years ago and do not tell me you remember why you coded something last year. Or 10 years ago or 100 years ago, If the product you are supporting has a long life span it may very well be that the code behind it must be kept. So these figures are not made up! "We are what we repeatedly do. excellence, then, is not an act, but a habit." Aristotle

                                B 1 Reply Last reply
                                0
                                • realJSOPR realJSOP

                                  I like one exit point too, but a lot of times, that just makes the code hard to follow. Get the exceptions out of the way as early as possible, and then write the business end of the function. Otherwise, you'll have deeply nested code that is a bitch to follow. My rule is that if there's more than three levels of nesting needed to support the desire for a single exit point, it's best not to do it. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                                  M Offline
                                  M Offline
                                  Michael A Barnhart
                                  wrote on last edited by
                                  #17

                                  John Simmons / outlaw programmer wrote: Get the exceptions out of the way Good point and I agree. There are allways exceptions. It bothers me when someone blindly follows absolutes that their instructors drilled into them. Even GOTO's have usage at times. I am not saying do not follow good practices. "We are what we repeatedly do. excellence, then, is not an act, but a habit." Aristotle

                                  1 Reply Last reply
                                  0
                                  • P Paul Riley

                                    Andrew Torrance wrote: I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Doesn't sound all that quirky to me. :-D Paul I think there're pieces of me you've never seen - Tori Amos, Tear in Your Hand

                                    A Offline
                                    A Offline
                                    Andrew Torrance
                                    wrote on last edited by
                                    #18

                                    Look at the code on this site , it is almost universal to find a return in a conditional statement . A single exit point means that return cannot be in such a segment of code. What starts off as trivial can end up growing into something painful. so I avoid things like.. if(MyVariable = true) return(); // The use of bracketted return is another quirk ! Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                                    1 Reply Last reply
                                    0
                                    • realJSOPR realJSOP

                                      I like one exit point too, but a lot of times, that just makes the code hard to follow. Get the exceptions out of the way as early as possible, and then write the business end of the function. Otherwise, you'll have deeply nested code that is a bitch to follow. My rule is that if there's more than three levels of nesting needed to support the desire for a single exit point, it's best not to do it. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

                                      A Offline
                                      A Offline
                                      Andrew Torrance
                                      wrote on last edited by
                                      #19

                                      Do you follow any 'rules' when handling exceptions ? E.g dealing with them close to where they happen or appending data to them and rethrowing them ? There must be some good ideas on exception handling , but all I ever see are nuts and bolts type articles never any ones on good practices. Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                                      1 Reply Last reply
                                      0
                                      • J Justin Hallet

                                        I used to be a style fanatic, wanting everyone to use my coding standards, but over the years I have come to realize the following to be true. Can you read the code and understand its intent? Yes, coding style is good enough. No, something has to change. There are different levels to examine here, layout/names/spacing is the minor, and logic is the major. As long as the code is understandable and the logic is correct don't stress and worry over the minor. Unless its your own code and you are not proud of how it looks! :-D

                                        A Offline
                                        A Offline
                                        Andrew Torrance
                                        wrote on last edited by
                                        #20

                                        Justin Hallet wrote: As long as the code is understandable and the logic is correct don't stress and worry over the minor. Fair enough , but what is understandable to one person may be difficult for another if the style used is not what you are used to . Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                                        1 Reply Last reply
                                        0
                                        • A Andrew Torrance

                                          We all have our own styles of writing , how do you find other peoples styles ? I have a quirk in that my functions only EVER have one exit point , and the first thing I do in any function is to default any returned parameters. Looking at this site I seem to be in a minority of slightly less than two , so what I do must be quirky , anyone else have style quirks ? And how do you get on with other peoples quirks ? Am I the only one forever playing catch up with technology , while all the juicy opportunites keep rolling by ?

                                          S Offline
                                          S Offline
                                          Stephane Rodriguez
                                          wrote on last edited by
                                          #21

                                          Objects should implement their own behaviour. This implies that methods do one thing, not 2, 3, 4. This from what I see does a lot for understanding the code, whether or not you actualjy wrote it. Also good for self-documentation even without // or /*. And also good for component code reusability.


                                          How low can you go ?
                                          (MS rant)

                                          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