Skip to content

tak1n/ruby-learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guidelines for better Ruby and Rails Code:

1.) All OO Rules including this guideline should be treated like guidelines and not as rules / laws

2.) Use class-level interfaces only for building objects, Refactoring specific

3.) Use Dependency Injection for objects which need collaborators or configuration

4.) Immutability - use ValueObjects, or Objects without a public interface for changing its instance vars (mutable state will be your dead)

5.) Know and respect Sandi's Rules:

  • Classes can be no longer than one hundred lines of code.
  • Methods can be no longer than five lines of code.
  • Pass no more than four 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

6.) Convenience vs Explicitness

7.) Relationship

  • "has-a" -> Person has a Car -> Composition
  • "acts like" -> Mixin
  • "is-a" -> Inheritance