Mariano Giagante

Joined

2,330 Experience
23 Lessons Completed
0 Questions Solved

Activity

Posted in Dependency Inversion Principle Discussion

So in here I see you're passing the Server::Create object an argument with the provider, which is something it already has (since it's in the server, and the Server::Create object knows the server).

This creates the possibility that someone might eventually try to call #perform(:linode) on an instance that has a :digital_ocean as the server.

Do you think we should depend on documentation and testing in these cases?
If I have a passing test verifying this case is correctly handled, I think it'd be OK.

Posted in Refactoring with the Null Object Pattern Discussion

Something very interesting about this code is that with that "def user" you're overriding the definition of the parent class (ActiveRecord::Base) for the #user method, when actually there is none! :D Because of the way Active Record works, the #user method is generated at runtime. So, when you call super inside it, you're actually triggering that definition.

Posted in Decorators From Scratch Discussion

Amazing episode! I guess this kind of decorators are different to the decorators in the GoF book. Those inherit from the class they decorate to adhere the Liskov's substitution principle. I suppose this can't be done because active record naming conventions would not be compatible with this.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.