Skip to content

ISP21/refactoring-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Refactoring Practice

Copy this template repository to your own Github account. Then clone it to your computer and do the refactorings. Push your work to Github.

Each subdirectory contains some code that needs refactoring.

  1. In this README, write one line describing each refactoring you apply and why.
  2. Perform the refactoring in the subdirectory code.

time/timestamp.py

Refactor timestamp.py. 2 or 3 refactorings are possible.

game_framework/gamelib.py

Look for refactorings in the class GameApp.

  • Avoid side-effects: replace side effect with return value (the caller must use the return value)

  • Encapsulate a collection - provide behavior that subclasses of GameApp need instead of requiring them to manipulate a collection that belongs to the GameApp class.

    • Hint: elements

recipe/recipe.py and recipe/main.py

This uses a dataclass, which requires Python 3.7.

The Recipe class defines a recipe for a hot beverage with attributes:

  • name - name of the recipe
  • coffee - units of coffee
  • chocolate - units of chocolate
  • milk - units of milk
  • sugar - units of sugar
  • price - (float) price in Baht

Refactor main.py. What can you do to eliminate the long, boring code?

Resources

About

Some refactoring exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages