MVC design pattern

YoungJoon Suh·2022년 4월 9일
0

MVC (model, view, controller)
What is MVC

  • SW Architecture Design Pattern
  • separates application functionalities
  • promotes organized programming
  1. Model
  • knowledge
  • handles data
  • interaction with Database
  1. View
  • visual representation of a model
  • what the users see (UI)
  1. Controller
  • receives input
  • process requests
  • get data from a model
  • pass data to the view

pseudo code
http://yourapp.com/users/profile/1

/routes
users/profile/:id = Users.getProfile(id)

/controllers
class Users{
function getProfile(id){
profile = this.UserModel.getProfile(id)

        renderView('users/profile', profile)
}

/models
class UserModel{
function getProfile(id){
data = this.db.get('SELECT * FROM users WHERE id = id')
return data;
}

/views
/users
/profile

    <h1>{{profile.name}}</h1>
    <ul>
  • Email: {{profile.email}}
  • Phone: {{profile.phone}}
  • profile
    저는 서영준 입니다.

    0개의 댓글