7

First of all, is not a programming matter, is a programmer afair.

I'm the new web programmer in my company.
I'm here just for 2 weeks. And they want me to teach Wordpress, configure & install it, and things like that.

But they have a intranet too to make all the compatibility stuff, tracking clients, ordering event, auto-emailing.

Well, the intranet is very nice, and they spent 1 or 2 years with a programmer to do that.

But the problem is:

The intranet is great for the user (a bad UI experience but works well).
They have it from 4 or 5 years now.

But if you go to the code, it is annoying.

Seriously, it's really really really heavy, code duplicated, insecure. All works ok, but all is wrong in code view.

Some points:

  • The site keeps 4GB of disk space (without DB!)
  • There where thousands of files, folders, with no order
  • A lot of files are duplicated
  • There were, at least, 20-40 files you have to configure to change the database source
  • Some config files are in .ini, so i can download from anywhere
  • The sites was coded for 4.0 or 3.x, miraculously it works on 5.x with some warnings.
  • The site was coded without any kind of scalability, they just copy and paste files and keep working, no includes, nothing.

For example: I see, at least 40 files called check_in.php in different folders.

Functions called: paste() paste_2()...

What points you will use to convince your boss to take care of that and refactor all the whole site?

It's a pain in the ass. I know refactor all gonna be hard, but I think it's the better way to continue my work.
Because they want me to make modifications on that and I have to spent 3 hours just to understand from where comes that **** function called paste() and what exactly do.

Ah, one more good point.

There's no documentation at all.

S.Lott
  • 45,522
  • 6
  • 93
  • 155
nax
  • 173

3 Answers3

16

The amount of change one should effect is contentious. What happens if you decide on a 'big bang' approach, estimate that it should take two months to refactor completely, and end up taking six? I'm not questioning your competence - it's just that projects like these can easily spiral out of control.

You could make a case for a gentle, iterative refactoring. So maybe you take a day to centralise the configuration files, and then move to other projects. Then two weeks later, you add autoloading. Get small changes live each time, and then wait for a bit for them to bed in. This way you remain productive on new projects, whilst slowly improving your codebase.

You should do these things on a separate branch, and if there are other tech people that your changes will touch (programmers, dbas, etc) then get them to buy into your changes before you do them.

halfer
  • 316
10

Explain the cost benefit: Every time they want to make a change you will spend 3 hours figuring out the code, and only then will you be able to make the change, which will probably take less than 3 hours. On a neat, well-structured site with good documentation most changes and additions can start immediately without delay. In your case you have a 3 hour prep session before anything can happen (based on what you have described)

Also, try to find a real-world analogy that your boss can understand. Explain how working on undocumented code is like trying to find something in a cupboard full of non-glass jars that all have no labels.

Generally doing a complete overhaul of a site is never (financially) viable. I have almost always had to compromise to make changes to a poor solutions as and when I touched on the code-base to avoid loosing too much productivity time to re-factoring. Code Clean-up is hardly ever allowed for from a costing point of view, it generally happens as a passive side-effect of touching on something else that needs to be improved.

3

It will help your case when you show some sort of transition path. Evolution not Revolution.

This way the decision becomes less risky.

DerMike
  • 1,053