Posted almost 3 years ago by Alexander M. yegor256.com

Please read the original blog post by Yegor Bugayenko. He uses Java in the examples so I have tried to...

Posted over 4 years ago by Alexander M.

# models/movie.rb class Movie include ActiveModel::Model attr_accessor :id, :title, :genres, :date, :rating end # presenters/movies_presenter.rb require 'erb' class MoviesPresenter

Posted over 4 years ago by Alexander M.

Let's say we have two associated models: # app/models/user.rb class User < ApplicationRecord has_one :location end # app/models/location.rb class Location < ApplicationRecord...

Posted over 4 years ago by Alexander M.

It’s common to use the decorator/presenter pattern to wrap ActiveRecord objects and add view-specific logic. For example:

Posted almost 5 years ago by Alexander M.

The chain of responsibility is most useful when related objects are all trying to handle the same request. Let's...

Posted almost 5 years ago by Alexander M.

This pattern a simple but deceptively powerful technique that decouples events — such as user interface interactions — from the concrete actions...

Posted almost 5 years ago by Alexander M.

What is primitive obsession? Primitive Obsession is using primitive data types to represent domain ideas. For example, we use a...

Posted almost 5 years ago by Alexander M.

Simple Inheritance require 'json' module MovieFacts class Director def initialize(json) @raw_data = JSON.parse(json) end def name @raw_data.fetch('name...

Posted about 5 years ago by Alexander M.

The Policy Objects design pattern is similar to Service Objects, but is responsible for read operations while Service Objects are...

Posted about 5 years ago by Alexander M.

The main purpose of a value object is answer meaningful questions for our application. class Temperature include Comparable def initialize...

Posted about 5 years ago by Alexander M.

We’re writing software for managing a coffee shop. class CoffeeBatch attr_reader :bean_origin, :roast_level, :roast_date

Posted about 5 years ago by Alexander M. railscasts.com

Models in a Rails application can easily become very complicated as more logic gets added to them. Fortunately there are...

Posted over 5 years ago by Alexander M.

Let's say we have a user page with different textual and graphical information. Usually it means there will be...

Posted over 5 years ago by Alexander M. martinfowler.com

Replacing exceptions with Notification in validations A common way to approach validation is to run series of checks on some...

Posted over 5 years ago by Alexander M.

The memento pattern is a software design pattern that provides the ability to restore an object to its previous state...

This website uses short-lived cookies to improve usability.
Accept or learn more