I landed a php-sql customer with an existing codebase - 90% back-end.
Said codebase has:
-a lot of global variables. I mean a lot. An obscene amount.
-classes that use those global variables
-include files coming from everywhere assigning values to them based on god knows what
-uses namespaces just for fun because he doesn't really need them
-ZERO documentation
-functions with 15+ parameters
-no strings used in the queries were escaped. none.
-undocumented functions that modify parameters sent to them by reference
So that you might say is the average php codebase written by the average php coder, and you would be right.
It doesn't stop there though.
Previous developer adds threads to the mix! I didn't even know php knew threads!
Since he doesn't understand threads + globals he uses mutexes for access to variables.
Since he doesn't understand sql he uses mutexes instead of locking/unlocking tables - even though none were needed.
No caching even though it has components that crawl the internet. And image generation. And SWF file generation - yes, he went as far as modifying bits inside flash files.
There are functions with 10 levels of loops that span 700+ lines.
I am stuck with a gazillion lines of this. It's pretty much the worst codebase I faced to date.
Then I remembered this, it's probably worth sharing for most coders out there.
https://www.youtube.com/watch?v=csyL9EC0S0c
Guess $previous_guy though he was indispensable by not writing docs and making himself needed every day.
What would you do (coding related)
Moderator: Moderators
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: What would you do (coding related)
Case 1: Customer knows how crap the code is > Rewrite it all from scratch and charge a lot.
Case 2: Customer thinks the code is "adequate" > Find new customer.

Case 2: Customer thinks the code is "adequate" > Find new customer.

Re: What would you do (coding related)
If I had no option and the client has deep pockets.. I would try and take another job. The client would label you a cut and run developer who over charged him.
If I had no option and the client has no money. I would walk, ain't working for for free that time goes to spring
If I had no option and the client has no money. I would walk, ain't working for for free that time goes to spring
-
- Posts: 98
- Joined: 22 Sep 2014, 20:29
Re: What would you do (coding related)
Wow thank you for the fast replies.
In my original naiveté I actually considered rewriting the core on my own time since learning to work with - and expand upon - current functionality would really slow me down. I'm at the point where for a single function call I have to enter every include and check for needed globals, where they come from and where they're changed.
Has money, makes money with system (after my changes at least...).
Appreciate you wisdom!
In my original naiveté I actually considered rewriting the core on my own time since learning to work with - and expand upon - current functionality would really slow me down. I'm at the point where for a single function call I have to enter every include and check for needed globals, where they come from and where they're changed.
Has money, makes money with system (after my changes at least...).
Appreciate you wisdom!
Re: What would you do (coding related)
If you decide to refactor the mess- get a company history. Basically what where they trying to archieve..
It helps to understand, where the mess started, and while it has grown on some spots and stalled on others.
Then slice it, meaning make components with interfaces on the spots were any rational system would have those. Reroute everything through the interfaces. Split stuff that wont fit.
If you are still not mad after that- tell me how.
It helps to understand, where the mess started, and while it has grown on some spots and stalled on others.
Then slice it, meaning make components with interfaces on the spots were any rational system would have those. Reroute everything through the interfaces. Split stuff that wont fit.
If you are still not mad after that- tell me how.
-
- Posts: 98
- Joined: 22 Sep 2014, 20:29
Re: What would you do (coding related)
Code: Select all
grep -izorP '^\s*global[a-z \n\s$,_]+' --include='*.php' --exclude-dir='dirname' --exclude-dir='dirname2' . | grep -ioP '\$\K\w+' | sort | uniq
And it's a start. I'm afraid I had been insane before this as well. The technical doing of the thing is one, but the fact that the guy is running a successful business around this is mind boggling.
Re: What would you do (coding related)
actually - no.. its just the never look up and out of the trenches perspective.. just keep digging.
and they dig and dig.. and it all looks succesfull and they pile up money for the rewrite they are going to do
and the day comes they have gone tron lightcycle with trenches
worst moment for a total rewrite
but the moment you will help them, release the pain and pressure, they will fall back into digging the trench..
trying to crew you into the dig team..
So you basically need to keep them bleeding, while rewritting it, and most of all, you will know that once you have rewritten it, a new approach will be made, digging into every direction, so some other poor soul will one day return look at it and ask itself, what is burried at the heart is actually a good start.
Its how success comes together.. glued from spare parts.. still red hot at some art.
Whats really gonna bug you, is the politics that started it and how to stop the fungi coders from overgrowing your stuff later on. I think Spring Devs actually would have some solid advice on this.
On beeing, give those who come after you defaults, means small start working start projects that push them into the right direction. With a default folder structure. With a small tutorial.
You are still a poor bastard though.
but the moment you will help them, release the pain and pressure, they will fall back into digging the trench..
trying to crew you into the dig team..
So you basically need to keep them bleeding, while rewritting it, and most of all, you will know that once you have rewritten it, a new approach will be made, digging into every direction, so some other poor soul will one day return look at it and ask itself, what is burried at the heart and why it was actually a good start.
Its how things comes together.. glued from spare parts.. still red hot at some artificial angles.
Whats really gonna bug you, is the politics that started it and how to stop the fungi coders from overgrowing your stuff later on. I think Spring Devs actually would have some solid advice on this.
On beeing, give those who come after you defaults, means small start working start projects that push them into the right direction. With a default folder structure. With a small tutorial.
You are still a poor bastard though.
and they dig and dig.. and it all looks succesfull and they pile up money for the rewrite they are going to do
and the day comes they have gone tron lightcycle with trenches
worst moment for a total rewrite
but the moment you will help them, release the pain and pressure, they will fall back into digging the trench..
trying to crew you into the dig team..
So you basically need to keep them bleeding, while rewritting it, and most of all, you will know that once you have rewritten it, a new approach will be made, digging into every direction, so some other poor soul will one day return look at it and ask itself, what is burried at the heart is actually a good start.
Its how success comes together.. glued from spare parts.. still red hot at some art.
Whats really gonna bug you, is the politics that started it and how to stop the fungi coders from overgrowing your stuff later on. I think Spring Devs actually would have some solid advice on this.
On beeing, give those who come after you defaults, means small start working start projects that push them into the right direction. With a default folder structure. With a small tutorial.
You are still a poor bastard though.
but the moment you will help them, release the pain and pressure, they will fall back into digging the trench..
trying to crew you into the dig team..
So you basically need to keep them bleeding, while rewritting it, and most of all, you will know that once you have rewritten it, a new approach will be made, digging into every direction, so some other poor soul will one day return look at it and ask itself, what is burried at the heart and why it was actually a good start.
Its how things comes together.. glued from spare parts.. still red hot at some artificial angles.
Whats really gonna bug you, is the politics that started it and how to stop the fungi coders from overgrowing your stuff later on. I think Spring Devs actually would have some solid advice on this.
On beeing, give those who come after you defaults, means small start working start projects that push them into the right direction. With a default folder structure. With a small tutorial.
You are still a poor bastard though.