So, I've just inherited a very large, very badly written monstrosity. Including javascript, template files etc, it breaks the 1 million LOC barrier. I'm looking for some advice and strategies that you guys might have used in similar situations, in particular on:
- getting a handle on the code base
- communicating 'progress' to the client
- not losing the will to live
The software is based on vtiger, an open-source CRM that has a (deserved) reputation of being incredibly badly written, that has since been badly hacked apart by several different companies with wildly differing ideas. My client currently have 150+ installs and 150+ angry clients.
Words fail me trying to describe the state of the software.
- no niceties such as MVC, ORMs, a DBAL, or a modular design
- all DB queries are inline SQL, with tens of inner joins on most queries
- dizzying call stack, yet reams of copy+paste code
The best part: the code will often query the DB and execute PHP code contained in the response, or load and run arbitrary files and modules as dictated by parsing particular DB fields. The one page I have studied in detail generates 105 DB queries in the simple case.
The DB itself is even worse. There are over 600 tables, as well as views, custom functions, cascades and (but of course) triggers. There is no consistent naming schema, very few explicit foreign key references (despite being heavily, heavily entwined) and I have already discovered several tables that don’t have primary keys, but are referenced by exact string matches on things like date stamps.
I wont mention the table-based HTML, javascript, lack of version control etc.
I’m not sure if its even possible to give relevant advice (besides perhaps ‘run screaming’), but if anyone here has come through a similar situation and has any advice to share, I would be deeply grateful.
Help me HN - you're my only hope.
(PS. 2K char limit sux)
2. Make sure there is some workable strategy for deploying and testing the code.
3. Ask somebody to provide you with a list of the changes, or else try to create some kind of diff against the original version of the code. If you can see crazy stuff here then find out who did it...
4. Ask somebody what the biggest bugs are? Which things are causing clients the most problems?
5. Try to establish which convention is 'winning' in the codebase. But you might want to create a more sensible convention which will allow unit testing (start this immediately!)
6. At this point, ask if you can hire people to work on this with you as it's a big problem, and you need to free yourself up for the rewrite.
7. If that isn't possible then leave. You have done enough to make your CV better and a company which passes you something like this does not care about your career.