Posts

Showing posts with the label oop

NestJS Practice Series

Image
Introduction NestJS is a progressive NodeJS framework designed for building efficient, reliable, and scalable server-side applications. Built on top of TypeScript (but also supporting pure JavaScript), NestJS combines elements of Object-Oriented Programming (OOP), Functional Programming (FP), and Functional Reactive Programming (FRP). The outstanding advantages of NestJS include: Modular architecture: Helps organize code scientifically, easy to maintain and expand for large projects. Powerful TypeScript support: Fully leverage static typing to minimize errors during development. Flexibility: Allows easy integration with other libraries (like Express or Fastify) and supports a wide variety of communication protocols (REST, GraphQL, WebSockets, Microservices). Rich ecosystem: Provides ready-to-use tools for processing common tasks like Validation, Caching, Database mapping (TypeORM/Prisma), and Authentication. Dependency Injection: A powerful mechanism that helps manage...

Explanation of SOLID in OOP

Image
Introduction SOLID is a set of five fundamental principles that support enhancing maintainability and ease of extension for future software development. Introduced by software engineer Robert C. Martin, also known as "Uncle Bob," in the book "Design Principles and Design Patterns," the SOLID principles include: S - Single Responsibility Principle O - Open/Closed Principle L - Liskov Substitution Principle I - Interface Segregation Principle D - Dependency Inversion Principle Below, we'll provide detailed explanations and analysis for each principle. Note that the examples in this article are implemented using TypeScript , but you can rewrite them in other object-oriented programming languages . 1. Single Responsibility Principle (SRP) A class should have one and only one reason to change, meaning that a class should have only one job. This is considered the simplest and most crucial principle because it relates to most of the other principles. Simply put, when ...