Thursdays the Flatiron School has an open house and invites perspective students, former students, and other members of the tech community to come and see what we are up to. To prepare for this event, our group was randomly divided up into groups of four and assigned to present one week during the next 10 weeks of the program. I had the honor and privilege of getting to go first.
Our group decided to draw on work from “Practical Object-Oriented Design in Ruby(POODR) by Sandi Metz. The book came out in late 2012 and has been the topic of much conversation within the Ruby community.
Sandi Metz’s book has been a great introduction to OOD. She writes in a simple and down-to-earth voice and draws on 30 years of experience. Much of her advice comes from perspective of someone who has been writing code and maintaining this same code for years. Her perspective on good OOD comes from a long-view perspective.
While doing research for this presentation, I stumbled across an episode of the Ruby Rogues podcast (Episode 87) where they do an in-depth interview with Sandi Metz about the book. She offers many interesting tidbits about her motivation for writing the book, her process, as well as her intended audience.
Metz intended the book to provide solid guidance for novice programmers. For myself, her matter-of-fact advice was welcomed and bit refreshing. Ruby, as a language with many methods that do the same thing and many different ways to solve the same problem, allows for immense creativity and individual style, but this freedom can intimidating for a novice who doesn’t have the experience programming or a deep understanding of the broader context in which the code will be living to choose the best design strategy.
Last week I wrote a post on SOLID Object-Oriented Design. My presentation on Thursday also elaborated on another set of rules Sandi Metz defines for novice programmers.
- Classes can be no longer than 100 lines of code.
- Methods can be no longer than 5 lines of code.
- Pass no more than 4 parameters into a method. Hash options are parameters.
- Controllers can instantiate only one object. Therefore, views can only know about one instance variable and views should only send messages to that object (@object.collaborator.value is not allowed).
During the interview with Sandi on Ruby Rogues, she suggests that novice programmers should follow the rules until you hate them. Only break the rules if and when you are able to fully explain why you need to break them.
All were in agreement that the first evening of Thursday presentations went well.
My slides can be found on Speaker Deck.