# SOLID Design Principles

## 😢 ปัญหา

แมวน้ำตัวหนึ่งนั่งเขียนโค้ดให้กับแอพอย่างเพลินๆ แล้วอยู่ๆก็พบว่าโค้ดต่างๆใน [GitHub](https://github.com/) ที่ถูกเขียนจากพวกเก่งๆ ทำไมมันช่างแต่งต่างกับของเราจุงเบย เช่นมีความเป็นระเบียบเรียบร้อยกว่า มีการจัดวางโครงสร้างที่ดีกว่า ออกแบบได้ดีกว่า และที่สำคัญคือเวลาที่เขาแก้ไขโค้ดหรือเวลาที่เขาเพิ่มความสามารถให้กับโค้ดนั้นเขาสามารถทำได้เลย แต่ถ้ากลับมาดูโค้ดของตัวเองกลับพบว่ามันมีอะไรต่อมิอะไรพันกันอิลุงตุงนังกันเป็นสปาเก็ตตี้ไปหมดกันนะ แล้วพวกป๋าๆใน GitHub เขาออกแบบโค้ดแบบนั้นได้ยังไง ทำยังไงเราถึงจะออกแบบได้แบบนั้นบ้าง?

## 😄 วิธีแก้ปัญหา

หนึ่งในการแก้ปัญหาเรื่องการออกแบบคือ **การทำตามมาตรฐานในการออกแบบที่เขาวางไว้** ซึ่งในคอร์สนี้จะมาพูดถึงการออกแบบโครงสร้างของโค้ดโดยใช้หลักที่ชื่อว่า S.O.L.I.D มาช่วยในการออกแบบกัน

{% hint style="info" %}
**เชื่อไหมว่า**\
ปัญหาเกือบจะ 80% ของการเขียนซอฟต์แวร์เกิดขึ้นเพราะคนที่เขียนโค้ดไม่ได้ทำตามมาตรฐานที่เขามีมาให้ เพราะโดยปรกตินักพัฒนาจะเรียนรู้การเขียนโค้ดซะส่วนใหญ่ แต่ไม่ได้มาดูเลยว่าภาษานั้นๆเขาวางมาตรฐานหรือสิ่งที่เรียกว่า **Best practic**e ของภาษานั้นๆหรือเทคโนโลยีนั้นๆเป็นยังไงบ้างไงล่ะ
{% endhint %}

## 🧭 ความรู้ในการจัดการปลาตัวนี้

{% content-ref url="/pages/-LmXwcjlVnUz2RAvIPNz" %}
[มารู้จักกับ SOLID กันดีกว่า](/basic/solid/intro.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LmY-oPStRD9jw4jpqBe" %}
[Single-Responsibility Principle](/basic/solid/srp.md)
{% endcontent-ref %}

{% content-ref url="/pages/-Lmtw4BxA9IipNtC9fCX" %}
[Open/Closed Principle](/basic/solid/ocp.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LmwSVetaZnwqBoftJ5w" %}
[Liskov Substitution Principle](/basic/solid/lsp.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LmykkSSC5ufsRJVW4OC" %}
[Interface Segregation Principle](/basic/solid/isp.md)
{% endcontent-ref %}

{% content-ref url="/pages/-Ln0VVvZibRgW33FLwaI" %}
[Dependency-Inversion Principle](/basic/solid/dip.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.saladpuk.com/basic/solid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
