python / refactoring

Refactoring, the triangle project – overview

Through this series of posts, I am exploring my journey refactoring an existing project. I hope that each version will improve on the last, becoming:

  • more readable
  • cleaner, shorter and more succint
  • utilise new tools or methods to do the above
  • maintain natural syntax. I would like my code to be easy to read, easy to understand and easy to maintain. I would like to avoid overly obscure code.

For this journey, I am going to work with the project here:

Briefly, the project will print out the outline of a triangle. The size of the triangle should be variable, as defined by the user. Sample output for size 5:


In future blogs, I am going to document my attempts to refactor this project. I envisage that I will follow a journey similar to:

  • initial hack-up (regular and inverted triangles)
  • general function to output either regular or inverted triangle
  • use recursion
  • use itertools
  • investigate decorators?

# to be continued…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s