Being pressured to GOTO the dark-side

前端 未结 10 881
我在风中等你
我在风中等你 2020-12-23 16:21

We have a situation at work where developers working on a legacy (core) system are being pressured into using GOTO statements when adding new features into existing code tha

相关标签:
10条回答
  • 2020-12-23 16:43

    The reality of development is that despite all the flowery words about doing it the right way, most clients are more interested in doing it the fast way. The concept of a code base rapidly moving towards the point of imploding and the resulting fallout on their business is something that they cannot comprehend because that would mean having to think beyond today.

    What you have is just one example. How you stand on this will dictate how you do development in the future. I think you have 4 options:

    1. Accept the request and accept that you will always be doing this.

    2. Accept the request, and immediately start looking for a new job.

    3. Refuse to do and and be prepared to fight to fix the mess.

    4. Resign.

    Which option you choose is going to depend on how much you value your job and your self esteem.

    0 讨论(0)
  • 2020-12-23 16:47

    This is the classic "management" vs. "techies" conflict.

    In spite of being on the "techie" team, over the years I have settled firmly the "management" side of this debate.

    There are a number of reasons for this:

    1. It's quite possible to have well written easy to read properly structured programs with gotos! Ask any assembler programmer; conditional branch and a primitive do loop are all they have to work with. Just because the "style" is not current and doesn't mean its not well written.

    2. If it is a mess then its going to be a real pain to extract the busines rules you will need if you are going for a complete re-write, or, if you are doing a technical refactoring of the program you will never be sure the behaviour of the refactored program is "correct" i.e. it does exactly what the old program does.

    3. Return on investment -- sticking to the original programming style and making minimal changes will take minimum effort and quickly statisfy the customers request. Spending a lot of time and effort refactoring will be more expensive and take longer.

    4. Risk -- rewrites and refactoring are hard to get right, extensive testing of the refactored code is required and things that look like "bugs" may have been "features" as far as the customer is concerned. A particular problem with "improving" legacy code is that business users may have well established work arounds that depend on a bug being there, or, exploit the existense of a bugs to change the business procedures without informing the IT department.

    So all in all management is faced with a decision -- "add one little goto" test the change and get it into production in double quick time with little risk -- or -- go in for a major programming effort and have the business scream at them when a new set of bugs crops up.

    And if you do decide to refactor in five years time some snotty nosed college graduate will be moaning that your refactored program is not buzzword compliant any more and demanding he be allowed to spend weeks rewriting it.

    If it ain't broke dont fix it!

    PS: Even Joel thinks this is a bad idea: things you should never do

    Update!-

    OK if you want to refactor and improve the code you need to go about it properly.

    The basic problem is you are saying to the client is "I want to spend n weeks working on this program and, if everything goes well, it will do exactly what it does now." -- this is a hard sell to say the least.

    You need to gather long term data on the number of crashes and outages, the time spent analysing and programming seemingly small changes, the number of change requests that were not done because they were too hard, business opertunities lost because the system could not change fast enough. Also gather some acedemic data on the costs of maintaing well structured programs vs. letting it sink.

    Unless you have a watertight case to present to the beancounters you will not get the budget. You really have to sell this to the business management, not, your immediate bosses.

    0 讨论(0)
  • 2020-12-23 16:48

    How many bugs have been introduced because of incorrectly written GOTOs? How much money did they cost the company? Turn the issue into something concrete, rather than "this feels bad". Once you can get it recognized as a problem by the people in charge, turn it into a policy like, "no new GOTOs for anything except simplifying the exit logic for a function", or "no new GOTOs for any functions that don't have 100% unit test coverage". Over time, tighten the policies.

    0 讨论(0)
  • 2020-12-23 16:48

    Unfortunately the language this is written in doesn't have any ready made refactoring tools

    Don't you have editors with macro capabilities? Don't you have shell scripts? I've done tons of refactoring over the years, very little of it with refactoring browsers.

    0 讨论(0)
提交回复
热议问题