Last night I attended to a really interesting event hosted by Social Chorus where Sandy Metz gave a presentation call “Rules”. Here I am posting couple pictures and pay attention to the one where she list the rules on OOP.
Here are Sandi’s rules:
1. Classes can be no longer than 100 lines of code
2. Methods can be no longer than five lines of code
3. Pass no more than four parameters into a method
4. Rails controller actions can only instantiate one object
5. You can pass only one instance variable to a view
As Sandi says, “You can learn these rules in a few minutes, but following them will improve your code forever”.
Who is Sandy Metz? She is the author of POODR: Practical Object-Oriented Design in Ruby, a book strongly suggested to read by my teacher Anne Spalding at Dev Bootcamp. I read couple chapters back then but after listening to her talk, this book got a place in my “Must read” books.
What did I learned from the talk? Besides the “Rules” I also learned that when I get the opportunity to work with a team of engineers, I need to keep in mind to not leave “trash code” (example: broken code) because besides the horrible negative impact that I will be making into my team, I could also influence on slowing down my team (because they will be spending time refactoring my code, or cleaning after me) and at some point the “good developers” could get tired of it and leave the team
My next steps after being inspire by this talk?
Put even more effort on learning testing my code and refactoring, refactoring!! and hopefully at some point I can check mark all the Sandy’s rules =)