현재 자바스크립트 표준은
     어디쯤?
   Javascript Standard of 2012
                                 Denny Lim <hello@iamdenny.com>
                                           <iamdenny@nhn.com>
객체
철학
문법
추상
수학
컴퓨터과학
객체지향 프로그램밍
객체지향 프로그래밍
왜 OOP를 해야 할까?
    배우기 쉽다
    유지보수 용이
    직관적인 코드
OOP의 특징
캡슐화
왜 캡슐화가 필요하지?
원하지 않는 무언가로부터 변수를 보호한다.
자바스크립트는
프로토타입 언어다
Private Data
코딩 컨벤션
fnto Hmnsedr{
ucin ua(Gne)
    /Piae
     /rvt
    ti.ng =1
     hs_Ae  ;
    ti.sedr=sedr| 'ae;
     hs_Gne   Gne | Ml'

    /Pbi
     /ulc
    ti.rwp=fnto({
     hsgoU   ucin)
         ti.ng+;
          hs_Ae+
    }
}
어디서든 접근가능
특권(Privileged) 메소드
fnto Hmnsepedr{
ucin ua(TmGne)
    /Piae
     /rvt
    vrng =1
     a Ae ,
       sedr=sepedr| 'ae;
        Gne  TmGne | Ml'

    /Piiee Mto
     /rvlgd ehd
    ti.rwp=fnto({
     hsgoU    ucin)
         ng+;
          Ae+
    }
}
일부 접근가능
모듈 패턴
모듈 패턴
fnto Hmnsepedr{
ucin ua(TmGne)
    /Piae
     /rvt
    vrng =1
     a Ae ,
       sedr=sepedr| 'ae;
        Gne  TmGne | Ml'

    /Pbi
     /ulc
    rtr {
     eun
         goU :fnto({
          rwp  ucin)
              ng+;
              Ae+
         }
    }
}
접근 가능
장점
쉽다
Private Data가 안전하다
단점
상속이 어렵다.
대형 프로젝트
 수많은 모듈
 복잡한 의존성
수많은 모듈
파일 하나에 모듈 하나
많은 파일들에 대한 이슈
 성능 이슈
 비동기 로딩
복잡한 의존성
불러올 모듈의 순서
수동으로 순서를 지정하기 힘듬
해결책은?
어렵지 않다.
다만, 표준이 없을 뿐.
CommonJS APIs
   Binary
   Console
   Encoding
   Filesystem
   IO
   Modules
   Packages
   Promises
CommonJS Modules
 Modules/1.0 : Node.js
 Modules/1.1
 Modules/1.1.1
웹서버 제작
vrht =rqie'tp)
a tp eur(ht';
ht.raeevrfnto (e,rs {
tpcetSre(ucin rq e)
 rswieed20 {CnetTp' 'etpan};
  e.rtHa(0, 'otn-ye: tx/li')
 rsed'el Wrdn)
  e.n(Hlo ol';
}.itn13,'2...';
)lse(37 17001)
cnoelg'evrrniga ht:/2...:37';
osl.o(Sre unn t tp/1700113/)
Arduino
breakout.js를 이용한 예제




     http://localhost:8888
AMD
Asychronous Module Definition
dfn(d,dpnece? fcoy;
eiei? eednis, atr)
사용법
dfn(
eie
     'con'
      acut,
     [srie,'usb]
      'evc' pbu',
     fnto(evc,pbu)
      ucinsrie usb{
          / PiaeCd
           / rvt oe

         / epr pbi AI
          / xot ulc Ps
         rtr {
          eun
              sgI :fnto({,
              inn   ucin)}
              sgOt:fnto( {,
              inu    ucin) }
              gtae:fnto( {,
              eNm    ucin) }
              stae:fnto( {
              eNm    ucin) }
         }
     }
);
다른 방법
(ucin)
fnto({
    / PiaeCd
     / rvt oe

      eprs={
       xot
           sgI :fnto({,
            inn  ucin)}
           sgOt:fnto( {,
            inu  ucin) }
           gtae:fnto( {,
            eNm  ucin) }
           stae:fnto( {
            eNm  ucin) }
      };

      dfn(acut,fnto({
       eie'con' ucin)
           rtr eprs
            eun xot;
      }
});
()
Jindo & jQuery
dfn(jno,[,fnto( {eunjno})
eie'id' ] ucin) rtr id; ;




dfn(jur' [,fnto( {eunjur; )
eie'qey, ] ucin) rtr Qey} ;
RequireJs
RequireJS
AMD 구현 by James Burke
비동기 로딩
2.0.5
사용법
<cittp=tx/aacit sc"eur.s>/cit
srp ye"etjvsrp" r=rqiej"<srp>




<cittp=tx/aacit sc"anj"<srp>
srp ye"etjvsrp" r=mi.s>/cit
main.js
rqie[ap] fnto(p)
eur('p', ucinap{
    apii(;
     p.nt)
};
)
app.js
dfn('i/con' 'i/esin]
eie[lbacut, lbssto',
    fnto(con,ssin{
     ucinacut eso)
         / 내부 코드
          /

         rtr {
          eun
              ii :fnto({
              nt  ucin)}
         }
     }
);
장점
클로벌 스코프 문제 해결
모든 것은 모듈안에서 작동
커피스크립트로도 컴파일 가능
플러그인을 지원함
단점
모듈 로딩 실패시 디버깅이 어렵다.
 잘못된 모듈 경로 설정
 플러그인 에러
여전히 풀리지 않은 문제
    수많은 모듈들
    수많은 파일들
    수많은 요청들
    성능 저하
Gracias
 BY Denny Lim
현재 자바스크립트 표준은 어디쯤

현재 자바스크립트 표준은 어디쯤