3

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?

7

2 Answers 2

5

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.

2
  • 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, 2012 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. Feb 23, 2012 at 22:16
0

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.

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