This second post of the series leaves for a moment the creational patterns and speaks about one of the most important structural pattern: the Adapter.
The purpose of an adapter is “to convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.”
Suppose therefore [...]
Tags: design patterns, ruby
Posted in Development, Metodologies, Ruby |
Today we continue our analysis of the Rails Best Practices.
In the previous post we saw Named Scope, Model Association and
Following the same direction, in today’s post we’ll examine the use of Callback Model and Virtual Attribute.
1. Virtual Attribute
Suppose we have a customers list table defined as follows
123456create_table "clients", :force => true do |t|
t.string [...]
Tags: Best Practices, model callback, ruby on rails, virtual attributes
Posted in Development, Metodologies, Ruby |
An abstract Factory provides a common interface for creating families of related objects together.
The client object does not bother to build objects directly, but it calls the methods provided by this common interface.
Below is showed one possible implementation of an abstract Factory and its concrete Factories that implement it.
Suppose we have two categories of games [...]
Tags: design patterns, ruby
Posted in Development, Metodologies, Ruby |
Hello everyone.
With this post I would like to start a serie of articles concerning the description of the most common design patterns and how these can be applied with the Ruby language.
In the world of software engineering you don’t need to reinvent the wheel to face daily problems: these problems are often very common and [...]
Tags: design patterns, ruby
Posted in Development, General, Metodologies, Ruby |
Maintain a skinny controller is one of the most important things to increase the readability and testability of the code.
Let’s see some practices to move from the logic controller to the model.
1. Named Scope
In this first example we see how to use a named_scope to move the research methods in the model, simplifying the [...]
Tags: Best Practices, ruby on rails
Posted in Development, Metodologies, Ruby |
COMMENTS