Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications
by James Talbot, Justin McLean, Jorge Hernandez
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access