Skip to content

Learning Python Day: 54

Refactoring: The _check_events() and _update_screen() methods

  • refactoring simplifies code structure to make it easier to build on
  • we’ll break the lengthy run-game() method into two helper methods
  • helper method – does work inside a class but isn’t meant to be used by code outside the class
  • a single leading underscore indicates a helper method

The _check_events() method

  • we’ll move code that manages events to a separate method called _check_events()
  • this simplifies run_game() and isolate the event management loop
Tags:

Leave a Reply

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