------art_150_14891283.1321818162972
Content-Type: multipart/alternative; 
	boundary---art_151_28847257.1321818162972"

------art_151_28847257.1321818162972
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

I seem to run into a couple of design issue a lot and I never know what is 
really proper. On one hand I often hear that I should limit coupling and 
stick to single responsibility, but when I do I often find it difficult to 
get the information to part of the program when it is needed. For example,

  class Singer
    def initialize(name)
      @name  ame
    end
    attr :name
  end

Then should Song be:

  class Song
    def new(singer)
      @singer  inger
    end
  end

or

  class Song
    def new(singer_name)
      @singer_name  inger_name
    end
  end

The later has less coupling, so according to principles I should use it. 
But if I later discover something in Song needs to know more about the 
singer, I'm in a bad way. e.g.

  class Song
    ...
    def play
      puts "Belting it out by #{@singer.name}, winner of 
#{@singer.grammy_count} grammies!"
    end
  end

I'd be in a fix if I had used the later Song class instead of the former. 
But then I suspect someone would remind me of SRP, single responsibility 
principle, and suggest instead:

  class SongPlayer
    def initialize(singer, song)
      @singer, @song  inger, song
    end
    def play
      puts "Belting it out by #{@singer.name}, winner of 
#{@singer.grammy_count} grammies!"
    end
  end

And yea, I guess that makes sense, since another singer might do a cover of 
some one else's song, right? But then, would it really be the exact same 
song? In most of my cases it's never the same "song" so I never have that 
kind of scenario. So is the SRP worth the extra classes it brings to the 
code then?

I sometimes think many OOP principles, SOLID or otherwise, arose out 
limitations of Java, and don't apply so well to Ruby.


------art_151_28847257.1321818162972
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I seem to run into a couple of design issue a lot and I never know what is really proper.&nbsp;On one hand I often hear that I should limit coupling and stick to single responsibility, but when I do I often find it difficult to get the information to part of the program when it is needed.&nbsp;For example,<div><br></div><div>&nbsp; class Singer</div><div>&nbsp; &nbsp; def initialize(name)</div><div>&nbsp; &nbsp; &nbsp; @name = name</div><div>&nbsp; &nbsp; end</div><div>&nbsp; &nbsp; attr :name</div><div>&nbsp; end</div><div><br></div><div>Then should Song be:</div><div><br></div><div><div style="border-style: initial; border-color: initial; ">&nbsp; class Song</div><div style="border-style: initial; border-color: initial; ">&nbsp; &nbsp; def new(singer)</div><div style="border-style: initial; border-color:nitial; ">&nbsp; &nbsp; &nbsp; @singer = singer</div><div style="border-style: initial; border-color: initial; ">&nbsp; &nbsp; end</div><div style="border-style: initial; border-color: initial; ">&nbsp; end</div></div><div><br></div><div>or</div><div><br></div><div><div style="border-style: initial; border-color: initial; "><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp;lass Song</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; def new(singer_name)</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; &nbsp; @singer_name = singer_name</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; end</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; end</div><div><br></div><div>The later has less coupling, so according to principles I should use it.ut if I later discover something in Song needs to know more about the singer, I'm in a bad way. e.g.</div><div><br></div><div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; class Song</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; ...</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; def play<br></div><div style="border-style: initial; border-color: initial; border-style: initial;order-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; &nbsp; puts "Belting it out by #{@singer.name}, winner of #{@singer.grammy_count} grammies!"</div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp; &nbsp; end<br></div><div style="border-style: initial; border-color: initial; border-style: initial; border-color: initial; border-style: initial; border-color: initial; ">&nbsp;nd</div></div><div><br></div><div>I'd be in a fix if I had used the laterong class instead of the former. But then I suspect someone would remind me of SRP, single responsibility principle, and suggest instead:</div><div><br></div><div>&nbsp; class SongPlayer</div><div>&nbsp; &nbsp; def initialize(singer, song)</div><div>&nbsp; &nbsp; &nbsp; @singer, @song = singer, song</div><div>&nbsp; &nbsp; end</div><div>&nbsp; &nbsp; def play</div><div>&nbsp; &nbsp; &nbsp; puts "Belting it out by #{@singer.name}, winner of #{@singer.grammy_count} grammies!"<br></div><div>&nbsp; &nbsp; end<br></div><div>&nbsp; end</div><div><br></div><div>And yea, I guess that makes sense, since another singer might do a cover of some one else's song, right? But then, would it really be the exact same song? In most of my cases it's neverhe same "song" so I never have that kind of scenario. So is the SRP worthhe extra classes it brings to the code then?</div><div><br></div><div>I sometimes think many OOP&nbsp;principles,&nbsp;SOLID or otherwise, arose outimitations of Java, and don't apply so well to Ruby.</div><div><br></div></div></div>
------art_151_28847257.1321818162972--

------art_150_14891283.1321818162972--