Design Pattern
๐ ๋ชฉ์ฐจ Introduction What is Observer Pattern? Implementation Conclusion Reference ๐ Introduction ์๋
ํ์ธ์. ์ด๋ฒ ํฌ์คํ
์์๋ Observer Pattern์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค. ๐ What is Observer Pattern? ์ต์ ๋ฒ ํจํด์ ๊ฐ์ฒด์ ์ํ ๋ณํ๋ฅผ ๊ด์ฐฐ ํ๋ ๊ด์ฐฐ์๋ฅผ ๋ฑ๋กํ์ฌ ์ํ ๋ณํ๊ฐ ์์๋ noti๋ฅผ ์ฃผ๋ ๋์์ธ ํจํด์
๋๋ค. ๐ Implementation ๋จผ์ subjectํด๋์ค๋ฅผ ์ ์ ํด๋ณด๊ฒ ์ต๋๋ค. class Subject { constructor() { this.observers = []; return this; } addObserver(observer) { this.observers.push(observe..
Javascript Study
๐ ๋ชฉ์ฐจ Introduction What is call? What is apply? What is bind? Usage Conclusion Reference ๐ Introduction ์๋
ํ์ธ์. ์ด๋ฒ ํฌ์คํ
์์๋ ๊ฐ์ฅ ํท๊ฐ๋ฆฌ๋ call, apply, bind์ ๋ํด์ ์์๋ณด๊ฒ ์ต๋๋ค. ๐ What is call? ๋จผ์ call์ ์ ์ํ๊ธฐ ์ ์ ํด๋น ์์ ๋ฅผ ๋ด์ฃผ์ธ์. const example = (a, b, c) => { console.log(a + b + c); }; example(1, 2, 3); // 6 example.call(null, 1, 2, 3); // 6 example์ ์คํ์ํจ ๊ฒ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก example.call๋ ๋๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋
๋๋ค. ๋์น๋ฅผ ์ฑ์ ๋ถ๋ ์๊ฒ ์ง๋ง call์ ์ฒซ๋ฒ ์งธ ์ธ..
Vue BDD
๐ ๋ชฉ์ฐจ Introduction Cypress api mock ํ๊ธฐ Conclusion Reference ๐ Introduction ์๋
ํ์ธ์. BDD๋ง์ง๋ง ์๊ฐ์ผ๋ก ์ด์ Cypress์์ api call๋ฅผ mock ํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค. ํด๋น ์ฝ๋๋ ์ฌ๊ธฐ์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ํด๋น ์์ ๋ jsonplaceholder์์ todo๋ฅผ ํ๋ ๋ฐํํ๋ ์์ ์
๋๋ค. ๐ Cypress api mock ํ๊ธฐ API๋ฅผ mock ํ๊ธฐ์ ์ ๋จผ์ ํ๋์ ์ ์ํด๋ณด๊ฒ ์ต๋๋ค. Todo์ ์ ๋ชฉ์ 'hello'๋ผ๊ณ ์ฐ์ฌ์์ด์ผ ํฉ๋๋ค. Feature: Todo Background: Given I am on the main page Scenario: Todo display Then I can see Todo with..
Vue BDD
๐ ๋ชฉ์ฐจ Introduction Gherkin ์ฌ์ฉ Gherkin + Cypress Vuex store mocking ํ๊ธฐ Conclusion Reference ๐ Introduction ์๋
ํ์ธ์! ์ค๋์ ์ง๋ ํฌ์คํ
์์ ๋ค๋ค๋ Gherkin์ ์ค์ ๋ก Cypress์ ์ ์ฉํ๋ ํฌ์คํ
์
๋๋ค. ํด๋น ์ฝ๋๋ ์ฌ๊ธฐ์์ ํ์ธ ํ์ค ์ ์์ต๋๋ค. ๐ง ํด๋น ํฌ์คํ
์ ์์ ๋ ๊ฐ๋จํ counter ๊ตฌํ์
๋๋ค. ๐ Gherkin ์ฌ์ฉ Counter๋ ์ธ๊ฐ์ง ์๋๋ฆฌ์ค์ ๋ํด์ ์๋์ด ํด์ผํฉ๋๋ค. count์ ์์ ๊ฐ์ 0์
๋๋ค. ํ๋ฌ์ค ๋ฒํผ์ ๋๋ฅด๋ฉด count๊ฐ 1 ์ฆ๊ฐ ํด์ผํฉ๋๋ค. ๋ง์ด๋์ค ๋ฒํผ์ ๋๋ฅด๋ฉด count๊ฐ 1 ๊ฐ์ ํด์ผํฉ๋๋ค. ์ด์ ํด๋น ์๋๋ฆฌ์ค๋ฅผ Gherkin์ผ๋ก ์ฎ๊ฒจ๋ณด๊ฒ ์ต๋๋ค. # Counter.featu..
Design Pattern
๐ ๋ชฉ์ฐจ Introduction Module Pattern ์ด๋? Moudle Pattern ๊ตฌํ Module Pattern์ ์ฅ๋จ์ Conclusion Reference ๐ Introduction ์๋
ํ์ธ์! ์ด๋ฒ ํฌ์คํ
์์๋ ์๋ฐ์คํฌ๋ฆฝํธ์์ module pattern์ ๋ํด์ ๊ณต๋ถํด๋ณด๊ฒ ์ต๋๋ค.๐ Singleton ํจํด๊ณผ๋ ๋น์ทํ์ง๋ง Singleton์ฒ๋ผ ํ๋์ instance๋ง ๋ง๋๋๊ฒ์ด ์๋ ๋ค์์ instance๋ฅผ ๋ง๋๋ ๊ฒ์ด module pattern ์
๋๋ค! ๐ Module Pattern ์ด๋? Module pattern์ด๋ ์ ์ฒด ์ดํ๋ฆฌ์ผ์ด์
์ผ๋ถ๋ฅผ ๋
๋ฆฝ๋ ์ฝ๋๋ก ๋ถ๋ฆฌํ์ฌ ๋ง๋๋ ๊ฒ ์
๋๋ค. ๋ค๋ฅธ ์ฌํ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์ฒ๋ผ ์๋ฐ์คํฌ๋ฆฝํธ๋ ์ ๊ทผ ์ ํ์(public, private,...)๊ฐ ์๊ธฐ ..
Vue BDD
๐ ๋ชฉ์ฐจ Introduction Gherkin?์ด ๋ญ๋ฐ? Gherkin ํค์๋ Good And Bad Gherkin example Conclusion Reference ๐ Introduction ์๋
ํ์ธ์. ์ด๋ฒ ํฌ์คํ
์ ๋๋์ด BDD๋ฅผ ์์ํ๋ ์ฒซ๊ฑธ์ ์
๋๋ค. ๋ฐ๋ก Gherkin์ธ๋ฐ์. ๊ทธ๋ผ ์ง๊ธ๋ถํฐ Gherkin์ด ๋ญ์ง ์ฌ์ฉ์ ์ด๋ป๊ฒ ํ๋์ง์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค. ๐ ๐ Gherkin?์ด ๋ญ๋ฐ? Gherkin์ด๋ cucumber์ ํํ ํ์์
๋๋ค. ์๋ ๊ทธ๋ฆผ์ ๋ด์ฃผ์ธ์. Gherkin์ ๋ฐ๋ก ์ด๋ ๊ฒ Given, When, Then์ผ๋ก ์ ์๋ฅผ ํฉ๋๋ค. Before Gerkin์ ๋ณด๋ฉด ๊ธฐํ์๋ก ๋ณด์ด๋ ์ฌ๋๊ณผ ๊ฐ๋ฐ์๋ก ๋ณด์ด๋ ์ฌ๋์ด ์๋ก ๋ํ๋ฅผ ํฉ๋๋ค. ๊ฐ๋ฐ์์ ๋ง์ ๊ธฐํ์๋ ์ดํด๋ฅผ ๋ชปํ์ฃ . ํ์ง๋ง Ghe..
Vue BDD
๐ ๋ชฉ์ฐจ Introduction Setting์ ์ด๋ป๊ฒ ํด์ผํ ๊น? Conclusion Reference ๐ Introduction ์๋
ํ์ธ์ ์ด๋ฒ ํฌ์คํ
์ ์ง๋๋ฒ์ ์๋ ค๋๋ฆฐ๋๋ก BDD๋ฅผ ์ธํ
ํ๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์๋ ค๋๋ฆฌ๋ ค๊ณ ํฉ๋๋ค. ์ค์ ์ฝ๋๋ ์ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์๋ฉด ๋ฉ๋๋ค. ๐ ๐ Setting์ ํ๋ ๋ฐฉ๋ฒ ๋จผ์ cypress-cucumber-preprocessor๋ฅผ ์ค์นํด์ฃผ์ธ์ npm i -D cypress-cucumber-preprocessor package.json package.json์ ํด๋น ๋ด์ฉ์ ์ถ๊ฐํด์ฃผ์ธ์. "cypress-cucumber-preprocessor": { "nonGlobalStepDefinitions": true, "stepDefinitions": "tests/e2e/specs",..
Design Pattern
๐ ๋ชฉ์ฐจ Introduction Singleton ํจํด์ด๋? Singleton ํจํด ๊ตฌํ Conclusion Reference ๐ Introduction ์๋
ํ์ธ์ ์ด๋ฒ ํฌ์คํ
์์๋ design pattern์ค singleton ํจํด์ ๋ํด์ ๋ฐฐ์๋ณด๊ฒ ์ต๋๋ค! ๐ Singleton ํจํด์ด๋? ์ด๋ฆ์์ single์ด ๋ค์ด๊ฐ๋ ๊ฒ์ผ๋ก ์ ์ถํ ์ ์๋ฏ์ด ์ ์ฒด ์์คํ
์์์ ํ๋์ ์ธ์คํด์ค๋ฅผ ์กด์ฌํ๋๋ก ๋ณด์ฅํ๋ ๊ฐ์ฒด ์์ฑํจํด์
๋๋ค. ๋ฐ๋ผ์, ๊ฐ์ฒด ๋ฆฌํฐ๋ด๋ ๋ชจ๋ ์ฑ๊ธํค ํจํด์ด๋ผ๊ณ ํ ์ ์์ต๋๋ค. ํ์ง๋ง ๋ชจ๋ ์์ฑ์ด ๋ค ๊ณต๊ฐ๊ฐ ๋์ด์๊ธฐ์ ๋น๊ณต๊ฐ๋ฅผ ๋ง๋ค๋ ์ ๋๋ก ๋ singleton ํจํด ์
๋๋ค. ๐ Singleton ํจํด ๊ตฌํ Singleton์ ๊ฐ์ฒด ๋ฆฌํฐ๋ด + ํด๋ก์ ๋ก ๊ตฌํํ ์ ์์ต๋๋ค. ๋ค์ ์ฝ๋๋ฅผ ๋ด์ฃผ์ธ์. ..