- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Building a business case for a project like this is fundamental. You need to clarify the risks of the looming train wreck in terms of sales $ lost, lost productivity to address the collapse of the system, etc. In other words, "If we don't do this, here are the possible outcomes."
All too often, a business case with defensible numbers is deferred, and the project gets rejected.
Admin
That's brilliant! It's like a binary-tree of elseif!
I'd create a new table to handle the special conditions. As for the invoice data, archived records should NEVER depend on code. Those invoices are something that should be converted into some sort of static format (pdf/rtf/html/jpg/xml/table/emf, take your pick, there's a whole world of them), regardless of the space it would take up. There have been many instances where I've had to rewrite entire modules to prevent this sort of performance rot, and as long as the front end remains entirely unaffected (save for a speed boost), management doesn't really care. Sometimes they don't even notice. Huh. I have a really thankless job. :(
Admin
Spoken like someone on the fast-track to management!
Admin
Admin
Sadly, there's still a lot of folks who believe Complexity Demonstrates Intelligence. sigh
Admin
Admin
Admin
You dinna tell him long it really would take, didja laddie? You'll never get a reputation as a miracle worker that way!
Admin
Ah managing expectations, now that's a useful skill.
Admin
If this is code cancer, then the developer(s) responsible are carcinogens. Does this mean we could get the FDA to ban them inclusion in software projects?
Admin
This is called diarrhea.
Admin
Or maybe it was just a matter of the writer not understanding English enough to compose a piece in it... Oh well.
Admin
If he had raised this in a developer meeting, would it have gained project time? Could he have proposed a project to retool the entire shopping cart? I get the feeling there weren't even proper developer meetings in this shop, so probably no way to propose projects other than go to your manager
Which. Is. What. He. Did.
Admin
context Well that was taken out of...
I'd also point out that "the important thing about invoices is that they must be immutable" means the invoices themselves should be immutable not the code that creates them.
Admin
OK. Management is not always as easy as it looks. But: Even if its Boss's decision was right to not to touch the running system, you need to have an idea what you want to do if the system is really slowing down and your customers can not order anything because the transaction runs out before the elseifs are processed...
Some times managers are very surprised if this problem comes up. They do not remember the day when Simon proposed this two solutions. Instead they make Simon work out another solution which is really ugly again and should be finished by next morning. :-)
Admin
TRWTF is that invoices SHOULD be immutable. Generate once from data. Then they should never be allowed to change, so you must store them in an unchangeable format. They just should be static no matter what. They are historical documents now. Regenerating them each time from scratch just to view them is incredibly moronic and too easy to break.
Admin
The solution here is obvious. Rather than keep all the elsifs like that, replace it with a database table that looks up an order ID number (or a range, as in this case) and returns multiple results, in order. Then simply loop through them, eval()ing the result each time to determine if they match an additional criterion (like the TLD shown in the example). If not, keep moving.
This way you only execute all the branches that might conceivably match.
Admin
My normal approach is to raise a defect in the tracking system "System beginning to run slow, investigate and resolve" Then assign it to manager and wait for it to be dished out..
Admin
Totally agree with the manager with this one. And I've experienced this so many times.
Most of the time, these situations involve coders dealing with what they deem "inelegant" code, and itch to deliver their own genius solution to the problem. However, half the time it breaks the existing solution, and causes more problems.
So what if its going slower and slower? Something that works is better than something that's broken. Worst case scenario is you'd need a better server to deal with the increased processing.
Admin
I guess if your clients are fine that you are hosting their application on NT and SQL 6.5 on a $15,000 dollar server then, yeah, sure don't bother.
Admin
Another WTF is that the story seems to indicate that the manager and the coder don't respect each other. A company is more than a revenue machine; it is people!
They both need to sit down together and work out the whole situation. The company doesn't benefit when good coders leave; coders don't become better coders by getting angry at management.
People aren't cogs.
Admin
Simon definitely gave up too easily. The fact that he left the room "defeated" when asked why they should fix the code would only show the manager that he doesn't really believe it's such an important issue, even if he does. So yes, when the whole thing collapses no-one's going to remember that he tried to, because he didn't.
BTW: http://www.urbandictionary.com/define.php?term=Code%20Cancer enjoy.
Admin
Admin
Whether it's affecting revenue or not depends on whether it's being annoying to customers, which isn't something listed. The story doesn't say exactly what was happening, only that the software was slow and getting slower. If it gets too slow, the company has to pay for extra servers, which isn't the end of the world, but an expense nonetheless. What is clear is that any problems were only going to get worse, and probably would wind up affecting revenue and productivity.
It may also be that Simon had leeway for some initiative in his job. Not everybody is a code slave chained to their computer and programming to the beat of a large drum, you know. Not everybody has their schedule completely full of tasks they are ordered to do.
So, the WTF was not that management didn't go with Simon's solution (which may have been the right thing), but that they didn't see any need to improve the situation. This may have been one of those companies that thinks that looking ahead two quarters is long-range planning; certainly one with a strategic vision would have made some plan to replace the mess.
Admin
How about parallel processing?
Split the code into 4 and run each request concurrently. If there's no result for server 1, look at already completed result for server 2, etc.
Admin
Admin
All the elseifs may be a WTF, but not nearly as large a WTF as wanting to replace the existing (working, albeit slow) invoice lookup infrastructure with a bunch of PDFs. That, my dear boy, is not an improvement.
Admin
is wrong as hell. cpu speed isn't doubling every 18 months anymore and irrelevant - tossing hardware at bad architecture is a bandaid on a GSW. fix you goddamn code.
another bandaid. What's so hard about loading offers from the DB?
My current work does this. There's some level of justification - things can change, given that it's not a thing in a box, but a service at a future time, but we don't store the thing in any one place. It's regenned every time.
How is this simpler than loading product info from the DB? Store historical data in a denormed form based on copies of what the data was at time of purchase and hold on to it for 5 years, or whatever required time period it is.
Admin
Admin
Oops ... I mean:
Admin
Admin
Keeping a system like that in place means losing money, and likely in a way that is not detected by ordinary means. What management is supposed to be payed for is, among other things, evaluate situation like these. Saying "it works, there's no need to change it" really means giving on evaluating the pros and the cons, so giving up on doing your freaking job. The real WTF is that, day after day, this kind of thought becomes more and more accepted, even by programmers.
Admin
CYA
Admin
CYA
Admin
What happens if ($invoice->date < $revisedBySimonDate) is FileNotFound
Admin
If it's getting slower at a linear rate while machines are getting faster at an exponential rate, you just don't have a problem.
Admin
I for a fact know that about 35-40% of my national electricity grid is controlled by a machine running NT SP3 because the software doesn't work on newer systems and the original developer is gone since 2000 and nobody knows what magic the application exactly does. Yes electricity production and trading (and thus pricing formulas & related math) are intertwined. They are lucky it got converted from Guilders to Euro's before the developer left.
Admin
So, to summarize, we have
1)_a group of people who based on incomplete data can conclude that it would be sheer madness to replace a system which works under any cirmcustances becuase new code must a) be buggy or b) needlessly expensive
Not to mention the non-mutually exlcusive group of people who thinks Simon was an idiot for giving up based on the conclusion of an article which is meant to be humorous.
Perhaps Simon was an idiot. Perhaps Simon quit. Perhaps Simon went on to implement a new system in his own time which he then sold to management for mucho bucks when the old one collapsed.
TRWTF is...well us.
Admin
Admin
@Management Victim,
You are dead on. I have found that in most cases, our aspirations to do code "the right way." Do not align with business need. I have come to the realization that my perception of "quality" is usually not the business's.
Businesses need functional systems. They usually don't care if that functional system is a rat's nest or a state-of-the-art IOC-driven, unit tested wonder. If it is not perfect, they still make money. When it gets unbearable, they gripe and pony up for a re-write.
In the spirit of full disclosure, you can inform the business people about quality, flexibility, maintainability, scalability, and all of the "-ilities." You can explain about technical debt. But in the end, debt of all kinds is a tool used by companies. So, many, many choose to operate in a perpetual state of technical debt, because despite poor internal quality, the systems perform well enough to allow the business to make money.
I have spent 25 years writing software, constantly studying techniques, technologies, and processes. For about 20 of those years, I was frustrated by the "short-sightedness" of the business people and my inability to find a home somewhere where they "do it right."
I found that I had to let go. Be a good influence when I can. Fully disclose risk without being "doom and gloom." And, build the best systems I can within the business need and constraints. I am a lot more relaxed now. :-)
Admin
Two unwarranted assumptions: since the act of adding an item is o(n), pricing is an n^2 op (yes, the catalog size is a variable), and there's no reason to believe the new things are being added linearly. Second thing is that processor speeds aren't going up nearly as fast as they were before.
Admin
TRWTF is that the system needed to recalculate old invoices. Compute the invoice once and store it in the database.
Admin
Yeah, same here. As it said in the article, one of the options was to export PDFs. Sounds like the best plan, since they shouldn't have to be recalculated as many people have pointed out.
The other RWTF is the sheer number of people defending the practice of keeping slow, bloated code around for no better reason than that management is too lazy to crunch the numbers on a simple cost-benefit analysis. Simon, here's my summary on what you should have thrown at your manager: If we export PDFs, we export them once, instead of recalculating every time and tying up the equipment every time. Further, by removing all the conditional code, the app runs faster by not having to process all those conditionals every time the script runs, which means we can put off a hardware upgrade.
Admin
Admin
I'm afraid our "no drinking on the job" policy prevents me from doing that.
Admin
Seems like a long-term solution as well. I doubt the else-if blocks are growing at a pace that can outstrip Moore's law.
Admin
Cancer is like O(n^2), this is only O(n), right? And if it's worked fine for 10 years, performance-wise it apparently isn't a worthwhile problem to fix now or let-alone for another decade.
If he wanted to fix it eventually, it's not like they (are going to|can) change how they do things, so porting 10000 vs. 10010 statements of code to X is not any different.
Admin
And here's TRWTF: Many admins would think the boss's question was rhetorical, just like you did.
It's not. It NEVER is, if the boss doesn't OK the work without an answer. NEVER, EVER, EVER.
Don't believe me? Go look up the definition of rhetorical.
Yes, the question should've been rhetorical, but it obviously wasn't.
Admin
FTFY. Energon cubes are from Transformers, Dilithium crystals are from Star Trek.
Admin
Too.. much.. sense.. head.. explode..