Frameworks 의 불편함
우량한아이들 새로운 아이들
예측하기 어려운 미래 전략
병주고 약주고..
(SPA + Server-side rendering?)
브라우저 지원범위.
커뮤니티, 문서화, 생태계, 급격한 변화
다양한 Syntax와 Pattern 이 존재
새로운 Learning costs
Intro
공통적으로
9.
On January 12,2016 Microsoft announced end of support for IE10, IE9, and IE8.
> Progressive Enhancement 전략과 함께 CSS3, ES 최신 버전의 사용도 가능
주변은,
Intro
Mobile Web Browser 의 꾸준한성장
> static view 중심의 서비스
> data 처리보다는 seamless한 animation 처리가 더 중요
ES2015,ES2016,ES2017 (thanks to jQuery, underscor, lodash)
> 다양한 readable syntax 제공. 다양한 라이브러리와의 이별
Standard transpilers (not Typescript, coffeeScript, JSX) with Builders
> ES를 더 땡길 수 있는 기회!
10.
우리 서비스는 지속가능해야한다
성능을 깊게 개선할 수 있어야 한다
동료가 쉽게 이해할 수 있는 코드를 구현해야 한다
다양한 환경에서 동작가능해야 한다
항상 더 좋은 UX를 고민하자
jQuery 개발자보단 Front-end 개발자가 되면 좋겠다
한편, FE개발자의 본능적 미션 !
Intro
“
”
Pure Templating Engine
vartemplateRunner = function(sHtml){
return function(oData){
for(var value in oData){
var re = "{%s?" + value + “s?%}";
sHtml = sHtml.replace(new RegExp(re, "ig"), oData[value])
}
return sHtml;
};
};
simple !
Templating
48.
서비스 logic 은clean하게 유지.
Template HTML은 쉽게 관리.
PreCompile 로 좀더 갈끔하게
template
html
template
html
template
html
PreCompile
[Build Step]
template
function
[Service Step]
복잡한 상황에서는 ?
Templating
let dependencyContainer ={
modalDependency : {
storagePlugin : new XHR(),
otherPlugin : new MyAsync()
}
}
let oModal = new Main(dependencyContainer.modalDependency);
Loose
Coupling
조금 아쉬움이 있다
직접 class를 쓴 거랑 큰 차이는 안나고, Lazy instantiation 이 안되고.
Static Dependency Injection
62.
Loose
Coupling
Register1
{XHR, Other2} newmainClass(...aDepClassInstance)
getInstance2
Injection3
DI Factory
XHR JSONP
Local
Storage
Other1 Other2 Other3
Dependencies Class
XHR Other2
Main Class
Dependency Injection
63.
Loose
Coupling
class Service {
constructor(storagePlugin,otherPlugin) {
this.storagePlugin = storagePlugin;
this.otherPlugin = otherPlugin;
}
getStorageData() {
return this.storagePlugin.getData();
}
getOtherData() {
return this.otherPlugin.getData();
}
}
Main Class
Dependency Injection
의존성 있는 Class과의 관계는 느슨하다.
64.
Loose
Coupling
//register depedencies
let myDI= new DIFactory();
myDI.register('xhr', XHR);
myDI.register('jsonp', JSONP);
myDI.register('other', Other);
//dependency injection
let cInstance = myDI.getInstance(Service, ["xhr","other"]);
console.log(cInstance.getStorageData());
Service code
Dependency Injection
Dependency 관계를 미리 정의하고, 인스턴스를 나중에 생성
65.
Loose
Coupling
class DIFactory {
constructor(){
this.matching = {};
}
register(name, dClass) {
this.matching[name] = new dClass();
}
getInstance(mainClass, aDepClass) {
let aDepClassInstance = aDepClass.map((v) => {
return this.matching[v];
});
return new mainClass(...aDepClassInstance);
}
}
DI Factory
이렇게 처리하기 위해 필요한
DI Factory 는 겨우 이정도
Register function
User
custom function
subscribepublish
‘FN_AFTER_FOCUS’
‘FN_AFTER_SUBMIT’
Remove methods of Dependencies.
Resuable
Codes
Plugin function
Emit Event
Plugin function
Loose
Coupling
Custom Function & Event Driven
68.
Resuable
Codes
Common
Component
AA Component BBComponent CC Component
A-1 plugin A-2 plugin B-1 plugin B-2 plugin C-1 plugin C-2 plugin
utility library
Component의 공통 기능
option 설정
plugin 등록
모든 파일에서 참고하는 유틸리티 메서
animation 처리
css 속성 추가
null 체크
..
Components
해당 component에 필요한 기능
Plugins
option으로 제공되는 추가기능.
LooseCoupling -> Resuable Component !
Loose
Coupling
69.
Clean Loose Coupling
Dependency를줄이는 패턴은 어렵고 복잡할 필요는 없다. 간단한 방법도 있다
커다란 Framework에서만 구현 가능한 것도 아니다.
다양하게 구현된 Module, Component 상황에 최적의 방법이 무엇인지 고민하
Loose
Coupling
Standard code withall tools,
사용자에게 더 좋은 UX를 제공하고,
개발에서 또 다른 즐거움을 느끼길 바랍니다 :-)
마무리
그리고, 앞으로 더 많은 분들과 함께,
이런 고민을 하게 되길 바라겠습니다
윤지수, codesquad
crong@codesquad.kr