- vừa được xem lúc

SOLID Principles

0 0 10

Người đăng: Văn Lê Đình

Theo Viblo Asia

What is SOLID principles?

SOLID principles are the design principles allowing us to manage and control almost problems of the software design. They are a set of best practices that also helps developers to code and test much easier and more effective. Therefore, when the scale of the application grows bigger and bigger, SOLID can help you to easily maitain the app. Let's have a look at each principle one by one. SOLID is the acronym of:

  • The Single Responsibility Principle
  • The Open-Closed Principle
  • The Liskov Substitution Principle
  • The Interface Segregation Principle
  • The Dependency Inversion Principle

1. The Single Responsibility Principle

A class should have one reason to change.

What does this mean? This means every class in your code should have only one job to do. Everything in that class should be related to a single purpose.

2. Open-Closed Principle

The Open-Closed Principle requires that classes should be open for extension and closed to modification. That mean if you have a new logic, we have to easy to write as a new class, but it's very hard to modified old class.

3 Liskov Substitution Principle

The Liskov Substitution Principle states that subclasses should be substitutable for their base classes. That mean, if you have class B is a sub-class of class A, and some logic need class A to handle logic, we should be able to pass an object of B in this logic without any error.

4 Interface Segregation Principle

Segregation means keeping things separated, and the Interface Segregation Principle is about separating the interfaces. That mean all logic we have, should be separated, and the class not need to write logic that they do not handle

5 Dependency Inversion Principle

The Dependency Inversion principle states that our classes should depend upon interfaces or abstract classes instead of concrete classes and functions. This mean our class should not depend on what specific, it's should depend on what abstract

Bình luận

Bài viết tương tự

- vừa được xem lúc

Kotlin Extension Function ! Điểm chấm phá của Kotlin so với Java

Xin chào các bạn , mình là 1 moblie developer , lần đầu viết bài có gì sai sót mong các bạn thông cảm nhé !!. Khi các bạn cần các bạn phải viết đi viết lại nhiều lần rất tốn time, nhìn code thì rối.

0 0 10

- vừa được xem lúc

Kotlin Colletion và Sequences sự khác biệt là gì ? (Phần 1)

**Xin chào các bạn, hôm nay mình xin chia sẻ các bạn về collections và sequences trong kotlin . **.

0 0 19

- vừa được xem lúc

Làm lập trình viên tại các công ty nước ngoài có gì giống và khác các công ty tại Việt Nam?

Sau 1-2 năm làm việc tại Việt Nam, các lập trình viên thường có xu hướng ứng tuyển làm onsite/remote cho các công ty công nghệ nước ngoài. Một số quốc gia mà người Việt thường hay hướng tới như Úc, Si

0 0 9

- vừa được xem lúc

Hỗ trợ xây dựng web bằng Wordpress

WordPress là một hệ thống quản lý nội dung (CMS) miễn phí và mã nguồn mở được phát triển bằng ngôn ngữ lập trình PHP và sử dụng cơ sở dữ liệu MySQL. Nó được sử dụng rộng rãi như một nền tảng để xây dự

0 0 66

- vừa được xem lúc

HTML là gì? Kiến thức Tổng quan Về HTML

Tổng quam về HTML Tmarketing. .

0 0 4

- vừa được xem lúc

[Android] Setup CI-CD for Android app using Fastlane and GitHub Actions

GitHub Actions là 1 nền tảng miễn phí do GitHub cung cấp để giúp chúng ta tự động hoá quá trình CI/CD, cho phép người dùng định nghĩa các workflow tự động hoá các hoạt động trong phát triển phần mềm.

0 0 4