You’re not receiving notifications from this thread.
How do I implement Facades Pattern on a already advanced Ruby on Rails project?
A few days ago read the four rules for developers and the Facade Pattern got my attention, however, find it somehow complicated to implement due to lack of good tutorials or the ones I've read implement it in very different ways.
Any help would be appreciated. Thanks.
The Facade Pattern is a pretty simple one. In Rails the guideline is usually to only have like one instance variable that your controller sets. Reality is that often times you need several variables to render the page, so they create a little Ruby object that's nothing special like their example of
Dashboard. It just has a few methods so you interact with the
Dashboard instead of several different instance variables in the view.
This pattern doesn't really improve your code all that much. It more hides the complexity behind a facade (hence the name) but it significantly improves the controller code.
You can simply create an
app/facades folder for this and as long as the directory loads (you may need to add it to the Rails config, can't remember), then all you'll have to do is create some basic Ruby classes that load the correct records and you're all set.
Since this pattern is simply and helpful but "doesn't really improve your code...", what would you recommend instead?
Thanks a lot!