[ 항해99] 54일차 OOP , MVC pattern
항해 99
54일 차 -
10:32 PM 집안이 32도... 창문을 다 열어놔서 바람이 많이 들어오는데도 이렇게 덥다.
한국이 언제부터이렇게 더웠지?
OOP
Object-Oriented Programming , 객체지향 프로그래밍 ;
이 개념이 정말 중요하고 , 거의 모든 개발자 취업할 때 requriement에서 이걸 본 것 같다.
근데 Node Js로 api나 살짝 만들면서 이것을 어떻게 class로 만들고 oop개념을 적용시킬지 감이 안 잡혔는데,
이렇게 Typescript를 쓰면서 적용시켜보니 신기했다. 이것 또한 학교에서 개념만 가르치지 말고, 숙제도 그런 typical 한 OOP문제 풀기만 시키지 말고 이런 걸 배웠으면 얼마나 좋았을까라고 생각했다.
constrctuor (생성자) => instance를 만드는 function
// constructor
function Student(name, age) {
this.name = name
this.age = age
this.sayFu= function () {
console.log("f you i am " + this.name)
}
}
var newStudent = new Student("bang", 19)
console.log(newStudent)
newStudent.sayFu()
inheritance : 상속을 구현하는 prototype
var array = [1,2,3]
var array = new Array(1,2,3)
var obj = {name: "sky"}
var ob = new Object({name: "sky")
array.prototpe
내장 함수들을 사용할 수 있는 이유는
prototype으로 현재 자신의 사용하고자 하는 객체의 부모에서 가져오는 것.
prototype은 부모의 것을 자식에게도 물려와서 쓰는 것
constructor는 자식에게 상속시키는 것.
OOP design pattern에도 여러 가지가 있는데, 일단 우리는 Web에서 많이 쓰이는 MVC pattern을 이 아저씨 tutorial을 따라 해 보기로 했다.
https://wanago.io/2018/12/10/express-mongodb-typescript-env-var/
Express MongoDB - TypeScript Express #2. Models, environment variables
In this part of the Express TypeScript tutorial, we cover using Express MongoDB with Mongoose. We also learn the concept of environment variables.
wanago.io
MVC :
https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
Model–view–controller - Wikipedia
From Wikipedia, the free encyclopedia Jump to navigation Jump to search Software design pattern Diagram of interactions within the MVC pattern Model–view–controller (usually known as MVC) is a software design pattern[1] commonly used for developing use
en.wikipedia.org
A common way of structuring an Express application is called Model-View-Controller. Some of the key components of MVC are controllers. They contain the logic of the application and deal with handling client requests. Since this course covers TypeScript Express, we use classes. For the sake of readable code, I also create a class for the app instance itself.
- typescript. 사용 시 can not find module에러 뜨는 거
당황하지 말고 에러 메시지 읽어 병신처럼 허우적 대지 말자 좀...
인제 이런 거 좀 보면 검색 없이 한 번에 알아서 할 줄 알아야 하는 거 아니니 😩 정신 차리자...
https://chiabi.github.io/2018/08/30/typescript/
TypeScript 사용할 때 'Cannot find module ...' 에러
웹팩과 타입스크립트를 공부하면서 자동판매기 프로젝트를 진행하다가 문제가 발생했다.처음에 loader등의 웹팩 설정에서 뭘 잘못한 줄 알았다. 결론적으로 문제는 tsconfig.js파일을 수정해 해결
chiabi.github.io
- npm 업데이트하라고 해서 npm -g install? 했다가
npm이 사라졌다, 또 허우적거리면서 이상한 곳에서 답을 찾고 잇다.
그냥 깔끔하게 node 새로 깔면 해결되는데...
이 정도면 수통 뚜껑에 머리 박아야 할 듯...
'IT > Bootcamp 항해99' 카테고리의 다른 글
[항해99] 57일차 타입스크립트 , 객체지향 프로그래밍 , MVC 패턴 (0) | 2021.08.03 |
---|---|
[항해99] 55일차 56일차 typescript , MVC (0) | 2021.08.02 |
[항해99] 52일차 github (0) | 2021.07.29 |
[항해99] 51일차 prisma. 프리즈마 npm (6) | 2021.07.28 |
[항해99] 49일차 & 50일차 prisma , test code , typescript (2) | 2021.07.27 |