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. In defense of spaghetti code. *ducks*

In defense of spaghetti code. *ducks*

Scheduled Pinned Locked Moved The Lounge
designhardwarehelpquestion
150 Posts 34 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.
  • E Eusebiu Marcu

    Well, that's the thing! His decision is a bad one (statistically) and hopes that the next phase will pay for the this one because he always thought there will be no other or the changes will be so big that the client will agree with a new code. Do you still think he was spot on? :laugh:

    Eusebiu

    H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #119

    My decision would be a bad one if I was writing business software on a team, for an enterprise. Fortunately, I found work that pays better and isn't mind numbing. But the priorities are different. If I was making bad decisions I wouldn't be nearly as successful as I am. I think you have an unrealistic view of your own position and how "right" you are.

    To err is human. Fortune favors the monsters.

    E 1 Reply Last reply
    0
    • H honey the codewitch

      I ran into an issue recently on a professional embedded project, and that was this: In translating the flow diagrams to code, there were so many conditions around state changes and such that my options were to either abstract the flow with some sort of generalized framework, or cook some spaghetti code. I chose the latter. Why? Simple. The actual effort if anything would be about equal, or favor the spaghetti approach. More importantly, progress remains visible with the spaghetti approach rather than the abstract flow framework which requires a lot of up front design and work without progress visible to the client. Finally, this is embedded code, where a rewrite is maybe a grand or two $USD, on the outside, assuming not a lot of reuse. It would cost at least half that to develop a simple framework, which might make things more maintainable, but questionable in terms of how effortlessly one can make changes (whereas maintainability is more about stepping away for a month and being able to pick it up again, mostly - or someone else picking up your code). It's all a matter of robbing peter to pay paul. The bottom line here is that while we may chase perfect code, and "best practices" that's not always the most effective technique for keeping the lights on. Flame away.

      To err is human. Fortune favors the monsters.

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

      It's not "spaghetti code", it's "Flow Diagram code". An easy 1:1 direct conversion. As long as the customer continues to use a Flow (aka State) Diagram as the documentation, then it's Knex spaghetti for the win! Naming the `goto` junction points is hard, but then naming is hard anyway. Customer is likely to adopt your naming anyway if they haven't already named things (states) :rolleyes: .

      H 1 Reply Last reply
      0
      • H honey the codewitch

        This is the lounge. It's not a programming instruction forum. My post wasn't here to be helpful. I was simply making an observation about coding practices and how they aren't always applicable. One you clearly don't agree with.

        To err is human. Fortune favors the monsters.

        E Offline
        E Offline
        Eusebiu Marcu
        wrote on last edited by
        #121

        I don't think an honest senior developer would agree with such a coding practice - i.e. spaghetti code - except very specific situations (like legacy, minimal change, etc.) - which do not apply to your post. So, yes, we can agree that they aren't always applicable (especially when no one will use that) :doh: . You either looked for validation (for whatever reason) or just wanted to waste some time... :)

        Eusebiu

        H 1 Reply Last reply
        0
        • P PhilipOakley

          It's not "spaghetti code", it's "Flow Diagram code". An easy 1:1 direct conversion. As long as the customer continues to use a Flow (aka State) Diagram as the documentation, then it's Knex spaghetti for the win! Naming the `goto` junction points is hard, but then naming is hard anyway. Customer is likely to adopt your naming anyway if they haven't already named things (states) :rolleyes: .

          H Offline
          H Offline
          honey the codewitch
          wrote on last edited by
          #122

          I'm inclined to agree with this. That said, I still feel spaghetti applies in as much as the code jumps around, and sometimes fires off one thing, which causes another thing, which makes the final result. It's hard to follow without a diagram.

          To err is human. Fortune favors the monsters.

          P 1 Reply Last reply
          0
          • H honey the codewitch

            My decision would be a bad one if I was writing business software on a team, for an enterprise. Fortunately, I found work that pays better and isn't mind numbing. But the priorities are different. If I was making bad decisions I wouldn't be nearly as successful as I am. I think you have an unrealistic view of your own position and how "right" you are.

            To err is human. Fortune favors the monsters.

            E Offline
            E Offline
            Eusebiu Marcu
            wrote on last edited by
            #123

            honey the codewitch wrote:

            My decision would be a bad one if I was writing business software on a team, for an enterprise.

            Not necessarily - writing good software requires skills - you might not have them, for all we know (and ofc we don't). But so far the ONLY argument that you gave is cost (having the hope the final decision will be to scrap the code). Well, for that simple thing you shouldn't write the OP - I wrote it in less than 20 words... :laugh:

            Eusebiu

            H 1 Reply Last reply
            0
            • E Eusebiu Marcu

              I don't think an honest senior developer would agree with such a coding practice - i.e. spaghetti code - except very specific situations (like legacy, minimal change, etc.) - which do not apply to your post. So, yes, we can agree that they aren't always applicable (especially when no one will use that) :doh: . You either looked for validation (for whatever reason) or just wanted to waste some time... :)

              Eusebiu

              H Offline
              H Offline
              honey the codewitch
              wrote on last edited by
              #124

              The lounge is the proverbial water cooler. If you're posting here you're not working. Whether or not it's a "waste of time" is in the eye of the beholder. And for the record, I wasn't hired as a senior developer. I was hired as a consultant. So a lot of those decisions you thought weren't mine to make were precisely why I was hired - to make them. The problem with coming at something from the outside and criticizing it out of the gate is you put yourself in a position where you have to criticize a situation you don't fully understand, and that rarely ends up making one look good, in practice.

              To err is human. Fortune favors the monsters.

              E 1 Reply Last reply
              0
              • E Eusebiu Marcu

                honey the codewitch wrote:

                My decision would be a bad one if I was writing business software on a team, for an enterprise.

                Not necessarily - writing good software requires skills - you might not have them, for all we know (and ofc we don't). But so far the ONLY argument that you gave is cost (having the hope the final decision will be to scrap the code). Well, for that simple thing you shouldn't write the OP - I wrote it in less than 20 words... :laugh:

                Eusebiu

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #125

                If my profile here was good enough to get me scouted professionally, it's good enough here for you to assess my skills. I think it's height of hubris to turn a disagreement about practices into a referendum on your debate opponent's skills in the field. David Dunning made his career off people who engage in nonsense like that, but you do you. :)

                To err is human. Fortune favors the monsters.

                E 1 Reply Last reply
                0
                • H honey the codewitch

                  The lounge is the proverbial water cooler. If you're posting here you're not working. Whether or not it's a "waste of time" is in the eye of the beholder. And for the record, I wasn't hired as a senior developer. I was hired as a consultant. So a lot of those decisions you thought weren't mine to make were precisely why I was hired - to make them. The problem with coming at something from the outside and criticizing it out of the gate is you put yourself in a position where you have to criticize a situation you don't fully understand, and that rarely ends up making one look good, in practice.

                  To err is human. Fortune favors the monsters.

                  E Offline
                  E Offline
                  Eusebiu Marcu
                  wrote on last edited by
                  #126

                  honey the codewitch wrote:

                  I was hired as a consultant

                  The client might think it hired you as a consultant, but you didn't behave like one as you took all the decisions without consulting with him... that's consulting 101. But what do we know?! We are not consultants... :wtf: Also, as mentioned 100 times already... I already said we don't know the full picture! But the one you're paint is looking... a bunch of spaghetti. See what I did there?! :laugh:

                  Eusebiu

                  H 1 Reply Last reply
                  0
                  • H honey the codewitch

                    I'm inclined to agree with this. That said, I still feel spaghetti applies in as much as the code jumps around, and sometimes fires off one thing, which causes another thing, which makes the final result. It's hard to follow without a diagram.

                    To err is human. Fortune favors the monsters.

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

                    It's a 'source of truth' problem. A well labelled complete flow diagram pre-defines the structure. Meanwhile a rambling weasel word requirements document is, well, rarely complete, even conceptually. So, for A very comprehensive and precise spec | CommitStrip[^] ...

                    1 Reply Last reply
                    0
                    • E Eusebiu Marcu

                      honey the codewitch wrote:

                      I was hired as a consultant

                      The client might think it hired you as a consultant, but you didn't behave like one as you took all the decisions without consulting with him... that's consulting 101. But what do we know?! We are not consultants... :wtf: Also, as mentioned 100 times already... I already said we don't know the full picture! But the one you're paint is looking... a bunch of spaghetti. See what I did there?! :laugh:

                      Eusebiu

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #128

                      You're making a lot of assumptions about what I have and haven't discussed with my client. I mean, it's fun to write fan fiction, but I think you could find a more engaging topic to tell stories about.

                      To err is human. Fortune favors the monsters.

                      E 1 Reply Last reply
                      0
                      • H honey the codewitch

                        If my profile here was good enough to get me scouted professionally, it's good enough here for you to assess my skills. I think it's height of hubris to turn a disagreement about practices into a referendum on your debate opponent's skills in the field. David Dunning made his career off people who engage in nonsense like that, but you do you. :)

                        To err is human. Fortune favors the monsters.

                        E Offline
                        E Offline
                        Eusebiu Marcu
                        wrote on last edited by
                        #129

                        honey the codewitch wrote:

                        David Dunning made his career off people who engage in nonsense like that

                        Indeed, like everything you write, as you correctly pointed out, is nonsense (dude, your words, not mine!). :laugh: Now I'm just having fun with you - it was clear like 5 posts ago that you cannot be 'brought' on the straight path - and the fact that you said you are not a senior developer but a consultant, it's precious! :laugh:

                        Eusebiu

                        H 1 Reply Last reply
                        0
                        • E Eusebiu Marcu

                          honey the codewitch wrote:

                          David Dunning made his career off people who engage in nonsense like that

                          Indeed, like everything you write, as you correctly pointed out, is nonsense (dude, your words, not mine!). :laugh: Now I'm just having fun with you - it was clear like 5 posts ago that you cannot be 'brought' on the straight path - and the fact that you said you are not a senior developer but a consultant, it's precious! :laugh:

                          Eusebiu

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #130

                          Ah condescending stuff! Real professional. I'm not going to continue this, because I have standards for the types of discussions I'm willing to engage in. You have a great day!

                          To err is human. Fortune favors the monsters.

                          E 2 Replies Last reply
                          0
                          • H honey the codewitch

                            You're making a lot of assumptions about what I have and haven't discussed with my client. I mean, it's fun to write fan fiction, but I think you could find a more engaging topic to tell stories about.

                            To err is human. Fortune favors the monsters.

                            E Offline
                            E Offline
                            Eusebiu Marcu
                            wrote on last edited by
                            #131

                            I've asked you already if you discussed with the client or not... if you cannot keep up, just quit! :laugh:

                            Eusebiu

                            1 Reply Last reply
                            0
                            • H honey the codewitch

                              Ah condescending stuff! Real professional. I'm not going to continue this, because I have standards for the types of discussions I'm willing to engage in. You have a great day!

                              To err is human. Fortune favors the monsters.

                              E Offline
                              E Offline
                              Eusebiu Marcu
                              wrote on last edited by
                              #132

                              :laugh: :laugh: :laugh: Your words, dude, your words! I just pointed them out... You are too sensitive for a consultant! The same with that remark earlier from the other guy that pointed out that some think they are senior but really are not...

                              Eusebiu

                              1 Reply Last reply
                              0
                              • H honey the codewitch

                                Ah condescending stuff! Real professional. I'm not going to continue this, because I have standards for the types of discussions I'm willing to engage in. You have a great day!

                                To err is human. Fortune favors the monsters.

                                E Offline
                                E Offline
                                Eusebiu Marcu
                                wrote on last edited by
                                #133

                                And BTW, I wonder if your team members would say that you are real professional or condescending (if they find out) that, in our opinion, you are the ONLY one that delivers on time and on budget. So, I would refrain myself from these expressions when I would embody them... If you cannot take a joke, it's your problem, not mine! :^)

                                Eusebiu

                                1 Reply Last reply
                                0
                                • E Eusebiu Marcu

                                  That's exactly what OP is doing! He keeps the price/cost low by writing spaghetti code, hoping that the client will agree with a new code which will contain (guess what?) abstractions :laugh: or the spec will change so much that it will make the code obsolete. You, on the other hand, were at least honest and told the client the reality! The fact that they had the experience with the 3 devs which delivered a bad quality software (in development terms) which now will cost the client multiple times the initial estimate just proves that bad software will always be bad. Ofc it will not agree with your estimates if it had that experience with the peanuts developers and working software (which is exactly the same as the current OP phase - the only difference will come in the case the investors/client will not use the code anymore and then he optimized $500 and the client invested many thousands or tens of thousands)! :laugh:

                                  Eusebiu

                                  J Offline
                                  J Offline
                                  jkirkerx
                                  wrote on last edited by
                                  #134

                                  This job came as a small upgrade, to develop a pricing curve during construction, or a nuisance markup each time the customer changed their mind, that I quoted for $2500 USD. But they expressed interest in upgrading the application, and asked how much I think it would cost, so I thought about for about 3 minutes and said $250K USD and that's on the cheap, take it to a real code shop with lots of programmers in a shiny glass building and your looking at $750K to a $1M. In fact, I'm not even sure if a real shop would accept this project, they would probably laugh at it. During this small project, their original code kept crashing their web server, so they outsourced the web server to a company, that laughed at the code, said it was dangerous, and placed this web server in a dark corner and isolated it off their main network. Then told them if they don't upgrade the app, they will kick it out. I wasn't looking to make a sale from this, because I already make money doing other things, but I felt sorry for them, as this was their main app, and they can't do construction without it. And because I was a construction contractor for over 15 years, I understood construction, so we agreed on the deal. As I got to the end, I started running the numbers, and discovered that they were lied to, and that the app didn't calculate like the original programmers said it did, and they were losing money on jobs, and didn't need the original job I was hired to do. So I'm now in the process of drilling down on the math for every item, and providing generated proof files. The way I see it, if your selling $18M of construction jobs a year, $250K+ is a small price to pay to confirm your not losing money. So back to my thought on the original post here, which has now changed ... Or is it now a question ... Was the ops decision based on code and best practices, or was it a decision based on best business practice, and did the op look at the macro level of the project as a whole, in terms of how much revenue or cash this component can generate for investors and share holders. Or did the op look at this at the micro level, of just being a component that can bring in some personal revenue, and maybe a little bit more down the road. This is where rogue programmers need to learn some more skills in addition to software engineering.

                                  If it ain't broke don't fix it Discover my world at jkirkerx.com

                                  E 1 Reply Last reply
                                  0
                                  • J jkirkerx

                                    This job came as a small upgrade, to develop a pricing curve during construction, or a nuisance markup each time the customer changed their mind, that I quoted for $2500 USD. But they expressed interest in upgrading the application, and asked how much I think it would cost, so I thought about for about 3 minutes and said $250K USD and that's on the cheap, take it to a real code shop with lots of programmers in a shiny glass building and your looking at $750K to a $1M. In fact, I'm not even sure if a real shop would accept this project, they would probably laugh at it. During this small project, their original code kept crashing their web server, so they outsourced the web server to a company, that laughed at the code, said it was dangerous, and placed this web server in a dark corner and isolated it off their main network. Then told them if they don't upgrade the app, they will kick it out. I wasn't looking to make a sale from this, because I already make money doing other things, but I felt sorry for them, as this was their main app, and they can't do construction without it. And because I was a construction contractor for over 15 years, I understood construction, so we agreed on the deal. As I got to the end, I started running the numbers, and discovered that they were lied to, and that the app didn't calculate like the original programmers said it did, and they were losing money on jobs, and didn't need the original job I was hired to do. So I'm now in the process of drilling down on the math for every item, and providing generated proof files. The way I see it, if your selling $18M of construction jobs a year, $250K+ is a small price to pay to confirm your not losing money. So back to my thought on the original post here, which has now changed ... Or is it now a question ... Was the ops decision based on code and best practices, or was it a decision based on best business practice, and did the op look at the macro level of the project as a whole, in terms of how much revenue or cash this component can generate for investors and share holders. Or did the op look at this at the micro level, of just being a component that can bring in some personal revenue, and maybe a little bit more down the road. This is where rogue programmers need to learn some more skills in addition to software engineering.

                                    If it ain't broke don't fix it Discover my world at jkirkerx.com

                                    E Offline
                                    E Offline
                                    Eusebiu Marcu
                                    wrote on last edited by
                                    #135

                                    jkirkerx wrote:

                                    The way I see it, if your selling $18M of construction jobs a year, $250K+ is a small price to pay to confirm your not losing money.

                                    As always, depends. If they would have seen it as you did, then yes! If they still trust the old guys, then... no! :)

                                    jkirkerx wrote:

                                    Was the ops decision based on code and best practices, or was it a decision based on best business practice

                                    After a long discussion the ONLY (like the only one and no other, especially technical - don't know why he mentioned embedded... I guess to build some sort of aura over it) argument OP came up with was financials with a little bit of narcisism (I am the only one that delivers on time/on budget, I know better the project etc.; ofc, there are other points of discussions since he said he coded from the beginning which raises other questions but will ignore those), thinking that whatever he build now will be scraped in the future (because phase 1 was scrapped) and redone correctly when the real money comes in. At a high level, it makes sense if you are sure of that outcome though why would someone pay you once to write some bad code (that works nevertheless) and then pay you again to write the good code? I can understand that phase 1 might have changed so much... but also phase 2? :wtf:

                                    Eusebiu

                                    J 1 Reply Last reply
                                    0
                                    • E Eusebiu Marcu

                                      Indeed! My question exactly to the OP... he didn't bother to answer it because the answer is obvious! I guess the client had some bad luck with some previous devs and now he trusts him completely since he's delivering an end result to some expectations, not knowing what's underneath mainly because it thinks/hopes that whatever comes next doesn't need whatever OP is delivering... which is kind of stupid but who knows... LE: and you know what will happen? After the investors will give them some money, the client will not agree a refactoring/recoding (because it works! why should we rewrite it?!) and OP will either quit or work on his free time... :))

                                      Eusebiu

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

                                      I don't think you're hearing me man. The story doesn't add up. The answer is obvious, but not in the way you're suggesting. None of this has to do with working in free time to make up for anything. I'm stating that even if the project isn't not important, there's a level of competency we should live up to. Why we're getting away from this point, I don't know.

                                      Jeremy Falcon

                                      1 Reply Last reply
                                      0
                                      • E Eusebiu Marcu

                                        jkirkerx wrote:

                                        The way I see it, if your selling $18M of construction jobs a year, $250K+ is a small price to pay to confirm your not losing money.

                                        As always, depends. If they would have seen it as you did, then yes! If they still trust the old guys, then... no! :)

                                        jkirkerx wrote:

                                        Was the ops decision based on code and best practices, or was it a decision based on best business practice

                                        After a long discussion the ONLY (like the only one and no other, especially technical - don't know why he mentioned embedded... I guess to build some sort of aura over it) argument OP came up with was financials with a little bit of narcisism (I am the only one that delivers on time/on budget, I know better the project etc.; ofc, there are other points of discussions since he said he coded from the beginning which raises other questions but will ignore those), thinking that whatever he build now will be scraped in the future (because phase 1 was scrapped) and redone correctly when the real money comes in. At a high level, it makes sense if you are sure of that outcome though why would someone pay you once to write some bad code (that works nevertheless) and then pay you again to write the good code? I can understand that phase 1 might have changed so much... but also phase 2? :wtf:

                                        Eusebiu

                                        J Offline
                                        J Offline
                                        jkirkerx
                                        wrote on last edited by
                                        #137

                                        Eusebiu Marcu wrote:

                                        (I am the only one that delivers on time/on budget, I know better the project etc.;

                                        I hear that from my car mechanic friend that works at a Porsche dealership. And my construction contractor friends as well. It is a pretty important track record to keep, as a contractor being considered for hire. I pay myself first, 2 hours a day 7 days a week, to learn some new skills. First being economics, 2nd - How money really works, 3rd - how to invest and manage my investments and assets, and now Rich Dad Poor Dad, 2 chapters left, learning the difference between assets and expenses, how the rich stay rich. Overall in the end, the op is on his journey of learning and mastering his skills, trying to get to the next level which usually leads to higher pay or salary, and a higher quality of life, and I can appreciate that. But one day he will have to figure out the money part, like take a step back on this skill and open the door to another skill that he can use personally to enhance his wealth. After reading Rich Dad Poor Dad, my new training says to offer respect to the op, and perhaps just offer better guidance if he's willing to learn.

                                        If it ain't broke don't fix it Discover my world at jkirkerx.com

                                        E 1 Reply Last reply
                                        0
                                        • H honey the codewitch

                                          I ran into an issue recently on a professional embedded project, and that was this: In translating the flow diagrams to code, there were so many conditions around state changes and such that my options were to either abstract the flow with some sort of generalized framework, or cook some spaghetti code. I chose the latter. Why? Simple. The actual effort if anything would be about equal, or favor the spaghetti approach. More importantly, progress remains visible with the spaghetti approach rather than the abstract flow framework which requires a lot of up front design and work without progress visible to the client. Finally, this is embedded code, where a rewrite is maybe a grand or two $USD, on the outside, assuming not a lot of reuse. It would cost at least half that to develop a simple framework, which might make things more maintainable, but questionable in terms of how effortlessly one can make changes (whereas maintainability is more about stepping away for a month and being able to pick it up again, mostly - or someone else picking up your code). It's all a matter of robbing peter to pay paul. The bottom line here is that while we may chase perfect code, and "best practices" that's not always the most effective technique for keeping the lights on. Flame away.

                                          To err is human. Fortune favors the monsters.

                                          N Offline
                                          N Offline
                                          Norm Powroz
                                          wrote on last edited by
                                          #138

                                          While I have written, or tried to write, well-structured code for over 45 years, there was a time when I had no choice. I was dealing with making changes to the mainframe operating system, a beast in which the non-resident portions were in pages of 384 memory words in length. This was in the days when a 64K machine was considered fairly large. Not only was it spaghetti code, one of the standard tricks was to overwrite the memory used by the housekeeping and initialization code in order to use it as storage. After all, if that code was only ever executed once, then after it ran it was simply occupying space for no good reason. This, of course, was all done in assembler, and predated the use of read-only memory, so writing self-modifying code was not only de rigueur, it was a talent you had to learn and be good at. Little of that code ever got well commented, but that was the way we rocked.

                                          J 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