Game Programming Patterns

Game Programming Patterns By Nystrom, Robert Book – 2014

Programmers will want to read this book. Not just game programmers, but also any programmer. Program structure is important for maintainability of large or medium programs. C++ language programmers will get the most benefit from the book. Other languages are also discussed, and all languages require some attention to structure.

Nystrom’s book is very readable and, perhaps I should add, entertaining. He has a dialogue on the go: the margin notes (his inner critic) are in counterpoint to the main discourse.

He gives credit to the Gang Of Four book (noting that it is 20 years old now,) as a foundation for his proposed new set of patterns.

The Best Perl

zen-1038363__180

The Perl language does not get enough respect these days. Newer languages like JavaScript, Python or Clojure get all the attention. But Perl is still in use almost everywhere, for many types of programs. It is powering the web at many  sites, including ZipRecruiter, PriceLine, TicketMaster, and DuckDuckGo.

Perl is good for rapid development. One reason is that there are many contributed modules are available, for just about any task you could imagine. Have a look at CPAN, the Perl module directory, containing more than 100,000 modules.

Suppose you have a bit of Perl experience and are starting a larger enterprise app. How do you choose among the thousands of Perl modules and frameworks? Suppose you Google a bit. Some of the best and newest modules will not be on the first Google page, because the best module authors are not necessarily SEO experts. Google will lead you to modules which look good at first blush, but do not have complete tests, or which depend on new versions of Perl, or have ‘hidden dark corners’.  You could get bogged down in Google results by the large quantity, the wild diversity, and the varying quality. Where do you start?

This is where Kensho becomes handy. It is a guide that recommends frameworks. There is a concise list of the best 5 database frameworks, the best 12 Object Oriented modules, the best 8 unit testing frameworks, and so on. 100 recommended modules in all.

For example, if you are planning an enterprise web site, look at the web development category, which lists app frameworks. In this, Catalyst is a mature project. Mojolicious is almost as mature, and is a large project with many features. Dancer2 is newer, and is quite different in that it is a DSL on top of Perl. Dancer2’s author had experience with the Sinatra framework. Your code will be concise, but at times  you will struggle to know what is happening behind the DSL facade (compare this with Rails in the Ruby world).

Now, look at the Object Oriented programming category.  You could structure your project based on the Moo or Moose object oriented frameworks. Your choice might be constrained by your choice of web app framework. If you use Catalyst, your OO will be Moose, and if Dancer then OO will be Moo with perhaps a bit of Moosex.

Likewise, testing frameworks can be constrained by previous choices.

The Kensho list is somewhat personal, being the preferences of Chris   Prather (PERIGRIN) (the originator) and Karen Etheridge, who is one of the most committed members of the Perl community. If you have used Perl, you have probably used one or many of the modules she wrote or maintains.

What’s the Kenshō 見性 name all about? From Wikipedia: “Kenshō is an initial insight or awakening, not full Buddhahood. It is to be followed by further training to deepen this insight, and learn to express it in daily life.”

So, before you start coding, have a look at the recommended frameworks, and structure your project better. There Is More Than One Way To Do It (TIMTOWTDI) but in most cases There Is A Best Way To Do It (TIABWTDI). And maybe TIMTOWTDI is one of Perl’s weaknesses! It will trip up the maintenance programmer, who may have to learn a new programming style with each project.

Many thanks to Gabor Szabo for corrections!

Dependency Injection

book coverDependency Injection : design patterns using Spring and Guice / Dhanji R. Prasanna, Manning, 2009

Java programmers will find this valuable. 300 pages, contents:

  1. – Dependency injection: what’s all the hype?
  2. – Time for injection
  3. – Investigating DI
  4. – Building modular applications
  5. – Scope: a fresh breath of state
  6. – More use cases in scoping
  7. – From birth to death: object lifecycle
  8. – Managing an object’s behavior
  9. – Best practices in code design
  10. – Integrating with third-party frameworks
  11. – Dependency injection in action!

appendix A – The Butterfly Container
appendix B – Smarty Pants for Adobe Flex

2016 Update: This book is still the only one in OPL with a decent discussion of Dependency Injection. After 7 years! Programmers using the AngularJS framework will want to understand this well, as will programmers of any mid to complex system.