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. My dirty little coding secret

My dirty little coding secret

Scheduled Pinned Locked Moved The Lounge
javascriptcomtutorialcode-review
54 Posts 43 Posters 4 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 Pete OHanlon

    I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

    Advanced TypeScript Programming Projects

    M Offline
    M Offline
    Mycroft Holmes
    wrote on last edited by
    #26

    It is neither dirty, little nor is it secret, it seems most of us do this. I think the real trick is getting the newbie to refactor the code prior to production!

    Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

    1 Reply Last reply
    0
    • Mike HankeyM Mike Hankey

      If I'm coding in an area that is new to me I start out with, what I call learning code or POC code. Once I learn the system to my satisfaction I straighten out and optimize the code to a working state. Or abandon it and wonder what the hell I was thinking even messing with it.

      PartsBin an Electronics Part Organizer - An updated version available! JaxCoder.com

      J Offline
      J Offline
      jmaida
      wrote on last edited by
      #27

      ditto

      "A little time, a little trouble, your better day" Badfinger

      1 Reply Last reply
      0
      • N Nelek

        I agree with you. Yes, yes... you read it right ;) ;P If it is something private... it is like v0, v00, v00+ until it gets to v1 in a nice form. If it is for work... I prefer to do like (I don't remember who told it but... anyways): If I have 8 hours to chop a tree, I will spend 6 hours sharpening my axe.

        M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

        J Offline
        J Offline
        jmaida
        wrote on last edited by
        #28

        I agree also.

        "A little time, a little trouble, your better day" Badfinger

        1 Reply Last reply
        0
        • P Pete OHanlon

          I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

          Advanced TypeScript Programming Projects

          K Offline
          K Offline
          kmoorevs
          wrote on last edited by
          #29

          Pete O'Hanlon wrote:

          start with naive implementations of code while I work out how I really want it to be laid out

          I visualize it as stumbling...progress isn't usually in a straight line or graceful. :laugh:

          "Go forth into the source" - Neal Morse "Hope is contagious"

          1 Reply Last reply
          0
          • P Pete OHanlon

            I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

            Advanced TypeScript Programming Projects

            A Offline
            A Offline
            Amarnath S
            wrote on last edited by
            #30

            Old saying - First make it work. Then make it work better.

            1 Reply Last reply
            0
            • P Pete OHanlon

              I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

              Advanced TypeScript Programming Projects

              5 Offline
              5 Offline
              5teveH
              wrote on last edited by
              #31

              Yeah, I'm with you - and, it seems, the majority. I spend as little time as possible on initial code/changes. Which means I haven't made a huge commitment if I've ended up on the wrong track, or down a cul-de-sac. So it's easy to throw away some, (or all) of my work and start again. It's a bit like getting lost when you're driving somewhere. [Yeah, some of us were driving before sat-nav!] The further you travel down the wrong road, the more you resist turning back. :confused:

              1 Reply Last reply
              0
              • P Pete OHanlon

                I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                Advanced TypeScript Programming Projects

                B Offline
                B Offline
                BillWoodruff
                wrote on last edited by
                #32

                Hi. Pete, i was fortunate enough to have an improbable journey to a career as a programmer beginning after i was ~39 years old (1982), and another, not unsuccessful, non-technical career in social work/psychology and academia. Lucky to always be involved with prototyping, never shaped by whatever into top-down planning, flow-charts, Backus-Naur formalisms, Design Patterns, etc. ... of course, those are valuable, and often necessary (I learned much later). i can't imagine not bread-boarding code, trying to "divide and conquer," and create proof of concept from wiring together "mini-solutions." Of course, i "grew up" with no net, no CP, no Stackoverflow, often with documentation printed out in 3-ring binders :) i am sure when you do "clever" it is SOLID clever.

                Quote:

                Pete O'Hanlon wrote:

                We need to get better at telling new coders that this is okay.

                Yes, but how, in the time of cut-and paste from SO and CP ?

                «The mind is not a vessel to be filled but a fire to be kindled» Plutarch

                1 Reply Last reply
                0
                • P Pete OHanlon

                  I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                  Advanced TypeScript Programming Projects

                  D Offline
                  D Offline
                  Daniel Pfeffer
                  wrote on last edited by
                  #33

                  I'm shocked, shocked! Do you mean to say that your code doesn't spring from your head full-grown, like Athena from the head of Zeus? :omg: Seriously, I suspect that everyone in the software field works in the manner you describe, especially those who claim otherwise. As a rule, the products we work on are simply too complex to be planned and built in a single step. Hardware may differ. Many hardware projects are simple enough for the design and planning to be combined. Naturally, one must have the experience (i.e. have endured many failures) to be able to do this.

                  Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                  1 Reply Last reply
                  0
                  • R raddevus

                    I agree 100% "How can I know what I mean, before I see what I say?" :laugh: It is far easier to edit something that isn't so great than it is to make something up out of thin air. So, get a little down, then edit. "Do something, even if it's wrong." "It is not enough to stare up the steps, we must step up the stairs!" "Action doesn't guarantee happiness. But, there is no happiness without action!" I got a million of 'em! :laugh: "Sometimes I sits & thinks. But other times I just sits."

                    S Offline
                    S Offline
                    Southmountain
                    wrote on last edited by
                    #34

                    good to see you guy's trick here:thumbsup::thumbsup:

                    diligent hands rule....

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      Strange - I'm different. I generally try to "do it the right way" from scratch, even for one off throwaway jobs for me. Even when I was checking a prototype PCB (solder on the processor and enough ancillary bits of hardware to make it run and toggle a signal, then add a bit more and test that, ...) the code was "production quality" - if only because I got bitten too many times by throwing code together to see if hardware worked and eventually found it was the software not the hardware I was trying to debug! :laugh:

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                      S Offline
                      S Offline
                      Southmountain
                      wrote on last edited by
                      #35

                      that's top-down methodology...

                      diligent hands rule....

                      1 Reply Last reply
                      0
                      • P Pete OHanlon

                        I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                        Advanced TypeScript Programming Projects

                        D Offline
                        D Offline
                        dandy72
                        wrote on last edited by
                        #36

                        It's called refactoring, and there's nothing wrong with that. Programming is an iterative process. Any time I look at code I wrote 10 years ago, I want to rewrite it. Of course, there's some who will constantly fiddle with working code - the key is to recognize when that's what you're doing, and stop it.

                        1 Reply Last reply
                        0
                        • R Rick York

                          I often get my best ideas in the shower. It got so frequent I had one boss tell me the company should pay my water bill.

                          "They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"

                          A Offline
                          A Offline
                          Andreas Mertens
                          wrote on last edited by
                          #37

                          For me, I usually get that "aha" moment at 3:00 AM. Forget about sleep after that.... 😳

                          1 Reply Last reply
                          0
                          • N Nelek

                            I agree with you. Yes, yes... you read it right ;) ;P If it is something private... it is like v0, v00, v00+ until it gets to v1 in a nice form. If it is for work... I prefer to do like (I don't remember who told it but... anyways): If I have 8 hours to chop a tree, I will spend 6 hours sharpening my axe.

                            M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                            J Offline
                            J Offline
                            Jeremy Falcon
                            wrote on last edited by
                            #38

                            Nelek wrote:

                            Yes, yes... you read it right

                            :laugh: :laugh: :laugh:

                            Nelek wrote:

                            I will spend 6 hours sharpening my axe.

                            It just makes sense. Time and time again I've seen "spaghetti code" projects because folks don't take the time to do that.

                            Jeremy Falcon

                            1 Reply Last reply
                            0
                            • P Pete OHanlon

                              I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                              Advanced TypeScript Programming Projects

                              D Offline
                              D Offline
                              den2k88
                              wrote on last edited by
                              #39

                              I strive to write boring and basic code (to not confused with BASIC, that is a part of my past). Clever solutions are clever until they are not.

                              GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                              1 Reply Last reply
                              0
                              • L Lost User

                                Yep ... I've refactored, and factored back again. Created "new" routines I had already created (and forgot about). It's called: "Flow".

                                "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                                J Offline
                                J Offline
                                JohaViss61
                                wrote on last edited by
                                #40

                                Guilty ;) I keep refactoring till I retire. I'm a C# developer. With every new version of the language, I look at my code to see where I can 'fit it in' the new stuff. I found a module last week that I refactored 98 times in the past 3 years. :cool: My mantra is: First make it work, the refactor it till it doesn't, and finally start over. :-D

                                1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                                  Advanced TypeScript Programming Projects

                                  D Offline
                                  D Offline
                                  Derek Hunter
                                  wrote on last edited by
                                  #41

                                  My dirty little secret is that quite often I won't write functions unless that code is used exactly the same way in at least three other places. And if an existing function doesn't do exactly what I want it to I will create a new version rather than add a new parameter. Or (even worse) I will inline a copy of the entire (existing) function and modify it in the main body of my code. Why do I do this? Because after thousands of code walk-throughs I know it is easier for someone to understand a linear block of code. Every meaningful function call (i.e. a function call that changes something rather than just return something) or call-back reduces the comprehensibility of code.

                                  1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                                    Advanced TypeScript Programming Projects

                                    J Offline
                                    J Offline
                                    john morrison leon
                                    wrote on last edited by
                                    #42

                                    It is the only way innovative code ever got written. The idea starts in your head and the structure that makes it work has to be coded up fast before it falls out of your head. At this stage I don't worry about public and private, const correctness or compiler warnings. I'm just interested in getting it all connected up so I have something to run and test. Then I go back and deal with const correctness etc. because that will help with writing the rest of the code. Nobody wants to admit that there isn't much between idea in head and working code.

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      Strange - I'm different. I generally try to "do it the right way" from scratch, even for one off throwaway jobs for me. Even when I was checking a prototype PCB (solder on the processor and enough ancillary bits of hardware to make it run and toggle a signal, then add a bit more and test that, ...) the code was "production quality" - if only because I got bitten too many times by throwing code together to see if hardware worked and eventually found it was the software not the hardware I was trying to debug! :laugh:

                                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                      P Offline
                                      P Offline
                                      PhilipOakley
                                      wrote on last edited by
                                      #43

                                      There's a subtle difference between production ready, and functionally complete. It's (for me) always worth thinking through what the functionally complete (System Engineered) version could include and how it may become over complex with contradictory requirements. Sometimes there are subtle choices that lead to the death-march pit of doom while a slightly different choice would clearly signpost the sunlit uplands of future success. Then you can focus on the core element, the 'spike', where the tyres hit the road and the concepts hits the existing code, and neater approaches to the same functionality do start to emerge. Moving fast, always broken, like a bull in a china shop, is not a good look! Production ready is good, full function extendable is even better ;-)

                                      1 Reply Last reply
                                      0
                                      • P Pete OHanlon

                                        I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                                        Advanced TypeScript Programming Projects

                                        C Offline
                                        C Offline
                                        Cpichols
                                        wrote on last edited by
                                        #44

                                        I wonder how many "Me too" responses there are here. Might make a decent survey question. Me too, btw.:thumbsup:

                                        1 Reply Last reply
                                        0
                                        • P Pete OHanlon

                                          I'm not too proud to say it. I pretty much always start with naive implementations of code while I work out how I really want it to be laid out. If you see "clever" code from me, that was never my first pass at it. There's always been a lot of playing around with it beforehand as I refactor and tidy it up. We need to get better at telling new coders that this is okay. Or perhaps it's not, and I'm just setting a bad example.

                                          Advanced TypeScript Programming Projects

                                          M Offline
                                          M Offline
                                          MSBassSinger
                                          wrote on last edited by
                                          #45

                                          That is a very wise way to approach something new. It lets you get basic functionality working ( and discovering any quirks or poor performing code). Then, especially if you use a repo so you can rollback an “experiment” easily, you can build on it. Refactor functionality as necessary to keep it somewhat atomic or genericize some of the code. Yours is a useful post to start my day.

                                          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