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. Coding - so what's a crime and whats a misdemeanor?

Coding - so what's a crime and whats a misdemeanor?

Scheduled Pinned Locked Moved The Lounge
databasecombeta-testingquestion
108 Posts 38 Posters 113 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.
  • P PIEBALDconsult

    Those are not gotos. Aside: While simplifying some code this week I removed a switch (that was inside a while) ... and later realized that I hadn't removed a break that was left over. :doh: I really dislike that break operates on switch -- I hope DMR's harp gives him blisters.

    G Offline
    G Offline
    GuyThiebaut
    wrote on last edited by
    #95

    True - back when I was at university in the late 80's we were taught 'structured programming' and anything that threw you out of an iteration was forbidden, until year two when we were told that there were circumstances where there was not other option.

    “That which can be asserted without evidence, can be dismissed without evidence.”

    ― Christopher Hitchens

    P 1 Reply Last reply
    0
    • G GuyThiebaut

      True - back when I was at university in the late 80's we were taught 'structured programming' and anything that threw you out of an iteration was forbidden, until year two when we were told that there were circumstances where there was not other option.

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #96

      GuyThiebaut wrote:

      anything that threw you out of an iteration was forbidden

      But break goes only to the end, not somewhere completely different, it's structured (still prefer to avoid it though).

      1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        D.1) Storing "numbers" as integers just because they're called numbers. (Telephone numbers, social security numbers, etc.)


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #97

        Hear! Hear!

        1 Reply Last reply
        0
        • K Kevin McFarlane

          It will be in the source code history.

          Kevin

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #98

          But where? And why was it removed?

          1 Reply Last reply
          0
          • S Simon_Whale

            Code that is complex by how its written rather than by it complexity of the problem

            Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

            D Offline
            D Offline
            Dar Brett 0
            wrote on last edited by
            #99

            Reminds me of my tech leads description of my code... I still think that it's necessary to write some code using reflection to generate a JavaScript file to be added dynamically during application startup to a web optimization bundle to declare AngularJS references to some Web API Controllers so that I can save myself ten minutes of copy-pasting every few weeks when I need a new Controller.

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Was just adding something in QA and I thought: there are things no sentient coder should do these days, but every day in QA we see some halfwit doing them. So I figure we need a list of Crimes and Misdemeanors, and these are my first candidates. Misdemeanors are "smack on the head" offenses, Crimes deserve a death sentence! :laugh: Misdemeanors: A) Ignoring existing standards and modifying someone else's code "your way". Crimes: A) Storing passwords in plain text: CommitStrip[^] B) Leaving your code open to SQL Injection: XKCD[^] C) Committing code that doesn't compile. Anyone want to add to these?

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              D Offline
              D Offline
              Dar Brett 0
              wrote on last edited by
              #100

              Some crimes I've seen in the last few years: A) Introducing dependencies without checking to see if they're reliable. B) Introducing dependencies that are just a C# wrapper around a REST API. C) Deciding that automating builds/deployments isn't worth the time. D) Manually deploying changes to production without committing them to source control (after which of course you go on leave). F) Being a lead developer and insisting that all columns in a database be nullable. G) Giving full sa/admin/root permissions to someone/something because you don't know what permissions it actually needs - have to confess I've been guilty of this in the past. H) Using {PopularFramework}.js because it's popular I can't seem to think of any misdemeanours though.

              R 2 Replies Last reply
              0
              • L Lost User

                Concatenating constant-strings. Swallowing exceptions. Throwing ex; P/Invokes copied from the web when there's a managed alternative. ..would become a long list.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                R Offline
                R Offline
                Robert g Blair
                wrote on last edited by
                #101

                Well, my whole system does nothing but Throw (not Throw Ex, or Throw New Ex). At the top there is an unhandled exception handler, which: - Shows the error in a message box - On OK it closes the current program down - Waits several seconds, then - restarts the program and puts the user back to (roughly) where they were. The users prefer that, and there have been very few cases where they got stuck in a loop. When it did happen, I soon heard about it. Almost every time they got what they call a "restart", was due to some kind of service fail, LAN, DB, internet, etc. Most of which self righted fairly quickly.

                1 Reply Last reply
                0
                • P Pete OHanlon

                  I'm just waiting for the first person to put "uses JavaScript" or "uses VB".

                  R Offline
                  R Offline
                  Robert g Blair
                  wrote on last edited by
                  #102

                  The diss JavaScript people must be fairly stupid by now. And the whole dissing VB always seemed so childish. Especially from C# programmers. "Hey look at me, I code in .Net, but I'm not one of those VB cretins - I'm cool like you guys".

                  1 Reply Last reply
                  0
                  • Z ZurdoDev

                    Eddy Vluggen wrote:

                    Swallowing exceptions.

                    Some exceptions are OK to ignore. :^)

                    There are only 10 types of people in the world, those who understand binary and those who don't.

                    R Offline
                    R Offline
                    Robert g Blair
                    wrote on last edited by
                    #103

                    Not so sure. If ever that was the case, what is the downside of handling it anyway? Surely less than the downside of being wrong about that exception being able to be ignored. And always remember, in .Net you can get a huge performance whack catching and swallowing exceptions (especially DB exceptions).

                    1 Reply Last reply
                    0
                    • J Jorgen Andersson

                      D) Use GOTO. E) Systems Hungarian But I'd like to add, that you also need to know when to break the rules.

                      Wrong is evil and must be defeated. - Jeff Ello

                      R Offline
                      R Offline
                      Robert g Blair
                      wrote on last edited by
                      #104

                      More to the point: I have not seen a GoTo in the wild since VB6 - and even then only for err handling (On Err Goto). I would seriously doubt that GoTo is a real problem in any .Net shop.

                      1 Reply Last reply
                      0
                      • L Lost User

                        Committing commented-out code. I'm not sure whether it's a misdemeanor or crime though.

                        R Offline
                        R Offline
                        Robert g Blair
                        wrote on last edited by
                        #105

                        Well, I always leave the commented out code there. If I see I any commented out code more than a week old, I delete it. (because obviously the new code didn't break the system, and the old code can always be retrieved anyway) (the only reason to leave the commented out code there is, if your commits breaks the build, or crashes the app the next day, you can readily reverse the mod - and you will still remember WTF it was all about).

                        1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          I'd disagree with this: I'd far rather see validation failures causing an immediate return then over indented cr@p to avoid it:

                          int age;
                          if (!int.TryParse(tbAge.Text, out age) && age > 0 && age < 150)
                          {
                          MessageBox.Show("Age must be an integral value between 1 and 150");
                          return;
                          }
                          ...

                          int age;
                          if (!int.TryParse(tbAge.Text, out age) && age > 0 && age < 150)
                          {
                          MessageBox.Show("Age must be an integral value between 1 and 150");
                          }
                          else
                          {
                          ...

                          You can get away with that for one level, but when you are validating a dozen inputs? Return is a cleaner way to do it, IMO.

                          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                          R Offline
                          R Offline
                          Robert g Blair
                          wrote on last edited by
                          #106

                          Validation messageboxes are amateurish. And users don't like them. The input control should limit the input to what is valid only. How you signal input error to user is another issue, but its not like there aren't a plethora of tools available. In my system, usually, the control just takes on an "input error" back color (configurable, generally light pink). Where there might be confusion, a custom validation message control appears below/beside/etc the control. In red. Finally, most input error can be dispensed with by having sensible input controls. Why on earth would you let a user type in an age? Give them a list to choose from. Give them 16 to 120 for Driver licence applications. 18 to 90 for porn-site account signups. Or 0 - 15 for KidsStuff.Com signups. Etc. 90 percent of user input can be presented as things for them to choose from, rather than let the user type it. Except for text input like descriptions, reasons messages etc. In which case you can't really validate - but you must filter for SQL injection!

                          1 Reply Last reply
                          0
                          • D Dar Brett 0

                            Some crimes I've seen in the last few years: A) Introducing dependencies without checking to see if they're reliable. B) Introducing dependencies that are just a C# wrapper around a REST API. C) Deciding that automating builds/deployments isn't worth the time. D) Manually deploying changes to production without committing them to source control (after which of course you go on leave). F) Being a lead developer and insisting that all columns in a database be nullable. G) Giving full sa/admin/root permissions to someone/something because you don't know what permissions it actually needs - have to confess I've been guilty of this in the past. H) Using {PopularFramework}.js because it's popular I can't seem to think of any misdemeanours though.

                            R Offline
                            R Offline
                            Robert g Blair
                            wrote on last edited by
                            #107

                            On C) I detest fully automated Build/Deploy. Build to Dev (automatic on commit). Deploy to Test as a non-automatic function (ie, someone has to press the button). Deploy from Test to Live ditto. Whoever pressed the button has to respond to the user calls when it crashes.

                            1 Reply Last reply
                            0
                            • D Dar Brett 0

                              Some crimes I've seen in the last few years: A) Introducing dependencies without checking to see if they're reliable. B) Introducing dependencies that are just a C# wrapper around a REST API. C) Deciding that automating builds/deployments isn't worth the time. D) Manually deploying changes to production without committing them to source control (after which of course you go on leave). F) Being a lead developer and insisting that all columns in a database be nullable. G) Giving full sa/admin/root permissions to someone/something because you don't know what permissions it actually needs - have to confess I've been guilty of this in the past. H) Using {PopularFramework}.js because it's popular I can't seem to think of any misdemeanours though.

                              R Offline
                              R Offline
                              Robert g Blair
                              wrote on last edited by
                              #108

                              On F): I really don't like nullable columns. In the last couple years I have set every single column (except date columns) to NOT NULL - but always with a default value (0 for numbers, '' for strings, 0 for bit etc). I thought maybe the Default thing would slow the DB down. Nope (MS-SQL Server 2012). I figured I would discover some logic errors just as bad as Null errors. Nope. All good :)

                              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