Design Patterns

 

Great software

Is n't just built. Its designed.

A layman's definition of design

Design in its simplest form is simply problem solving.

 

Design Patterns

design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.

Why Design Patterns?

  • No need to reinvent the wheel
  • Saves time
  • Increases productivity

MVC

Model - View - Controller

 

Before we go further

Design patterns are language agnostics. They can be used in any language so long as the basic concepts are understood. 

Models

Business logic and interaction with the database 

 

For example, a social network's models include users(usernames, email, passwords, bio e.t.c)

Views

Views refer to the presentation of content

We use views to organize what the display looks like. In some cases this is where the user has interaction with software.

Controllers

Controllers are unique in the sense that they seat in between models and views

Think of them as middle men. Whats crucial about them is that they handle requests.

MVC in practise

Rails Structure of MVC

Text

app
  -> Models
      -- user.rb
  -> Views
      --layouts
      --users
         --show.html.erb
         --index.html.erb
         --edit.html.erb
         --new.html.erb
  -> Controllers
       --users_controllers.rb

Questions?

Design Patterns: Introduction to MVC

By Alvin Kato

Design Patterns: Introduction to MVC

A mini introduction to MVC using Rails

  • 307