Skip to main content

Section 1.1 What you will learn from this book

Subsection 1.1.1 Maintainable code matters

This book focuses on learning how write maintainable software. Writing a few lines of code to make the computer is hard already (well, for most people it is), but if you are reading this book, then you hopefully are already familiar with that, in at least one programming language.
But what about writing 10000 lines of code, or 100,000 lines of code, and you are working with 6 other people, and you need to look back at your code two years from now and modify it so that it does something new.
Did you write your code with that in mind?
If you did, then maybe you don’t need this book after all. But if you’re anything like me when I started, then probably not. My only goal back then was to get that darned computer to do what I wanted it to do. I wasn’t planning to come back to it 6 months later.
Why is writing maintainable code important? Two simple but important reasons:
  1. Programmer time is expensive, in fact it is the most expensive part of software development. Anything that slows down a programmer is simply put a heavy cost to your bottom line. And a lot of the time it was avoidable.
  2. Your code will need to be changed at some point in the future. If there is one thing that we have learned over the years is that requirements change over time, and at some point down the line your code will be asked to do something it was not designed to do. And will need to take steps to make it so.
The most important quality that your software solution needs to have is not its ability to solve the current problem; it is in fact its ability to adapt and solve the future similar but slightly different problems.

Subsection 1.1.2 To Java or not to Java

This book will also act as an introduction to the Java programming language. But let’s get some things straight:
  1. I am assuming that you are already familiar with basic programming, in at least one language, preferably two. Students in my classes have typically seen some Python and C++ by this point. This is not a book about the basics of programming. There plenty of other resources out there for that, I encourage you to start there.
  2. I will only teach you a small part of Java. The language is there as a vehicle for discussing concepts of maintainable code. There are many things that we will not discuss, and I urge you to further your studies of the language from other resources.
  3. I chose Java for many reasons, but primarily because it has a fairly pure OOP approach, it is strongly typed, and it doesn’t try to be "too smart". Yes it’s verbose. Yes there are many cooler kids in the block. And by all means you should meet at least a couple of them, hang out with them and learn what makes them cool. But all the principles that we will be talking about are just as valid in those languages, and Java offers a convenient vehicle for presenting them.

Subsection 1.1.3 All that Jazz

So what all will we cover in this book?
  • We’ll learn some Java. Not much, but enough for our needs.
  • We’ll cover topics related to object-oriented programming.
  • We’ll discuss clean code practices, including code smells and refactoring.
  • We’ll discuss the basics of unit testing and test-driven development, and in particular the use of test doubles.
  • We’ll discuss OOP design principles and look at a number of design patterns through that lens.
  • Lastly, we’ll do all that through gradually building a small application.
All these topics mesh so well together, that trying to study them in isolation is far from ideal. We will therefore interweave all these topics gradually, as we move through the design of our application. But more on that in the chapters to come.