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.

Possible Duplicate:
How do I approach a coworker about his or her code quality?

My development colleague is producing numerous blocks of code which I am a bit concerned doesn't really make for easy reading and potential issues in the future. I've tried giving little tips along the way without blantantly saying what I think but his technique never seems to change.

I wouldn't normally be worried however we never identified any specific programming standards at the beginning of our project and it's now really starting to effect me a bit as I have to go through his code and try and debug it.

A small snippet of just a small part of the code is as such.

foreach(DistributionRecord record in _manager.Distributions)
{
    foreach (Engine.Model.DistributionModel.LossFromAtmosphericConditionsEnum NLossAt
                    in Enum.GetValues(typeof(Engine.Model.DistributionModel.LossFromAtmosphericStructureEnum)))
                    if (record.NlossAt.ContainsKey(NLossAt))
                        if (record.NlossAt[NLossAt].ContainsKey(DistributionModel.LossFromAtmosphericConditionsEnum.Atvolat))
                            _indirect[GetIndirectSourceEnumFromEnterpriseType(record)] += record.NlossAt[NLossAt][DistributionModel.LossFromAtmosphericConditionsEnum.Atvolat]
                                * _manager.Scenario.Management.EmissionFactors.EmissionFactorIndirectBackgroundVolatisation;

                foreach (Engine.Model.DistributionModel.LossOffEnum lossOff in Enum.GetValues(typeof(Engine.Model.DistributionModel.LossOffEnum)))
                    if (enterprise.NlossOff.ContainsKey(lossOff))
                        if (enterprise.NlossOff[lossOff].ContainsKey(DistributionModel.LossTypesEnum.lossleach))
                            _indirect[GetIndirectSourceEnumFromEnterpriseType(record)] += record.NlossOff[lossOff][DistributionModel.LossTypesEnum.lossleach][NutrientEnum.N].Value
                                * _manager.Scenario.Management.EmissionFactors.EmissionFactorN2OIndirectBackgroundLeach;
}

I've talked to the boss and without blatantly saying it explained my concerns etc I don't know what else to do.

Not sure if this is appropriate for this forum but any advice would be appreciated basically on how I can tackle this with my colleague. Or perhaps I'm just being unrealistic and gotta get with the real world in that this is just how some people write code and it's ok?

share|improve this question

marked as duplicate by Rachel, FrustratedWithFormsDesigner, kevin cline, Doug T., Josh K Feb 23 '12 at 23:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Why do you have to debug his code? –  Garrett Hall Feb 23 '12 at 20:58
6  
If this made it on to thedailywtf.com , do you think the other coder would get the message? –  FrustratedWithFormsDesigner Feb 23 '12 at 20:59
    
Whoa that is dense. –  Mike Brown Feb 23 '12 at 21:01
3  
Possible duplicate of How do I approach a coworker about his or her code quality? –  Rachel Feb 23 '12 at 21:10
    
@Rachel. Yep looks like it is. Thanks for pointing that out –  dreza Feb 23 '12 at 21:56

2 Answers 2

Talk to your boss about institutuing a code review process. Then you can show him what the problems are officially and as a bonus, he will be expected to fix them before deploying. Of course your code will be reviewed and changes will be requested for it as well.

share|improve this answer
1  
So we would review each others code. Could be an idea I could float with boss. I'll have to be prepared to come under the microscope as well ha –  dreza Feb 23 '12 at 21:55
2  
@HLGEM: In my experience, this will help only if other team members share dreza's opinion. If it's one against one it will just create resentment. –  kevin cline Feb 23 '12 at 22:16

Come up with agreed on coding standards by committee (both of you and maybe your boss involved). Then the discussion on code written prior the issue isn't a problem. Also as HLGEM mention (and i upvoted) code reviews. But without the standard agreed on the reviews could end up causing some heated discussions.

share|improve this answer

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