-
How to use discipline, consistency and code organization to make your code grow more gently.
-
As you cycle through patterns, your application is becoming a patchwork of different coding techniques.
All those new techniques actually help, or if you are just adding layers of inderection.
-
Large applications are large so what we can do is organize a codebase in a way that "scales logarithmically".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NotesController < ApplicationController | |
def index | |
load_notes | |
end | |
def show | |
load_note | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/admin/base.rb | |
class Admin::BaseController | |
include Admin::CRUDMethods | |
class NotImplementedError < StandardError; end | |
def index | |
list_resources | |
end |
The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.
- Single Responsibility Principle: a class should have only a single responsibility
- Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
- Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
- Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import cv2 | |
import matplotlib.pyplot as plt | |
import time | |
# Training with 50k cifar images and testing with their set. | |
# be sure to use cifar data in python format. |