Application Layer ใน Clean Architecture: UseCase ที่ดีควรมีแค่นี้
Application Layer คือชั้น Orchestration ใน Clean Architecture — อธิบาย UseCase, Mapper และ Command/Query pattern พร้อมตัวอย่าง C# ที่แยก I/O ออกจาก Logic อย่างชัดเจน
ยินดีต้อนรับครับ! บล็อกแห่งนี้ถูกสร้างขึ้นเพื่อแบ่งปันประสบการณ์จริงจากเส้นทางสาย Software Development ไม่ว่าจะเป็นมุม Technical, การวิเคราะห์และออกแบบระบบ ไปจนถึงแนวทางการพัฒนา Architecture ที่ใช้งานได้จริงในโปรเจกต์ต่างๆ
ผมเชื่อว่า “การเรียนรู้ที่ต่อเนื่อง” คือสิ่งที่ทำให้เราพัฒนาทั้งทักษะและวิธีคิดได้ในทุกๆ วัน และหวังว่าบทความในเว็บนี้จะช่วยให้คุณสามารถนำความรู้ไปต่อยอดในการทำงานจริงได้ทันที
คุณจะได้พบกับเนื้อหาหลักในบล็อก เช่น:
หวังว่าที่นี่จะเป็นพื้นที่ช่วยให้เราพัฒนาและเติบโตไปด้วยกันบนเส้นทางสาย Dev ครับ 🌱💻
Application Layer คือชั้น Orchestration ใน Clean Architecture — อธิบาย UseCase, Mapper และ Command/Query pattern พร้อมตัวอย่าง C# ที่แยก I/O ออกจาก Logic อย่างชัดเจน
Core Layer คือ Domain Layer ใน Clean Architecture — อธิบายวิธีจัด project structure ด้วย Feature-first, UseCase-based Repository และ CQRS พร้อมตัวอย่าง C# ที่ใช้งานได้จริง
DataResponse<T> คือ HTTP Response Contract กลางของระบบ — แก้ปัญหา response format ต่างกันและ HTTP client field ต่างกัน ด้วย two-step unwrap พร้อม code จริงที่ใช้ได้ทั้ง backend และ frontend
implement InventoryRemoteAxiosClient และ InventoryRemoteFetchClient ด้วย DataResponse<T> pass-through — เห็นความต่าง error handling, timeout, streaming และ swap ที่ Composition Root บรรทัดเดียว
ออกแบบ share-client ใน Modular Monolith ด้วย axios + ServiceClient Interface จาก share-core — group ตาม Provider BC, ไม่มี transform, swap HTTP↔Internal ได้ที่ Composition Root โดย UseCase ไม่รู้เลย