Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Programming standards...no flaming please!

Programming standards...no flaming please!

Scheduled Pinned Locked Moved The Lounge
csharpdatabasequestion
84 Posts 36 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.
  • L leckey 0

    I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

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

    Try to keep a function to one page. A guide, not a rule however. Elaine :rose: The tigress is here :-D

    1 Reply Last reply
    0
    • L led mike

      Christian Graus wrote:

      The book that covers all of this is called Code Complete

      4 cups of coffee: $3.25 Bag of M&M peanuts: $2.49 Surfing Code Project: Free Don Miguel's comment on Code Complete[^]: Priceless There are some things money can't buy, for everything else there's Mastercard :-D

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #54

      led mike wrote:

      Don Miguel's comment on Code Complete[^]: Priceless

      Please explain what is good about that. You've posted this as being some high-quality post-of-the-year a few times, but I fail to see anything that stands out about it.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      L 1 Reply Last reply
      0
      • L leckey 0

        I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

        C Offline
        C Offline
        code frog 0
        wrote on last edited by
        #55

        109 wow. It's only 68 for me but that's the beauty of A/C. Technology should read SD someday. I just saw you were a code-chick (slang intended for humor) that's cool!:cool: So what's a leckey anyways? I'd explain code-frog but it would take about 32 years as of July 18th.:-D


        When I'm joking people take me seriously.
        When I'm serious they think I'm joking.
        I'm left to conclude my life must be a complete joke. :sigh: :laugh: :cool:

        L S 2 Replies Last reply
        0
        • L leckey 0

          Ennis Ray Lynch, Jr. wrote:

          Switch to c#

          Amen brother! I hate VB.

          Ennis Ray Lynch, Jr. wrote:

          In business applications readability and maintainability and self-documentation is more important that the absolute fastest code [in most cases].

          Like I said, it's ugly code. Not much commenting. Old code just commented out. And it is definately not that fast. If it were me I'd rewrite the entire thing.

          M Offline
          M Offline
          mr_lasseter
          wrote on last edited by
          #56

          I wonder why VB gets such a bad name? Your boss could have very easily written the same progam in C#. Last time I checked there was nothing in C# that prevents a function from being a certain number of lines or that limits the branching in a switch statement. Judging by some of the questions in C# forum, I wouldn't be surprised if you will soon see C# applications built like this. Remember not everyone that is using C# right now has a C or java background.;P Mike Lasseter

          1 Reply Last reply
          0
          • C code frog 0

            109 wow. It's only 68 for me but that's the beauty of A/C. Technology should read SD someday. I just saw you were a code-chick (slang intended for humor) that's cool!:cool: So what's a leckey anyways? I'd explain code-frog but it would take about 32 years as of July 18th.:-D


            When I'm joking people take me seriously.
            When I'm serious they think I'm joking.
            I'm left to conclude my life must be a complete joke. :sigh: :laugh: :cool:

            L Offline
            L Offline
            leckey 0
            wrote on last edited by
            #57

            I prefer Geek Girl, but Code Chick works. When I ran into other computer science students around town they would always be like, "Oh I remember you! I had class xyz with you!" I guess I was pretty memorable being the only white chick in class.:cool: leckey be part of my last name. I was one of those girls who hyphenated.

            1 Reply Last reply
            0
            • L leckey 0

              I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

              E Offline
              E Offline
              Eric Goedhart
              wrote on last edited by
              #58

              Hi, I assume you talk about a program that has to be completed and you are faced with a lot of code from others who have worked on this program before. I think that you (forget the whole program you have at this moment), should make clear what the function is of this program, what it should do, what results are expected (who will work with it) and then compare all of this with what you have when you hit F5. When this result is acceptable regarding what the software should perorm, and the overall design is ok, i would go deeper into the code, otherwise i would suggest dropping what you have right now. When you look to modern software (corporate software) 99.9 % of the expected (Visual Studio based) software is all about inserting, editing and updating or removing data in a database that runs on the Windows Operating System and can be accesed via your Windows or Internet application, or be shared over a network, and is presented to the users in a logical working relating way,so these operations can be performed. 0.1% (my quess) are difficult calculations and so on, that need special attention. When you have the main things ok i would concentrate on this 1% with your whole team, and see how far you can go in realising the task these functions have ro perform. Good luck with your project:) With friendly greetings, Eric Goedhart Skype: eric-goedhart Deep in the fundamental heart of mind and Universe there is a reason. -Slartibartfast

              1 Reply Last reply
              0
              • C code frog 0

                109 wow. It's only 68 for me but that's the beauty of A/C. Technology should read SD someday. I just saw you were a code-chick (slang intended for humor) that's cool!:cool: So what's a leckey anyways? I'd explain code-frog but it would take about 32 years as of July 18th.:-D


                When I'm joking people take me seriously.
                When I'm serious they think I'm joking.
                I'm left to conclude my life must be a complete joke. :sigh: :laugh: :cool:

                S Offline
                S Offline
                S Senthil Kumar
                wrote on last edited by
                #59

                Belated birthday wishes Rex. I should've remembered it, especially because my birthday is also July 18th :)

                Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                C 1 Reply Last reply
                0
                • L leckey 0

                  I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #60

                  The one time we had a strictly enforced limit was when I developed safety critical code - and then we put a limit on the McCabe Complexity metric[^] per sub-program (15, I think). This means that there is a strict limit on the number of decision points in the function/procedure, making understanding of said code item, easier, as well as making unit testing cheaper. The only times you could argue against the limit was when you had case statements on big enumerated types (for example, our scheduler used an enumerated type as a sort of task id and switched on that to dispatch scheduled functions).

                  1 Reply Last reply
                  0
                  • P Paul Conrad

                    leckey wrote:

                    I know...I know. It does interact with another 3rd party product that uses FORTRAN.

                    :omg:

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #61

                    Whats with the :omg: - FORTRAN is a *real* engineers language....it's actually pretty good for engineers who aren't really software people - the language is simple enough that they can write their code to do what they want...and then you can wrap the horrible Fortran in something else (Ada 95 in my case - don't ask). Of course, these days, they're more likely to design the thing in Simulink[^] and autocode it using Real Time Workshop[^]. WHich isn't necessarily any better for the software person trying to interface to their code...

                    1 Reply Last reply
                    0
                    • R Ryan Binns

                      led mike wrote:

                      Don Miguel's comment on Code Complete[^]: Priceless

                      Please explain what is good about that. You've posted this as being some high-quality post-of-the-year a few times, but I fail to see anything that stands out about it.

                      Ryan

                      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

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

                      Ryan Binns wrote:

                      I fail to see anything that stands out about it.

                      Sorry I guess you have no sense of humor. I sent the OP and Don's reply to as email to devs in my group and it kills them all. People have it pinned up to their walls along with various Dilbert strips. For me it is the funniest post so far in the Lounge (Category: Development Related) :-D

                      1 Reply Last reply
                      0
                      • L leckey 0

                        I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

                        L Offline
                        L Offline
                        leppie
                        wrote on last edited by
                        #63

                        leckey wrote:

                        I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go.

                        Thats is quite common for a generated parser.**

                        xacc.ide-0.2.0 preview - Now in 100% C# goodness

                        **

                        1 Reply Last reply
                        0
                        • L leckey 0

                          I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

                          J Offline
                          J Offline
                          Johnny Mnemonic
                          wrote on last edited by
                          #64

                          "Things should be made as simple as possible, but no simpler." -- Albert Einstein My oppinion is that good developer should not ever directly think about the number of lines , number of classes, and other such things. He should develop a good, effective, usable classes. If some function, to accomplish it's function has to be long, let it be, but only while that function's function is a single strict logical unit. One should consider refactoring if he founds that a function does more than it should, not that it is just longer or shorter than ordinary.

                          1 Reply Last reply
                          0
                          • L leckey 0

                            I wasn't really sure if this belonged to a particular message board so please no flaming! I am wondering what others habits are when it comes to programming. I just inherited a huge VB.NET program. In one VB page it has over 10k lines of code. One function within that has about half those lines. Do you have a "limit" on how big/small a function/method/class should be before breaking it into smaller parts? We just used the analyzer on this thing and found one case statement has over 70 routes to go. So I'm hoping to clean this puppy up. BTW...heat index is currently at 109 degrees. Hope everyone else is staying cool.

                            Z Offline
                            Z Offline
                            zmorris
                            wrote on last edited by
                            #65

                            You need this book: http://www.amazon.com/gp/product/0201485672/102-8688208-6140902?v=glance&n=283155 Desparately. I'm surprised no one has mentioned it yet. It is exactly what you need. Read it. Live it.

                            1 Reply Last reply
                            0
                            • L leckey 0

                              Ennis Ray Lynch, Jr. wrote:

                              Switch to c#

                              Amen brother! I hate VB.

                              Ennis Ray Lynch, Jr. wrote:

                              In business applications readability and maintainability and self-documentation is more important that the absolute fastest code [in most cases].

                              Like I said, it's ugly code. Not much commenting. Old code just commented out. And it is definately not that fast. If it were me I'd rewrite the entire thing.

                              K Offline
                              K Offline
                              K Lynn
                              wrote on last edited by
                              #66

                              leckey wrote:

                              Ennis Ray Lynch, Jr. wrote: Switch to c# Amen brother! I hate VB.

                              C# = VB.NET for C Developers :)

                              1 Reply Last reply
                              0
                              • L leckey 0

                                Ennis Ray Lynch, Jr. wrote:

                                Switch to c#

                                Amen brother! I hate VB.

                                Ennis Ray Lynch, Jr. wrote:

                                In business applications readability and maintainability and self-documentation is more important that the absolute fastest code [in most cases].

                                Like I said, it's ugly code. Not much commenting. Old code just commented out. And it is definately not that fast. If it were me I'd rewrite the entire thing.

                                H Offline
                                H Offline
                                hfmendezp
                                wrote on last edited by
                                #67

                                I have to agree... a code like that deserves to be commented and redone :)

                                1 Reply Last reply
                                0
                                • C Christian Graus

                                  If you inherited it from someone within the company, go and smack them on the head. No code file should be 10k lines. Some functions may tend to be long, but they should be refactored where-ever possible, ideally I would say 30 lines is a max for a function. The book that covers all of this is called Code Complete. If you don't own it, buy it. While I found I knew most of what it was saying, I still found it exciting to see it all in written form, with logical explanations for the benefit of people like the clown who wrote the code you're now looking at. I am however cautious about refactoring existing code, do it if you can, but beware, lest you go crazy and spend heaps of time chasing an ideal that may introduce bugs in code that already works. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                  S Offline
                                  S Offline
                                  schleprock
                                  wrote on last edited by
                                  #68

                                  applications should be decomposed so that each method or function performs one action. at the top level of the application, the action may be "populate_database". this method would then call lower level methods to perform each of the actions to populate a database where each lower level method performs a single action. strict line limitations on methods or functions is arbitrary. although i do go by the "the method should fit on my screen" guide. as far as code file size, i don't believe there is a need to limit the file size arbitrarily. we limit a file to a single class. for some of our abstract base classes, the class is pretty big to cover all the base methods. working with methods or functions that perform multiple tasks is a nightmare. in a previous life, i had the truly unfortunate nightmare of having to work with a code file that was over 80000 (yes that's eighty thousand) lines long. one function within this file was over 12000 lines long. to add insult to injury, there were goto statements in the code (it was C code) that were used for regular program execution (not error recovery). to make it even worse (which is a challenge) there was a macro with a goto statement in the file!! decomposition of the application into single actions is the way to go. schleprock

                                  1 Reply Last reply
                                  0
                                  • S S Senthil Kumar

                                    Belated birthday wishes Rex. I should've remembered it, especially because my birthday is also July 18th :)

                                    Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                                    C Offline
                                    C Offline
                                    code frog 0
                                    wrote on last edited by
                                    #69

                                    Oh yeah! That's right! To you to. Do anything especially memorable? I went rollerblading then just did work as usual. Had a great barbecue later that day though. That was fun. Watched the kids get their fill of the kiddie pool and all that.:-D


                                    When I'm joking people take me seriously.
                                    When I'm serious they think I'm joking.
                                    I'm left to conclude my life must be a complete joke. :sigh: :laugh: :cool:

                                    1 Reply Last reply
                                    0
                                    • L leckey 0

                                      Ennis Ray Lynch, Jr. wrote:

                                      Switch to c#

                                      Amen brother! I hate VB.

                                      Ennis Ray Lynch, Jr. wrote:

                                      In business applications readability and maintainability and self-documentation is more important that the absolute fastest code [in most cases].

                                      Like I said, it's ugly code. Not much commenting. Old code just commented out. And it is definately not that fast. If it were me I'd rewrite the entire thing.

                                      M Offline
                                      M Offline
                                      mcintyrg
                                      wrote on last edited by
                                      #70

                                      I have to vote in favour of the C# movement. VB is for kids :)

                                      V E 2 Replies Last reply
                                      0
                                      • C Christian Graus

                                        Ennis Ray Lynch, Jr. wrote:

                                        BTW, when I convert code bases I retype it.

                                        OK - the code bases I have changed, it's been because I took a job and found the code was VB, and indicated I only did C#. There was really no option for me to hand type them. One I've been on for two years now, and I admit I still from time to time find code that I change to better reflect what C# can do. But after a day, I had a C# code base that worked fine.

                                        Ennis Ray Lynch, Jr. wrote:

                                        Fortunately with .NET you can mix languages

                                        I thought you could only do that in ASP.NET, unless you mean mix languages between different dlls in the project, not within one project ? Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                        P Offline
                                        P Offline
                                        Paul Farry
                                        wrote on last edited by
                                        #71

                                        You can't mix languages in the IDE within 1 project, but you can mix them if you are using commandline compile. The SDK Samples provide an example on how to do this. I find it sad people say I can't do VB, I can't do C#. It's programming. It's the language is a tool. If you are going to dig a hole, you usea shovel, if you are planting a flower in the garden you use a spade. If you are excavating, you use a backhoe.

                                        C 1 Reply Last reply
                                        0
                                        • P Paul Farry

                                          You can't mix languages in the IDE within 1 project, but you can mix them if you are using commandline compile. The SDK Samples provide an example on how to do this. I find it sad people say I can't do VB, I can't do C#. It's programming. It's the language is a tool. If you are going to dig a hole, you usea shovel, if you are planting a flower in the garden you use a spade. If you are excavating, you use a backhoe.

                                          C Offline
                                          C Offline
                                          Christian Graus
                                          wrote on last edited by
                                          #72

                                          Paul Farry wrote:

                                          If you are going to dig a hole, you usea shovel, if you are planting a flower in the garden you use a spade. If you are excavating, you use a backhoe.

                                          That's true, but C# and VB.NET are the same tool, except that VB can't do unsafe code. Beyond that, the analogy breaks down, there's no other place where one is the right tool over the other. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                          P 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