Books: Ruby on Rails and Design Patterns

In pursuit of my Master’s degree, I had planned to take a course called “Object Oriented Languages and Systems” during the summer of 2012. However, due to some unfortunate circumstances, I was unable to continue the course. Being that I have been more focused on embedded design, my last experiences with object oriented languages were not so recent. So, in an effort to ensure that I would be very prepared for the class, I took it upon myself to begin reading all four textbooks suggested for the class early to get a good head start. The four books were:

Object-Oriented Design Using Java [ISBN-13: 978-0072974164]
Head First Design Patterns [ISBN-13: 978-0596007126]
Programming Ruby 1.9: The Pragmatic Programmers’ Guide (Facets of Ruby) [ISBN-13: 978-1934356081]
Agile Web Development with Rails (Pragmatic Programmers) [ISBN-13: 978-1934356548]

I moved around between books a bit since I didn’t know what the sequence of the material in the class would be. I ended up reading the whole way through Object-Oriented Design Using Java first. This book covers a lot of material in its relatively few pages (by comparison to the other three books). There are a lot of points packed into each chapter, which from the details I knew about the course I was going to take, were highlighted by the course. However, I believe the tight correlation was probably due to the professor’s preference towards this particular book, not plain old coincidence. Regardless, the material was good and the presentation satisfactory. I didn’t feel out of my depth with the examples, even having not programmed in Java for some years. There were entire chapters devoted to examples, which I thought was helpful, though the last example chapter, if I recall correctly, was a bit tricky. I did find myself re-reading the book examples for some things, such as the trickier inheritance occurances (when using general versus specific type assignment), where class notes attempted to describe and fell a bit short.

My next read was the Programming Ruby book, as I found out that the beginning portion of the class would focus on Ruby on Rails. Ruby is a fascinating language. I find it to generally be uncomplicated, but there are also things you can write that could take a while to understand. Some new concepts to me were things like closures and mixins. Though I have yet to find a cool use for closures, I have this feeling that in the right scenario, they would be awesome. Mixins are also awesome in their own right. Mixins allow classes to have something that resembles multiple inheritance, but without some of the pains multiple inheritance can cause. Another thing about Ruby that I like is the “everything is an object” treatment. I know this can bite, but the options it opens up are pretty sweet. With regard to the book itself, I liked the organization of the book pretty well. There were only a few spots that I felt were lacking in explanation, but goodness, there is certainly a lot in the book already. Having read this book and a portion of the Agile Rails book, I felt I understood significantly more than those students I talked to (who had never touched Ruby before).

I interjected some reading of the Agile Web Development with Rails book once I heard that the first project for the class would use Ruby on Rails. I enjoyed following my way through this book, setting up a bookstore for their very own book company. Once I got several chapters in, they started to add fanciful things to their site, that I’m sure were nice, but with the impending project, I felt I needed to jump into things which were in later chapters. I have not investigated to see if there was some organization choosen, or even if it would have been within reason to skip any part. Instead I skipped around and tried to read the later chapters without implemnting as with the earlier chapters. Things seemed to work out okay by this method, though I figure at some point it would be good to continue the original path through the book. I do have to say, the amount of behind the scenes stuff that Rails does is both a blessing and a curse in that you both get so much for “free”, but so much of it is not obvious, you have to look or read to find it.

Lastly, Head First Design Patterns. This book is gigantic at over 600 pages, but don’t let that be daunting. The layout of the pages in this book is not like your typical book. The pages contain random amounts of information, with images and text smattered about in a generally pleasing way. There are questions with and without answers scattered about, and sometimes a crossword at the end of the chapter. This book is extremely example driven, which is great for someone like me. I also enjoyed the somewhat ADD style, which made it such that if you felt your attention might be moving elsewhere, it was probably to some other spot on the page instead of somewhere else entirely. The organization was well thought through, as they referenced design patterns from previous chapters to make points or comparisons fairly often. Having spent some time trying to understand Clang previously, when I got to the chapter on iterators and composition, all I could think of was “so Clang isn’t just intended to cause confusion, it must have taken from the composition pattern”. I’m not sure that simply knowing that would solve all the confusion with I experienced with Clang and trying to use it to generate my own LLVM, however, it certainly gave me some well needed perspective. I’d also like to point out that this book discusses MVC and its makeup in some detail with good descriptions and examples in one of the later chapters, which is a key part of how Ruby on Rails expects you to structure your code, so it could have been helpful to get this reading done first had I known this detail.

I hope that in the future I can spend some time to become a bit more familiar with Ruby (and Rails). I’ve also noticed some design patterns in code descriptions that colleagues have written up, though I’m not even sure of the prevalence of the concept in non-object oriented languages.