Refactoring Your Code
When you’re writing an app as complex as On Your Bike, it can make sense to periodically examine the classes to see whether you can build a simpler and easier-to-understand structure by breaking up the classes—another kind of refactoring. It’s a good idea to compare the name of the class to what the class actually does, and, if you see methods that go above and beyond what you expect from the class’s name, it could be a sign that the methods belong in another class. If possible, each class should have only one responsibility. In addition, if the methods primarily call methods on one other class, it may mean that the methods belong in another class.
If you examine the TimerActivity class
, you will see it is now doing several ...
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.