Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Feb 20 '12 at 10:04

This question came from our site for professional and enthusiast programmers.

15  
If you are working for a business you need to make a business case. "If we do this we will get more money". You may find that doing that is impossible, even if you believe, correctly, that the quality is very bad. –  Joe Feb 20 '12 at 10:02
    
13  
So, you're very fresh (2 weeks) and want to propose a total refactoring? This is crazy. It's more likely that you simply don't understand a new (for you) legacy codebase. It's always like that at the beginning. Wait at least a few months and then rethink if you really want to propose a total refactoring. –  quant_dev Feb 20 '12 at 10:49
2  
Why did those that made this quit? –  user1249 Feb 20 '12 at 11:03
1  
In this case, beginning your career in a firm by becoming the bearer of bad news can only end badly for the OP. –  quant_dev Feb 20 '12 at 17:03
show 5 more comments

3 Answers 3

up vote 14 down vote accepted

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.

share|improve this answer
11  
“Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.” –  veryfoolish Feb 20 '12 at 10:10
1  
I understand your point. I'm pretty sure it gonna take more than expected, i can't say for sure how much time it can cost. With the two answers i have i'm thinking on take a time, see what time take for each little change. Know more about this intranet and then do a better planification of all and give my boss to think about. I love the idea of making a little branch. Maybe i gonna do that, just in my free time. Thanks a lot. –  nax Feb 20 '12 at 10:26
    
Is the whole site under version control, btw? If not, that would be the first thing I would do - it's a nice quick win. And essential, of course, if you're going to do branching. –  halfer Feb 20 '12 at 10:45
    
The problem is the company just have one programmer before. And he was who do the intranet. don't have control version, servers, nothing. Just an intranet and a web page. I'm here just to do some changes, in theory. I take care of version control because i used it and i know how good can be –  nax Feb 20 '12 at 10:54
    
Excellent, well get everything into a version control system you know - even files you think are dead. Then maybe get a link-checker to see if any stuff can be deleted or tidied to a different folder (of course make such changes carefully ;) ). –  halfer Feb 20 '12 at 11:12
add comment

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.

share|improve this answer
    
Well, i'm in a trouble. Bot answers helped me. as i say in the other one, i gonna spend some more time and know how much time takes any change, give a complete documentation from all change i do. And in a month or two, give to my boss. In the mean time, i start working in my free time in the refactoring, and planification of the whole intranet. thanks a lot! –  nax Feb 20 '12 at 10:28
1  
+1, I agree about not being able to 'fix everything'. On my current project, I have to use a homegrown ORM (!!!) that was written when Propel was already a solid product. Sometimes when writing a query type we don't yet have, I find that there's a bug in the ORM - but changing it is just not viable for as long as our platform is on PHP. –  halfer Feb 20 '12 at 10:37
    
In terms of warnings, we have loads, but we're working on a slow programme of removing them, and iteratively removing the template layer that is often their cause. It's low priority and the changes are small, so are non-disruptive. –  halfer Feb 20 '12 at 10:39
2  
@nax: Not sure what you mean by "free time". Do not donate your personal time to this enterprise unless you are an owner. If you really prefer coding to other leisure activities, contribute to an open-source project or start one. That will at least be good for your resume. –  kevin cline Feb 20 '12 at 17:09
    
@kevincline i'm just talking about the last 10-20 min after finish my work, usuarlly are free timed. but i don't think i gonna do that. because it take so much time... but maybe i use it to documentation or planification of little improvements. Do you have or know any open source project or site i can go to help? –  nax Feb 20 '12 at 17:45
show 1 more comment

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

This way the decision becomes less risky.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.