I got a WordPress project.
The goal is to optimize the purchase system of a book publisher’s website.
It was written from scrach and didn’t use plugins like woocommerce.
On the surface, it’s not a difficult task, i heard about the way the system works and made a basic plan to go for it piece by piece but man, when I saw the code…
It’s about 5 thousand lines of code in 3 to 4 files. Half of the code is also written between htmls tags and templates.
It was bad but I still wanted to accept the job, but oh boy I was in the wrong. The worst part was when I started reading the codes.
Apart from the complexity of the functions and being all over the place, all the naming for function and variabls was also weird, they hardly mean anything.
I really wonder where to start…
[ad_2]
Yea, I think in the future always suggest taking half a day or so to do a slightly deeper run through of the filesystem before committing yourself to a project / budget / chosen solution. ( This sucks as advice after the fact, but just as a ‘don’t get burnt by this’ deal – spending 4 hours or so to know it needs to be rebuilt completely changes the proposition from your perspective ).
Realistically on stuff like this, for me, it’s almost always a tear down job, in order to completely reorganise it like a sane person would. Loads of work obviously but having tried to fight against spaghetti code previously, it’s pretty much never worth it, as the deciphering / refactoring / debugging / cleaning usually takes the same amount of time as just isolating the core functionality needed and writing it out sensibly and coherently.
There is probably stuff that is semi-usable in there, I think the first thing you need to do is just run through it and understand what everything is *attempting* to do, comment blocked functionality for references for yourself (obvs), and start splitting it out into a sensible file system, then just make a decision on how ridiculous the current implementation is vs. what you would write instead.
Most importantly just be upfront with the client, tell them what you’ve run into and give them an updated estimate on time and cost, and run through potential options with them.