title: Ruby: Why instantiate an object and use an instance method when a class method would suffice?
body: <p>I am trying to learn design patterns by reading code that has been written by other people. Recently I've been focusing on the difference between class methods and instance methods.</p>
  
  <p>In some code I was reading, I came across the following use of an instance method:</p>
  
  <pre><code>class Foo
    def bar!(baz)
      # do something to baz
    end
  end
  
  my_foo = Foo.new
  my_foo.bar!(baz)
  </code></pre>
  
  <p>Why use an instance method here? The <code>Foo</code> class only exists to do <code>bar</code>, so why not just use a class method? From what I've been learning, my inclination would've been do to this:</p>
  
  <pre><code>class Foo
    def self.bar!(baz)
      # do something to baz
    end
  end
  
  Foo.bar!(baz)
  </code></pre>
  
  <p>Is there any reason to go with the first pattern? Is it just a matter of preference? My thought was that making an object uses memory and so the first one is actually inefficient, but am looking for any advice from more experienced folks. Thanks! </p>