Josh Hepworth

Don't Be Afraid to Create a Class

In the early days of programming, pretty much everything seems like an uphill battle. It's all new, and nothing quite just comes to you. Sure, you can search Google and figure out what command you forgot, or what method name you couldn't remember, but that hurdle can subtly push new developers away from good habits.

While I've only been seriously pushing myself to do this for the past year, I think on of these pitfalls is not creating new classes when needed. A few things contribute to this hurdle:

  1. Not recognizing that a new class would be beneficial to the software's design
  2. Not feeling comfortable adding a file to the project
  3. Not knowing where the file should go in the project
  4. Not knowing what it should be named

Some of these may seem trivial, but each one makes it easier to just keep adding to existing files. Slowly this will lead to fat, oversized, incomprehensible classes. Just like this fat cat.

Fat Cat

While adding functionality, we must be comfortable without the project adding, naming, and designing new classes for our existing objects to collaborate with. To work towards this we should:

  1. Include clear, hierarchical structure for files (classes) in the project.
  2. Follow consistent naming and namespacing conventions, and, if possible, outline them in the project's README.
  3. Encourage other developers on the project to break functionality out into collaborator objects when new features are being added.
  4. In the context of Rails, truly understand and take to heart that we're developing in Ruby. Not everything needs to be a Active/Action__________ subclass.
  5. Be flexible, and encourage experimentation. Understand that branching out isn't permanent to ease mental barriers; know that we can always change our minds.