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. Visual Basic
  4. Formatting code...

Formatting code...

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
8 Posts 5 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 Offline
    D Offline
    dawmail333
    wrote on last edited by
    #1

    Hey guys! I'm still trying to decide the best way to format my VB.Net code. I've looked over this project I've been working on for a couple of months and saw the number of different formatting/variable naming (etc) approaches I'd used, and I've decided that I'd best try to stick to one style. Can anyone recommend and easy-to-follow and neat way of formatting/laying out/variable naming my code? I hope this doesn't sound silly, but at the least, I'd like to have my code look uniform... :~ X| :doh: Awaiting replies eagerly :)

    modified on Wednesday, June 23, 2010 12:58 AM

    J L 2 Replies Last reply
    0
    • D dawmail333

      Hey guys! I'm still trying to decide the best way to format my VB.Net code. I've looked over this project I've been working on for a couple of months and saw the number of different formatting/variable naming (etc) approaches I'd used, and I've decided that I'd best try to stick to one style. Can anyone recommend and easy-to-follow and neat way of formatting/laying out/variable naming my code? I hope this doesn't sound silly, but at the least, I'd like to have my code look uniform... :~ X| :doh: Awaiting replies eagerly :)

      modified on Wednesday, June 23, 2010 12:58 AM

      J Offline
      J Offline
      Jay Royall
      wrote on last edited by
      #2

      With regards to vaiable naming its really a matter of personal style, and just as long it's easy to follow and consistent then the choice is yours. If you're after ideas then what I do is prefix all my variables with a 3 letter abbreviation. For example, String variables I prefix with 'str', booleans with 'bln', etc. But as for layout and format, if you're using Visual Studion then that should take care of it for you.

      D 1 Reply Last reply
      0
      • J Jay Royall

        With regards to vaiable naming its really a matter of personal style, and just as long it's easy to follow and consistent then the choice is yours. If you're after ideas then what I do is prefix all my variables with a 3 letter abbreviation. For example, String variables I prefix with 'str', booleans with 'bln', etc. But as for layout and format, if you're using Visual Studion then that should take care of it for you.

        D Offline
        D Offline
        dawmail333
        wrote on last edited by
        #3

        Well, you see, I kept mixing styles where I named every control starting with a 3char prefix, with a style where everything had that prefix (e.g. variable in code too), with other styles for classes. And by layouts, I can't explain exactly what I mean but... Can anyone point me to some examples of beautifully formatted VB.Net code?

        I 1 Reply Last reply
        0
        • D dawmail333

          Well, you see, I kept mixing styles where I named every control starting with a 3char prefix, with a style where everything had that prefix (e.g. variable in code too), with other styles for classes. And by layouts, I can't explain exactly what I mean but... Can anyone point me to some examples of beautifully formatted VB.Net code?

          I Offline
          I Offline
          Ian Shlasko
          wrote on last edited by
          #4

          As a hundred people, and you'll get a hundred different answers... There's no RIGHT answer, really... My personal style has spontaneously evolved to something like: Private/method variables: Camel case, no prefix (Since you can mouseover to get the type - If it's confusing, would be using extra comments anyway) Properties/Methods/Classes: Pascal case... Methods are verbs, classes and properties are nouns (Except boolean properties, which are named like IsBold, CanCalculate, etc - Kinda like that convention as used in WPF) Iterator variables: I tend to use short names like "idx", "row", "col", "rec"... But I avoid single-letter names unless it's x/y/z for a coordinate system. If I end up using more than one or two at a time, I tend to give them longer names to keep it readable. As for braces, well, you're using VB, so you don't have to deal with the curly brace debate.

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

          D K 2 Replies Last reply
          0
          • D dawmail333

            Hey guys! I'm still trying to decide the best way to format my VB.Net code. I've looked over this project I've been working on for a couple of months and saw the number of different formatting/variable naming (etc) approaches I'd used, and I've decided that I'd best try to stick to one style. Can anyone recommend and easy-to-follow and neat way of formatting/laying out/variable naming my code? I hope this doesn't sound silly, but at the least, I'd like to have my code look uniform... :~ X| :doh: Awaiting replies eagerly :)

            modified on Wednesday, June 23, 2010 12:58 AM

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            I would NOT prefix variables with a couple of letters that indicate the type, since that makes type changes hard. You may start with an array of something, later turn it into a list, and afterwards decide to go for a dictionary. You then would have to rename the variables all the time. I do recommend using meaningful names, using full english words (except for very local variables), and using singular and plural as applicable, so I would write: For Each stu as Student in students :)

            Luc Pattyn


            Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.


            Local announcement (Antwerp region): Lange Wapper? Neen!


            D 1 Reply Last reply
            0
            • L Luc Pattyn

              I would NOT prefix variables with a couple of letters that indicate the type, since that makes type changes hard. You may start with an array of something, later turn it into a list, and afterwards decide to go for a dictionary. You then would have to rename the variables all the time. I do recommend using meaningful names, using full english words (except for very local variables), and using singular and plural as applicable, so I would write: For Each stu as Student in students :)

              Luc Pattyn


              Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.


              Local announcement (Antwerp region): Lange Wapper? Neen!


              D Offline
              D Offline
              dawmail333
              wrote on last edited by
              #6

              Sound advice thanks.

              1 Reply Last reply
              0
              • I Ian Shlasko

                As a hundred people, and you'll get a hundred different answers... There's no RIGHT answer, really... My personal style has spontaneously evolved to something like: Private/method variables: Camel case, no prefix (Since you can mouseover to get the type - If it's confusing, would be using extra comments anyway) Properties/Methods/Classes: Pascal case... Methods are verbs, classes and properties are nouns (Except boolean properties, which are named like IsBold, CanCalculate, etc - Kinda like that convention as used in WPF) Iterator variables: I tend to use short names like "idx", "row", "col", "rec"... But I avoid single-letter names unless it's x/y/z for a coordinate system. If I end up using more than one or two at a time, I tend to give them longer names to keep it readable. As for braces, well, you're using VB, so you don't have to deal with the curly brace debate.

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

                D Offline
                D Offline
                dawmail333
                wrote on last edited by
                #7

                The convention for naming methods etc would give my code more structure. Thanks for your advice. I tend to use x for local vars, a habit which really is nasty...

                1 Reply Last reply
                0
                • I Ian Shlasko

                  As a hundred people, and you'll get a hundred different answers... There's no RIGHT answer, really... My personal style has spontaneously evolved to something like: Private/method variables: Camel case, no prefix (Since you can mouseover to get the type - If it's confusing, would be using extra comments anyway) Properties/Methods/Classes: Pascal case... Methods are verbs, classes and properties are nouns (Except boolean properties, which are named like IsBold, CanCalculate, etc - Kinda like that convention as used in WPF) Iterator variables: I tend to use short names like "idx", "row", "col", "rec"... But I avoid single-letter names unless it's x/y/z for a coordinate system. If I end up using more than one or two at a time, I tend to give them longer names to keep it readable. As for braces, well, you're using VB, so you don't have to deal with the curly brace debate.

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

                  K Offline
                  K Offline
                  KrisnNala
                  wrote on last edited by
                  #8

                  Hi one thing I've found really useful is to not use words such as Date, Time, etc the VB uses, can muck up your code big time, as I've found out. Apart from that use variables that you will understand when looking at code 6mths down the line. I agree with alot that I use things like strBookings if a string for example. Good luck x :)

                  Kris MCP

                  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