Skip to content

Instantly share code, notes, and snippets.

@Mattia46
Mattia46 / CRUD.md
Last active November 3, 2015 14:33
Details about CRUD!!

CRUD


CRUD stand for 'Create', 'Read', 'Update' and 'Delete'. Each function of CRUD represents a major function of working with relational database (SQL). SQL is a language made for managing data held for relational databases.

Example:

Create:

INSERT INFO table_name (:key => value);

Read

@Mattia46
Mattia46 / Database.md
Last active November 2, 2015 16:17
Differences between Relational DB, NoSQL and Flat files

Relational DB vs NoSQL vs Flat files:

Relational DB: The relational database organizes data into table with columns and row.Each row has an unique 'primary key' identifying the row. The column represent a row attribute. Most of the relational database system use SQL (Structured Query Language) as the language for insert, querying, updating and deleting information.

NoSQL is a non relational database so without a predefined schema. The simplest NoSql structure is the Hash (key => value) that let the NoSQL being more scalable, agile and provides superior performance.

The Flat Files has not relational structure. An example of Flat Files is a text document or lines of ASCII test. Usually the flat files contain one record per line separated with a comma.

Mattia & Julien

@Mattia46
Mattia46 / journey_log.rb
Created October 22, 2015 14:11 — forked from leoallen85/journey_log.rb
Dependency Injection in the method
describe JourneyLog do
subject(:journey_log) { described_class.new }
let(:journey_klass) { double(:journey_klass) }
let(:journey) { double(:journey) }
describe "Starting a journey" do
it "adds a journey to the log" do
allow(journey_klass).to receive(:new).with(:station).and_return(journey)
@Mattia46
Mattia46 / journey_log.rb
Created October 22, 2015 14:11 — forked from leoallen85/journey_log.rb
Dependency Injection in the constructor
describe JourneyLog do
subject(:journey_log) { described_class.new(journey_klass: journey_klass) }
let(:journey_klass) { double(:journey_klass) }
let(:journey) { double(:journey) }
describe "Starting a journey" do
it "adds a journey to the log" do
allow(journey_klass).to receive(:new).with(:station).and_return(journey)
@Mattia46
Mattia46 / Dependency_injection.md
Created October 22, 2015 12:25
How to create a flexible dependancy between classes

DEPENDANCY INJECTION

'An object depends on another object if, when one object changes, the other might be forced to change in turn'

Sandi Metz Bad example

class Hacker

 def initialize

Encapsulation is the packing of data and functions into a single component.

Encapsulation means that the internal representation of an object is hidden from the outside. Only the object can interact with its internal data. Public methods can be created to open a defined way to access the logic inside an object.

class Document  
  attr_accessor :name

  def initialize(name)
    @name = name
 end
@Mattia46
Mattia46 / single_responsibility_principle.md
Last active October 20, 2015 10:02
How to make your code flexible and elegant

Single Responsibility Principle

What is the SRP?

The Single Responsibility Principle (SRP) is a way of making your code more elegant and flexible. It is part of the SOLID design principles in computer programming. The principle states that every class should have only one resposibility.

In the context of the Single Responsibility Principle (SRP) we define a responsibility to be “a reason for change.” If you can think of more than one motive for changing a class, then that class has more than one responsibility.

Bob Martin