More Files, Fewer Lines

After last week’s post and the associated code audit, I ended up diving right in to cleaning up my overlapping UI code, making some of the controls more re-usable, and trying to reduce the number of lines of code in the project. I haven’t started in on the JSON parsing and Java API, but I’ve managed to tear a whole lot of code out of the project.

The first big win was figuring out how to accomplish several UI design tasks, which previously required custom classes, over to clever use of UIAppearance properties, especially appearanceWhenContainedIn: hierarchies to get exactly the effects that I want everywhere, managed in the app delegate, and that let me remove several custom classes and lots of custom table delegate code.

The second big win has been breaking code up into smaller and more manageable chunks. This has been both breaking files into better semantic separations, and also breaking functions down into smaller parts. I’m surprised that along with the benefit of better readability and decreased complexity, I’ve also managed to reduce overall line count in several places by forcing myself to re-think how a block of code is structured.

As a secondary part of step 2, I’ve been restructuring the directory tree, renaming files, refactoring methods and variables, and doing everything I can do to enforce stylistic consistency. The project was relatively clean to begin with however the difference between “pretty good” and “excellent” can be a large one.

All told I’ve only caught 2 relatively minor bugs while doing this round of clean up, which is a good sign of the state of the code going in. I’ve also done a large overhaul on 3 screens in the app to enforce consistency in how UI elements function based on decisions that were made after the initial revision of those screens were completed. I’m about 1/2 of the way through my code audit of the iOS app, and after that I’m looking at a major overhaul to the API generator.