Preface

My personal title for this book is “Java: Exercises in Style.” After the wise people at Manning taught me about catchiness, this preface is all that’s left of that title and its literary overtone. Indeed, in the modern classic Exercises in Style, French writer Raymond Queneau writes the same story in 99 different ways. The point of the book is not the story, which is intentionally unremarkable, but rather the whimsical exploration of the virtually endless expressive capabilities of natural languages.

Programming is certainly not literature, despite efforts by renowed personalities such as Donald Knuth to bring the two closer together. In fact, beginner programmers may be forgiven if they think there’s one best way to solve each programming assignment, just like simple math problems have a single solution. In reality, modern day programming can be much more similar to literature than to math. Programming languages have evolved to include ever more abstract constructions, multiplying the ways to achieve the same goal. Even after their introduction, languages evolve, often by acquiring new ways of doing the same things. The most used languages, such as Java, have been evolving at an accelerated pace to keep up with the younger languages trying to take their positions.

In this book, I try to give a taste of the wide range of concerns and solutions that you should consider, or at least be aware of, when undertaking any programming task. The task I propose is quite mundane: a class representing water containers that you can connect with pipes and fill with liquid. Clients interact continuously with the containers, adding or removing water and placing new pipes at any time. I present and discuss 18 different implementations for this task, each striving to maximize a different objective, be it performance, code clarity, or some other software quality. This book is not a dry sequence of code snippets. Whenever the context calls for it, I take the opportunity to discuss a number of specialized topics pertaining to computer science (various data structures, complexity theory, and amortized complexity); Java programming (thread synchronization and the Java memory model); and software engineering (the design-by-contract methodology and testing techniques). My objective is to show you that even a relatively simple case study, when analyzed in depth, is linked to a vast network of topics, all of which contribute to writing better code.

Further Reading

One of the objectives of this book is to stimulate your curiosity about the various disciplines related to software development. That’s why each chapter ends with a Further reading section, where I briefly introduce the best resources I could find on the chapter’s topic. I think the preface should be no exception, so here it goes:

  • Raymond Queneau. Exercises in Style. New Directions, 2013. The original “exercises in style” book. (Actually, the original was written in French in 1947.)
  • Cristina Videira Lopes. Exercises in Programming Style. CRC, 2014. The author solves a simple programming task in 33 different styles using Python. Rather than optimizing different code qualities, every style results from obeying certain constraints. Among other things, it teaches you a lot about the history of programming languages.
  • Matt Madden. 99 Ways to Tell a Story: Exercises in Style. Jonathan Cape, 2006. When you need a break from coding, check out this comic book featuring a simple story drawn in 99 different styles.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.141