Project Ramon

A learning journey from a Ruby noob perspective

Learning to Interface(pt. 1)


Today I’ve been reading up on Ruby accessor methods, using hash arguments in the constructor and getting better at building interfaces. I don’t have a lot to share at the moment as I’m still reviewing various resources to gain more knowledge on these topics. If you have any resources that would aid a beginner in best practices of these three topics feel free to add them in the comments.

One resource in particular I found informative was a confreaks video by Caike Souza titled: Powerful Interfaces.

In the video Caike goes over 3 laws of interfaces:

  1. An interface must do what it’s methods say that it does.
    • paying attention to naming is important.
    • the key is to focus on the messages that our object’s send more than the internals of what they do
      demonstrates this using a controller example using .save and .new
      • at 5:00
      • and 7:40
  2. An interface should do no harm.
    • should not interfere with other modules or do things outside its scoped purpose
      • at 10:00
  3. An interface should notify the client if something goes wrong
    • abstract the details into something that makes sense in the interface
      • at 11:25

If you’re a newbie interested in writing more maintainable code, check out his video.

Have an enjoyable weekend!


Categories: Ruby

Tags: ,

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