Best Website Development Company

Improve by refactoring.
Strive to improve the code. Just like this guy is trying to improve his swing. Looks like a fine golfer by the way. probably low single figure handicap, if not scratch.

We will attempt to do something which is seldom done or discussed in Tekla code samples: and that is the very important issue of refactoring code.

 

1. Start with Tests.

 

The first thing you need is a good suite of tests. That way you will know whether something has gone wrong or not. It might be tricky doing this since we are developing within the Tekla environment, but I do suppose it’s possible.

 

2. General Themes:

 

  • Change names to more appropriate titles.
  • Restructure the code to make it understandable.
  • Correct any obvious defects:

 

 

2 Responses

  1. when I try to use this method
    private List groupBeamsByPartNameAndFinish(PartSelector beams)
    {
    return beams.GroupBy(part => new NameProfileFinish() { Name = part.Name, Profile = part.Profile.ProfileString, Finish = part.Finish.ToString() }, (key, group) => new AggregateBeam { NPF = key, Beams = group.DistinctBy(b => b.Identifier).ToList() }).ToList();
    }
    I get this error:
    Error CS1061 ‘IEnumerable’ does not contain a definition for ‘DistinctBy’ and no accessible extension method ‘DistinctBy’ accepting a first argument of type ‘IEnumerable’ could be found (are you missing a using directive or an assembly reference?)

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress PopUp Plugin