Course Week01 Day04

Today was all about writing well organized code. Atomizing methods, and making sure classes don’t have method envy with each other, and making sure changes in one class doesn’t change the functionality of another, even if one’s dependent on the other.


  • having a method that takes a &block as an argument and the does: in its body is doing the same thing as a method that yield(stuff)
  • $PROGRAM == __FILE__  is the same as $0 == __FILE__
  • when writing a class and needing to pass around data
    • use an instance variable if that data never changes during the object’s lifetime
    • pass it as an argument if it changes
    • alternatively – make factory methods that act as instance creators
      • have class methods that create instances of a class that store information
  • using a regex to match a string is powerful because it can match on length and content:
    • /^.{7}$/ would match strings that are 7 characters long and don’t contain say dashes ( – ) or apostrophes ( ‘ )

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s