31 Oct '16, 12am

Building Reusable Object-Oriented Systems: Inheritance

When building software, we often come across special cases, specializations, and shared logic. In object-oriented languages, inheritance is commonly used to deal with these. Building an API client Let’s say you are writing a client to interact with a third-party API that lists movies. It might look like: module MovieFacts class Client def initialize(client_id, client_secret) @client_id = client_id @client_secret = client_secret end def directors fetch_data("/directors").map { |director| Director.new(director) } end def director(name) Director.new(fetch_data("/directors/#{name}")) end private def fetch_data # fetch directors from API end end end The client returns a lightweight Director object based on the JSON response. module MovieFacts class Director def initialize(json) @raw_data = JSON.parse(json) end def name @raw_data.fetch("name") end def id @raw_data.fetch("id") en...

Full article: https://robots.thoughtbot.com/reusable-oo-inheritance

Tweets

Building Reusable Object-Oriented Systems: Modules

robots.thoughtbot.com 01 Nov '16, 12am

If you can’t fix it with duct tape, you haven’t used enough ~ American folk saying In a previous post , we looked at build...

Building Reusable Object-Oriented Systems: Comp...

robots.thoughtbot.com 02 Nov '16, 12am

In two recent posts, we’ve used single inheritance and multiple inheritance to build an API client that fetches directors ...

(1/3) Building Reusable Object-Oriented Systems...

robots.thoughtbot.com 05 Nov '16, 11pm

When building software, we often come across special cases, specializations, and shared logic. In object-oriented language...

(2/3) Building Reusable Object-Oriented Systems...

robots.thoughtbot.com 05 Nov '16, 11pm

In two recent posts, we’ve used single inheritance and multiple inheritance to build an API client that fetches directors ...

(3/3) Building Reusable Object-Oriented Systems...

robots.thoughtbot.com 05 Nov '16, 11pm

Building Reusable Object-Oriented Systems: Modules Joël Quenneville November 01, 2016 web ruby good code If you can’t fix ...

Composition vs Inheritance

robots.thoughtbot.com 03 Nov '16, 12am

Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. This is the op...

Building for the blind.

Building for the blind.

golfcourseindustry.com 30 Oct '16, 3pm

Norman Kritz is a Philadelphia-area pharmacist. Charitable involvement turned him into a golf course architect. His first ...

@thoughtbot really killing it this week with al...

robots.thoughtbot.com 04 Nov '16, 3pm

Optimising images for your website can be a bit of a black art, but it’s well worth doing as the bandwidth savings can be ...

Deep learning systems to explain their decisions

Deep learning systems to explain their decisions

newelectronics.co.uk 31 Oct '16, 12pm

“In real-world applications, sometimes people want to know why the model makes the predictions it does,” said graduate stu...

Use object-oriented Ruby to model a fundraising...

freelancer.com 05 Nov '16, 12am

I am a Computer Science major from the University of California, Davis. I have over 10 years of experience as a programmer...

Building a Well-Polished Ruby Gem

rubyflow.com 01 Nov '16, 6pm

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

From land or at sea – learn about the #missiled...

raytheon.com 04 Nov '16, 10pm

Thirteen countries rely on Global Patriot Solutions for air and missile defense. Our SM-3® missile and Exoatmospheric Kill...

FREE webinar 11/9 details @ENERGY's new team of...

usgbc.org 01 Nov '16, 4pm

Building envelopes are the shell of the built environment. Comprising walls, windows, roof and foundation, the envelope se...

Ungrounded PV Systems | Home Power Magazine

Ungrounded PV Systems | Home Power Magazine

homepower.com 30 Oct '16, 11am

Manufacturers are rapidly bringing to market lighter weight, more efficient, and space-saving transformerless inverters fo...