Skip to content

General style/design issues #2

@MichaelXavier

Description

@MichaelXavier

I'm just going to pile these in for now. Please get to them when it makes sense to.

I noticed some problems while going through the code of this project that should be addressed and learned from:

  1. We don't use seattle.rb style method calls/definitions. Instead of def foo bar, baz, we do def foo(bar,baz). Instead of calling it as foo bar, baz, we prefer in almost every case foo(bar, baz). The only time when we are ok with going without parens is in DSLs, such as validates_presence of :email instead of validates_presence_of(:email).
  2. Huge huge lines. I don't really worry about long strings spanning more than 80 chars because ruby's syntax for multi-line strings that don't have newlines is even uglier. However, there are lots of specs that have hashes that are huge and all on one line. Create a new line for each key/value pair.
  3. Too many classes with only class methods. As a general rule of thumb, if you have a class that is all class methods, and doesn't make sense to instantiate, you could use a module instead, but there's a better solution: make them instance methods. A lot of the stateless class methods I saw are actually pretty big, unwieldy methods (10+ lines). Create a new class instead and spread out that code over many private methods and the code will be much easier. Also, just because you don't need any state now doesn't mean that you won't later. Please read this for more detail: http://blog.codeclimate.com/blog/2012/11/14/why-ruby-class-methods-resist-refactoring/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions