Refactoring the Code – Printing Selected Beams to Excel - Part 1 (Tekla Open API)

_config.yml

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. Always try to improve it. Just like the guy above. Try to make it better.

I proceeded on the basis that the Tekla API, like the AutoCad API couldn’t be tested easily. But it can. This will be a wonderful exercise in adding tests to an existing code base. Using the test you can slowly but surely refector. It’s an exercise worth undertaking for existing code basis which you may inherit or come into contact with.

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:



Written on January 26, 2018