Should we refactor files we're working on?
When programming, always follow the camping rule: Always leave the code base healthier than when you found it. — Martin Fowler, Refactoring The Boy Scouts of America have a simple rule that we can apply to our profession. Leave the campground cleaner than you found it. — Robert Martin, Clean Code Many of us share the attitude expressed by the above Fowler and Martin quotes. The attitude presumes that code we’re working on now will change again soon, and we’ll reap the benefits of a refactor when that happens.…
Why and How we Should Calculate Expected Utility of Refactorings
In my experience, most applications are a mess…Changes are commonly made under urgent time pressure, which drives applications towards disorder…Velocity gradually slows, and everyone comes to hate the application, their job, and their life. —Sandi Metz, “The Half-Life of Code” Why Many of us work in codebases that are not easy to work with, codebases that we want to make better. The way that we typically choose what parts of the codebase get made better, however, is sub-optimal.…
How to Safely move Logic out of Activities
In my last post, I argued that we should stop putting our app logic in Activitys and Fragments because it makes both unit testing and functional testing our apps more difficult. In this post, I’ll try to suggest a method of safely removing app logic from our Activitys and Fragments, drawing on a central idea discussed in Michael Feathers’ Working Effectively with Legacy Code: characterization tests. In the first section, I briefly introduce the idea of characterization tests.…