에러와 버그의 차이점
·
Computer Science/Terminology and Concepts
에러(Error)와 버그(Bug)는 소프트웨어 개발에서 자주 혼용되지만, 의미와 맥락에서 차이가 있습니다.아래에서 두 개념을 비교합니다.1. 에러 (Error)정의: 소프트웨어가 실행 중 예상치 못한 동작을 수행하거나 실패할 때 발생하는 문제.발생 원인: 주로 런타임(Runtime) 또는 컴파일 단계에서 코드나 시스템이 의도한 대로 작동하지 않을 때 발생.유형:컴파일 에러: 문법 오류나 잘못된 코드 작성으로 인해 프로그램이 컴파일되지 않는 경우.예: int x = "text"; (데이터 타입 불일치)런타임 에러: 실행 중에 발생하는 문제로, 프로그램이 멈추거나 비정상적으로 종료됨.예: 0으로 나누기, NullPointerException, 메모리 부족 등.논리적 에러: 실행에는 문제가 없으나, 결과가 의..
Observer pattern
·
Frontend/JS Patterns
With the observer pattern,we can subscribe certain objects, the observers, to another object, called the observable. Whenever an event occurs, the observable notifies all its observers! observers: an array of observers that will get notified whenever a specific event occursAn observable object usually contains 3 important parts: subscribe(): a method in order to add observers to the observers li..
Module pattern
·
Frontend/JS Patterns
The module pattern allows you to split up your code into smaller, reusable pieces.modules allow you to keep certain values within your file private. Declarations within a module are scoped (encapsulated) to that module , by default.// export exampleexport function add(x, y) { return x + y;}export function multiply(x) { return x * 2;}export function subtract(x, y) { return x - y;}export functi..
Mixin pattern
·
Frontend/JS Patterns
An object used to Add reusable functionality to another object or class, without using inheritance.Simply, adding functionalities to the target prototype!We can add the dogFunctionality mixin to the Dog prototype with the Object.assign method. We can add animalFunctionality to the dogFunctionality prototype, using Object.assign. In this case, the target object is dogFunctionality.class Dog { co..
Middleware Pattern
·
Frontend/JS Patterns
실제로 요청과 응답 사이에 위치하는 미들웨어 기능 체인으로,하나 이상의 미들웨어 함수를 통해 요청 객체부터 응답까지 추적하고 수정할 수 있습니다. const app = require("express")(); const html = require("./data"); app.use( "/", (req, res, next) => { req.headers["test-header"] = 1234; next(); }, (req, res, next) => { console.log(`Request has test header: ${!!req.headers["test-header"]}`); next(); } ); app.get("/", (req, re..
Mediator Pattern
·
Frontend/JS Patterns
Mediator(중재자, 조정자) 패턴은component 가 중앙 지점인 중재자를 통해 서로 상호 작용할 수 있도록 합니다. 예를 들어,항공 교통 관제사가 모든 비행기가 다른 비행기에 충돌하지 않고안전하게 비행하는 데 필요한 정보를 받도록 하는 것과 같은 역할을 합니다. 모든 객체가 다른 객체와 직접 통신하여 many to many 관계가 되는 대신,객체의 요청은 Mediator 가 처리하는데, Mediator 는 이 요청을 처리하여 필요한 곳으로 전달합니다. Before. Mediator 패턴 적용 전. After. Mediator 패턴 적용 후. Chat room 이 예시 중 하나로,채팅방 내의 사용자들은 서로 직접 대화하지 않고, 대신, Chat room 이 사용자들 사이의 중재자 역할을 합니다. ..