His code base is atrocious. I just got this contract and I'm trying to be as professional as possible by giving my client examples of why he needs to change the way he is doing things on the technology side to avoid certain disaster.<p>The code clearly exhibits that the developers do not understand programming in several instances. There are is-a relationships used where has-a would be appropriate as well as code that is just completely in the wrong freaking place, to put it bluntly. Misspellings are abundant and there is no documentation. All the code is formatted like trash and I seriously doubt that even the original developers (an outsourcing company who are obviously specializing in making shitty websites as fast as they possibly can and didn't even bother to open up a programming book before trying) would be able to read the code.<p>Any advice on explaining this to him? None of the code is in version control, documented, or has any heirarchical structure. Tons of code is repeated, there is voodoo code, yoyo code, bulldozer code, and several examples of developers copy pasting and obviously not reading docs at all.<p>Here is one of the cutest things I found:<p>function formatAvgRating($average_rating){
124 if($average_rating <= "0.25" ){
125 $average_rating = "0";
126 }else if( $average_rating > "0.25" && $average_rating <= "0.75" ){
127 $average_rating = ".5";
128 }else if( $average_rating > "0.75" && $average_rating <= "1.25" ){
129 $average_rating = "1";
130 }else if($average_rating > "1.25" && $average_rating <= "1.75" ){
131 $average_rating = "1.5";
132 }else if($average_rating > "1.75" && $average_rating <= "2.25" ){
133 $average_rating = "2";
134 }else if($average_rating > "2.25" && $average_rating <= "2.75" ){
135 $average_rating = "2.5";
136 }else if($average_rating > "2.75" && $average_rating <= "3.25" ){
137 $average_rating = "3";
138 }else if($average_rating > "3.25" && $average_rating <= "3.75" ){
139 $average_rating = "3.5";
140 }else if($average_rating > "3.75" && $average_rating <= "4.25" ){
141 $average_rating = "4";
142 }else if($average_rating > "4.25" && $average_rating <= "4.75" ){
143 $average_rating = "4.5";
144 }else if($average_rating > "4.75" ){
145 $average_rating = "5";
146 }<p>Should I tell him this is how a competent individual would write it?<p>function formatAvgRating($rating) {
$rating_floor = floor($rating);
$part = $rating - $rating_floor;
if ($part < .25)
return $rating_floor;
else if ($part > .75)
return $rating_floor + 1;
else
return $rating_floor + .5;
}<p>???<p>So many decisions..
Do you want to take over their job?
If not, do you have a cheap, competent replacement?<p>If the replacement isn't as cheap as the apparently horrendously long code, can you show noticeable differences in runtimes?
9 out of 10 developers think they are superior coders than they actually are. Keep that in mind while considering your options -- that is, are you <i>really</i> as awesome as you say you are? So awesome and so superior to the current team that you can validly say you can do better and prove that? Not just in a single scenario but across the proverbial board?<p>Even if you say yes to the above I say don't do it because karma is a bitch. But I doubt you will say yes to the above.
Sorry, I know that we tend to be purists and want our functions to be all clean and tidy and use like.. zero lines of code, but I understood what the cute code is trying to do in like 0.2 seconds. If I were hiring something out, this is code is actually fine with me.<p>It takes some mental energy to actually look carefully at the cleaner solution.<p>Different strokes...
You didn't mention what your engagement is with this client.<p>If you're a consultant, hired to help them improve the product and their development process, than you can advise on how the company may train or otherwise improve their situation with the existing staff.<p>If you're a contractor, hired to write some specific features for a project and nothing more, than suggesting what they do with their staff is way beyond your scope of interest and will just likely get you canned.
No. Don't do that. You never know who did what or why they did it. There may be some good reasons for bad code. Even worse, there may be a personal relationship that you inadvertently shit all over by suggesting the client ditch their programmers. Don't shy away form pointing out bad code that gets in your way (and why they need to pay you to fix it), but don't make it personal - there is no up side.
Are you sure that the state of the code base is due to programmers ability? In most cases it is a result of starting out with incomplete or unknown set of requirements. Edit after edit, bug fix after bug fix the codebase becomes a mess.Most of the time there's no incentive to go back and refactor and redesign the code. Lack of funds, lack of personnel, not touching what already works, you name it...
we had the same problem in my current work environment. The director(who also codes) being a very experienced person in getting things done from china and India outsourced teams, set up a 1hr everyday code review session. In about a month we saw decent improvements.
Be careful.<p>1) Do your contract. If asked then respond with that.<p>2) Do a good job, let your client see clearly YOUR code is superior.<p>3) Let your client keep their shitty coders.<p>By stating the above, you potentially destroy a relationship with a client. Unwarranted too.