Why Refactoring? How to Refactor/Restructure Python Package?

Melvin Koh
HackerNoon.com

--

Refactoring in Python is not that hard.

In this article, I will walk you through:
1. The signs of need for refactoring.
2. What is considered refactoring?
3. What to do before refactoring?
4. Step by step guide to restructuring Python package

The examples are written specifically with Python in mind. However, the general principles shall hold true across all languages.

The signs of need for refactoring

  1. Your versions are no longer supported. The best written code will still be obsolete after some time.
  2. You want the new features in newer versions of frameworks, libraries or even programming language.
  3. Your code was written quick and dirty with tons of technical debts.
  4. Your code is hard to navigate. Countless indirect access.
  5. Not comply with standards, style guides, conventions.

What is considered as refactoring?

The term refactor, covers a broad array of actions and definitions. While the term itself generally lead to a common goal, which is a cleaner, better code base, there are still a lot of actions can be considered as ‘refactoring’.

--

--