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 Insider News
  4. C# coding style

C# coding style

Scheduled Pinned Locked Moved The Insider News
csharpphpcomtutorialquestion
28 Posts 8 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.
  • C Chris Jacobi

    Hi, for quite some time I am using my own C# style guide for my startup. It probably is among the C# style guides the one with the most variations from "official" style guides. However, all variations are principled and never just for the reason of being different. I would invite anybody to have a look at it. Maybe one or the other feature might prove beneficial for your own projects. It can be found here: http://chrisjacobi.wordpress.com[^] A separate discussion meta-topic might be: By using a style guide like this, will it attract stellar programmers because it is a nice style and gives enough individual freedom? Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style? Chris, www.whitehawksoftware.com[^]

    G Offline
    G Offline
    Garth J Lancaster
    wrote on last edited by
    #8

    BTW : I've sent a note to the 'Hamsters' requesting this be moved somewhere 'more appropriate'

    1 Reply Last reply
    0
    • C Chris Jacobi

      Hi, for quite some time I am using my own C# style guide for my startup. It probably is among the C# style guides the one with the most variations from "official" style guides. However, all variations are principled and never just for the reason of being different. I would invite anybody to have a look at it. Maybe one or the other feature might prove beneficial for your own projects. It can be found here: http://chrisjacobi.wordpress.com[^] A separate discussion meta-topic might be: By using a style guide like this, will it attract stellar programmers because it is a nice style and gives enough individual freedom? Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style? Chris, www.whitehawksoftware.com[^]

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

      Guide reads:

      We [...] don't want any rules which makes their life harder.

      So, the code is automatically formatted on each checkin?

      Guide reads:

      We prefer standard SQL. **

      Which one? I prefer the 92 standard :)

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      C 1 Reply Last reply
      0
      • G Garth J Lancaster

        There may have been a better place to post this - but the intent is good I think 'C# style guides' are worthwhile, but, you need to have a living document, and you may well change your stance on something over time - I also think you'd have to provide examples - for example 'Big O Notation' - not many [cough] younger programmers these days I suspect would know or care what that means. You could also include - use of a code repository, and give basic instructions on maintaining a project within a repository, AND, you could also include suggested directory structure for a project, especially where you have sub projects, 3rd party libraries, shared utility libraries of your own, etc :-) 'g'

        C Offline
        C Offline
        Chris Jacobi
        wrote on last edited by
        #10

        Garth, I believe you are right or have a good point in everything you have mentioned. I will explain motivations not because I am defensive, but because it adds details to the discussion. I do agree about needing a living document; I do have some problems finding the right technology however. Once I have (more) coworkers, their input is a must; for a limited time PDF works fine. About changing the stance, I not only agree, but can admit that it already has happened a few times (E.g. what it says about lambdas). Big O notation: I do not want to belittle younger guys who haven't heard about it. In some sense this style is an example of mild project-dependence: In my particular application not being carefull with Big O notation would doom it pretty fast. And, on project dependency: It is somewhat hurtfull for me to be quiet on scheduling multiple processes, however my time limits and the specific purpose of the guide lead me to ommit features which are not relevant in my particular context. I found that admitting and even using some project dependencies made it much easier to come up with a useful guide. Code repositary, directory structures, maintenance policy are all out for 2 simple reasons: 1) I'm not experienced enough to know the best ways myself. 2) Once decided I think they will not be part of a style guide; they will be part of mandatory project rules. About a better place to post: I did some research to find a good place; I apologize if I wasn't thorough enough and used a wrong place. If people who know the right structure for this website can improve the placement, I am thankful. By the way if that other guy calls it spam, he is not completely off, just a little impolite: 1) I do have a spam component: Attracting the right guys around me was part of my goal... 2) I hate spam so much that I am willing to forgive some knee-jerk reactions against something he considers spam. Chris

        1 Reply Last reply
        0
        • L Lost User

          Guide reads:

          We [...] don't want any rules which makes their life harder.

          So, the code is automatically formatted on each checkin?

          Guide reads:

          We prefer standard SQL. **

          Which one? I prefer the 92 standard :)

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          C Offline
          C Offline
          Chris Jacobi
          wrote on last edited by
          #11

          You hit a slightly sour point in my standard: a) I think most rules are on a level a little bit higher then what automatic formatters can do. b) Fixing output of automatic formatters is painful. However, readability is so important to me that I pay the price. I am takeing your word on SQL, at least until a coworker will bring up that issue again. That choice may be important in a particular project, but I don't think the choice adds much value to a somewhat more generic style guide discussion. (I saw your :) )

          L 1 Reply Last reply
          0
          • C Chris Jacobi

            Hi, for quite some time I am using my own C# style guide for my startup. It probably is among the C# style guides the one with the most variations from "official" style guides. However, all variations are principled and never just for the reason of being different. I would invite anybody to have a look at it. Maybe one or the other feature might prove beneficial for your own projects. It can be found here: http://chrisjacobi.wordpress.com[^] A separate discussion meta-topic might be: By using a style guide like this, will it attract stellar programmers because it is a nice style and gives enough individual freedom? Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style? Chris, www.whitehawksoftware.com[^]

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

            Wordy, verbose, you should use your own style guide when writing the document (as in, liberal use of whitespace), abstract, vague, treads on far too many topics having nothing to do with style...I could go on. This needs some serious polishing. A good style guide is short, to the point, and provides a simple "good" and "bad" example so the desired style is clear -- no wiggle room for interpretation.

            Chris Jacobi wrote:

            Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style?

            From what I read through there's nothing particularly unusual about what you write -- most of it is common sense. But who in the world is going to police an 11 page document? And what in the world does "Agile" have to do with "style?" My advice: cut the document by replacing 90% of your words with short "do/don't do" examples. Imagine something that can fit on a 4x6 two-sided notecard. Marc

            C 1 Reply Last reply
            0
            • M Marc Clifton

              Wordy, verbose, you should use your own style guide when writing the document (as in, liberal use of whitespace), abstract, vague, treads on far too many topics having nothing to do with style...I could go on. This needs some serious polishing. A good style guide is short, to the point, and provides a simple "good" and "bad" example so the desired style is clear -- no wiggle room for interpretation.

              Chris Jacobi wrote:

              Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style?

              From what I read through there's nothing particularly unusual about what you write -- most of it is common sense. But who in the world is going to police an 11 page document? And what in the world does "Agile" have to do with "style?" My advice: cut the document by replacing 90% of your words with short "do/don't do" examples. Imagine something that can fit on a 4x6 two-sided notecard. Marc

              C Offline
              C Offline
              Chris Jacobi
              wrote on last edited by
              #13

              Marc, thanks for your comment. I have never written a style guide for the English language. Only a fool or an elementary school teacher would make the effort to read what I have to say about the English language; I certainly cannot refute your statement on polish. I disagree on whatever is the proper length. When I researched style guides I found some very short and to the point guides; I ignored many simply because I couldn't see the reasoning behind what they were saying. There is a 350 page book "Framework Design Guidelines" (mostly C#) [Google]. I think it is well written and has interesting inserts from different personalities. Nevertheless, I ignored most of it, mostly because it doesn't respect the limits of my attention span. Somewhat because is too general and doesn't contain what is specially important for my startup. And lastly, they didn't dare to disagree loudly enough with other standards. I think having some wiggle room is treating my cowerkers as professional adults. For the same reason it has very little trivial content. Examples would be nice, but most is for the benefit of programming-in-the-large, where I find it difficult to make reasonable examples. "Policing" is not something I like to do; The people I want to work with earn respect and absence of being policed. If you think there is nothing unusual and most is common sense, I think that this is a compliment to me, but in my opinion it also compliments on you. What has "Agile" have to do with "style?" Good question, but I am taking some wiggle room myself defining what is style. In what other document could I ramble about obsessive agile-ness in a reasonable way? And for anybody who has read till here: Google Marc on CodeProject; he has written some nice articles. Chris www.whitehawksoftware.com Edited to spell Marc's name corrctly.

              P D 2 Replies Last reply
              0
              • C Chris Jacobi

                Marc, thanks for your comment. I have never written a style guide for the English language. Only a fool or an elementary school teacher would make the effort to read what I have to say about the English language; I certainly cannot refute your statement on polish. I disagree on whatever is the proper length. When I researched style guides I found some very short and to the point guides; I ignored many simply because I couldn't see the reasoning behind what they were saying. There is a 350 page book "Framework Design Guidelines" (mostly C#) [Google]. I think it is well written and has interesting inserts from different personalities. Nevertheless, I ignored most of it, mostly because it doesn't respect the limits of my attention span. Somewhat because is too general and doesn't contain what is specially important for my startup. And lastly, they didn't dare to disagree loudly enough with other standards. I think having some wiggle room is treating my cowerkers as professional adults. For the same reason it has very little trivial content. Examples would be nice, but most is for the benefit of programming-in-the-large, where I find it difficult to make reasonable examples. "Policing" is not something I like to do; The people I want to work with earn respect and absence of being policed. If you think there is nothing unusual and most is common sense, I think that this is a compliment to me, but in my opinion it also compliments on you. What has "Agile" have to do with "style?" Good question, but I am taking some wiggle room myself defining what is style. In what other document could I ramble about obsessive agile-ness in a reasonable way? And for anybody who has read till here: Google Marc on CodeProject; he has written some nice articles. Chris www.whitehawksoftware.com Edited to spell Marc's name corrctly.

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

                Please take the opportunity to spell Marc's name properly. I know you don't mean it, but getting someone's name wrong is very disrespectful.

                L T 2 Replies Last reply
                0
                • C Chris Jacobi

                  You hit a slightly sour point in my standard: a) I think most rules are on a level a little bit higher then what automatic formatters can do. b) Fixing output of automatic formatters is painful. However, readability is so important to me that I pay the price. I am takeing your word on SQL, at least until a coworker will bring up that issue again. That choice may be important in a particular project, but I don't think the choice adds much value to a somewhat more generic style guide discussion. (I saw your :) )

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

                  Chris Jacobi wrote:

                  You hit a slightly sour point in my standard:

                  I know.

                  Chris Jacobi wrote:

                  I think most rules are on a level a little bit higher then what automatic formatters can do.

                  I would not waste any time on formatting to someones personal preference. Yes, it is important, but it is not a religion.

                  Chris Jacobi wrote:

                  However, readability is so important to me that I pay the price

                  Readability is the most important thing to keep a project alive, I'll agree with that. Don't get me wrong; we're doing a lot in a similar way. Then again, the fact that one does not comment the obvious should not be part of a style-guide - it should be part of the education. Same goes for the SOLID principles. No, I don't like it as a compulsory style guide; it'd take too damn long to verify each rule against the code I wrote to see if there's a violation.

                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Please take the opportunity to spell Marc's name properly. I know you don't mean it, but getting someone's name wrong is very disrespectful.

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

                    Pete O'Hanlon wrote:

                    but getting someone's name wrong is very disrespectful.

                    Making a mistake is never disrespectful.

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                    P 1 Reply Last reply
                    0
                    • C Chris Jacobi

                      Hi, for quite some time I am using my own C# style guide for my startup. It probably is among the C# style guides the one with the most variations from "official" style guides. However, all variations are principled and never just for the reason of being different. I would invite anybody to have a look at it. Maybe one or the other feature might prove beneficial for your own projects. It can be found here: http://chrisjacobi.wordpress.com[^] A separate discussion meta-topic might be: By using a style guide like this, will it attract stellar programmers because it is a nice style and gives enough individual freedom? Alternatively, would it deter first class programmers because they might oppose using a somewhat unusual style? Chris, www.whitehawksoftware.com[^]

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

                      It would be better if you submitted it as an article per the Blog submission guide[^].

                      1 Reply Last reply
                      0
                      • T TheGreatAndPowerfulOz

                        spam

                        If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                        You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                        Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

                        R Offline
                        R Offline
                        Rob Grainger
                        wrote on last edited by
                        #18

                        No its not. Its not trying to sell anything. Its certainly in the wrong forum, but that's something entirely different.

                        "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                        T 1 Reply Last reply
                        0
                        • L Lost User

                          Pete O'Hanlon wrote:

                          but getting someone's name wrong is very disrespectful.

                          Making a mistake is never disrespectful.

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

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

                          Doing it twice is, especially when you can see their name right there in front of you.

                          L 1 Reply Last reply
                          0
                          • C Chris Jacobi

                            Marc, thanks for your comment. I have never written a style guide for the English language. Only a fool or an elementary school teacher would make the effort to read what I have to say about the English language; I certainly cannot refute your statement on polish. I disagree on whatever is the proper length. When I researched style guides I found some very short and to the point guides; I ignored many simply because I couldn't see the reasoning behind what they were saying. There is a 350 page book "Framework Design Guidelines" (mostly C#) [Google]. I think it is well written and has interesting inserts from different personalities. Nevertheless, I ignored most of it, mostly because it doesn't respect the limits of my attention span. Somewhat because is too general and doesn't contain what is specially important for my startup. And lastly, they didn't dare to disagree loudly enough with other standards. I think having some wiggle room is treating my cowerkers as professional adults. For the same reason it has very little trivial content. Examples would be nice, but most is for the benefit of programming-in-the-large, where I find it difficult to make reasonable examples. "Policing" is not something I like to do; The people I want to work with earn respect and absence of being policed. If you think there is nothing unusual and most is common sense, I think that this is a compliment to me, but in my opinion it also compliments on you. What has "Agile" have to do with "style?" Good question, but I am taking some wiggle room myself defining what is style. In what other document could I ramble about obsessive agile-ness in a reasonable way? And for anybody who has read till here: Google Marc on CodeProject; he has written some nice articles. Chris www.whitehawksoftware.com Edited to spell Marc's name corrctly.

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

                            I mostly agree with Marc that the baseline of the style guide should be short and to the point. Supplemental material explaining why can be helpful; but being able to fit the essentials onto at most a single sheet of paper so it can be stuck to the wall for easy reference by anyone new to the team is more useful. If you want to keep it in PDF form, the best option is probably just to add a 1 page short guide that only has the what not the why. If you're willing to switch to HTML format putting the explanation in default collapsed blocks would be better.

                            Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                            1 Reply Last reply
                            0
                            • R Rob Grainger

                              No its not. Its not trying to sell anything. Its certainly in the wrong forum, but that's something entirely different.

                              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                              T Offline
                              T Offline
                              TheGreatAndPowerfulOz
                              wrote on last edited by
                              #21

                              wrong forum = spam, and he's clearly advertising.

                              If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                              You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                              Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

                              1 Reply Last reply
                              0
                              • G Garth J Lancaster

                                what makes you say that ? did you read his 'coding standards' - your post is actually more spam than his, since you barely managed to give a one-word reply

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

                                I'd say that putting links into his post linking to his company which is aiming to have a commercial product out in the next month counts as spamming. The blog post was fine - the link to his company was gratuitous.

                                D 1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  Doing it twice is, especially when you can see their name right there in front of you.

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

                                  Pete O'Hanlon wrote:

                                  Doing it twice is, especially when you can see their name right there in front of you.

                                  Call it a bug; one can overlook a simple typo quickly - let's not suggest that it has anything to do with respect.

                                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                                  1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    Please take the opportunity to spell Marc's name properly. I know you don't mean it, but getting someone's name wrong is very disrespectful.

                                    T Offline
                                    T Offline
                                    TheGreatAndPowerfulOz
                                    wrote on last edited by
                                    #24

                                    Marc doesn't need any help defending himself. He's got cred.

                                    If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                                    You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                                    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

                                    P 1 Reply Last reply
                                    0
                                    • T TheGreatAndPowerfulOz

                                      Marc doesn't need any help defending himself. He's got cred.

                                      If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                                      You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                                      Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

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

                                      He's also got me. I'll go all Krav Maga on anyone who disses my main man.

                                      T 1 Reply Last reply
                                      0
                                      • P Pete OHanlon

                                        He's also got me. I'll go all Krav Maga on anyone who disses my main man.

                                        T Offline
                                        T Offline
                                        TheGreatAndPowerfulOz
                                        wrote on last edited by
                                        #26

                                        Shields down! Deactivate waepons! At ease! Sounds like you need extended shore leave.

                                        If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                                        You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                                        Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

                                        P 1 Reply Last reply
                                        0
                                        • T TheGreatAndPowerfulOz

                                          Shields down! Deactivate waepons! At ease! Sounds like you need extended shore leave.

                                          If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                                          You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                                          Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

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

                                          Sounds like a plan to me.

                                          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