Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

SOLID Principles

Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion

Dependency inversion principle

one should “Depend upon Abstractions. Do not depend upon concretions.” (EDIT: Concretions, I can only assume mean the opposite of abstraction– as far as I can tell things isn’t a CS concept.)

This means that in the controller, it is better to define

1
2
3
def current_user
  @current_user
end

than using the instance variable because right now the instance var is concrete but you might want to add logic and redefine it:

E.G.
1
2
3
def current_user
    @current_user ||= User.find_by_id(sessions[:id]) if session[:user_id]
end

Comments