Building Puzzle Frenzy: using small source code files

As I told you before, Puzzle Frenzy was build starting from an old app I wrote for WP7. A lot of things changed since then, and most importantly I got to read Uncle Bob’s Clean Code as well as watch some of his Clean Code episodes.

Based on what I learned by reading the book I started refactoring the code. One of the thing that bothered me the most in the old code was the big source files, where I kept big classes and long methods.

Over time I managed to decrease the classes size quite a lot which helps me when it comes to testing, fixing bugs or adding new features.

Here is a comparison of the file size numbers:

Before After
Total line count 4114 6514
Source files count 45 118
Average file line count 91 55

meaning that

  • I increased the total amount of code with 58%
  • I increased the number of files with 162%
  • I reduced the average file size by 39%.

Here is how the file line count looks like:

Before: WP app source files line count

Before: WP app source files line count

After: Puzzle Frenzy source files line count

After: Puzzle Frenzy source files line count

As you can observe I still have some old large classes, but with constant refactoring I’m pretty confident that I will manage to decrease their size over time.

I’m more then excited with these changes: now the code reads better, I can understand easier what it does, and I have more confidence in it.

I strongly recommend the above-mentioned Clean Code book, it contains some priceless advice.

Happy coding!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.