찾다
웹 프론트엔드JS 튜토리얼스크리밍 아키텍처란 무엇인가?

What is Screaming Architecture?

Screaming Architecture는 유명한 소프트웨어 개발자이자 사상가인 Robert C. Martin(종종 "밥 삼촌"이라고도 함)이 도입한 개념입니다. 이 용어는 독특하게 들릴 수도 있지만, 시스템 아키텍처가 애플리케이션의 주요 관심사와 사용 사례를 반영하도록 만드는 데 중점을 두는 소프트웨어 설계의 강력한 원칙을 나타냅니다. 간단히 말해서 소프트웨어 아키텍처는 의도와 목적을 "고명"해야 합니다.

이 종합 가이드에서는 Screaming Architecture의 기본 사항, 기존 소프트웨어 아키텍처와의 차이점, 도메인 중심 설계에서의 중요성, 프로젝트에서 이 아키텍처를 구현하는 방법을 살펴보겠습니다. 또한 Screaming Architecture가 코드 가독성, 유지 관리성 및 장기 확장성을 향상시킬 수 있는 실제 사례와 시나리오도 다룰 것입니다.

왜 "비명을 지르는" 건축인가?

Screaming Architecture의 기본 아이디어는 코드베이스의 기본 구조가 비즈니스 목적을 즉시 전달해야 한다는 것입니다. 이는 기술 프레임워크, 도구 또는 기타 부차적인 관심사를 강조할 수 있는 기존 아키텍처와 대조됩니다. Screaming Architecture에서는 구현 세부 사항보다 도메인 문제가 우선합니다.

밥 마틴 삼촌은 이를 비유로 설명했습니다. 건물에 다가가 그 건축물을 본다고 상상해 보세요. 간판이 없어도 도서관인지, 학교인지, 사무실인지 알 수 있는 경우가 많습니다. 소프트웨어 아키텍처에도 동일하게 적용되어야 합니다. 애플리케이션의 폴더 구조와 디자인을 보면 그것이 무엇을 위한 것인지 즉시 이해해야 합니다. 회계 시스템을 구축하는 경우 아키텍처는 "Django", "Spring Boot" 또는 "React"가 아닌 "account"를 외쳐야 합니다.

프레임워크 중심 아키텍처의 문제점

많은 프로젝트에서 기술 프레임워크에 대한 초점이 비즈니스 또는 도메인 논리를 무색하게 만듭니다. 다음과 같은 파일 구조를 찾을 수 있습니다.

controllers/

services/

repositories/

models/

이 디렉토리는 유용하지만 소프트웨어가 해결하는 핵심 문제를 반영하기보다는 기술적인 역할을 설명합니다. 예를 들어 이 구조는 시스템이 MVC(Model-View-Controller)를 사용한다는 것을 알려주지만 시스템이 재무 데이터, 사용자 관리 또는 콘텐츠 생성을 처리하는지 여부에 대한 통찰력은 제공하지 않습니다.

프레임워크 함정

프레임워크를 지나치게 강조하면 기술 상용구로 인해 비즈니스 로직이 모호해지는 코드베이스가 탄생합니다. 프레임워크 규칙을 중심으로 구축된 시스템은 해당 프레임워크와 긴밀하게 결합됩니다. 프레임워크나 기술 스택을 변경하려는 경우 리팩토링이 큰 노력이 됩니다. Screaming Architecture는 도메인 로직을 깔끔하고 분리된 상태로 유지하는 것을 옹호하므로 프레임워크 선택은 코드베이스의 핵심 구조가 아닌 구현 세부 사항이 됩니다.

도메인 중심 설계(DDD)의 비명을 지르는 아키텍처

도메인 기반 디자인(DDD)과 Screaming Architecture는 종종 함께 사용됩니다. DDD는 기술 전문가와 도메인 전문가 간의 협업을 강조하는 소프트웨어 개발 접근 방식으로, 실제 운영과 밀접하게 일치하는 방식으로 핵심 비즈니스 로직을 모델링하는 데 중점을 둡니다.

Screaming Architecture에서는 도메인 모델과 비즈니스 로직이 애플리케이션의 중심에 있고 프레임워크, 데이터베이스, UI, 서비스 등 다른 모든 것이 주변 장치가 됩니다. 핵심 아이디어는 코드 구조가 기술적 구현 세부 사항이 아닌 도메인 모델을 반영해야 한다는 것입니다.

도메인 중심 원칙을 사용하여 의도를 "비명"하는 방식으로 프로젝트를 구성하는 방법은 다음과 같습니다.

/src
    /accounting
        Ledger.cs
        Transaction.cs
        Account.cs
        TaxService.cs
    /sales
        Order.cs
        Invoice.cs
        Customer.cs
        DiscountPolicy.cs

이 예에서 폴더 이름은 비즈니스 관심사인 회계 및 판매를 직접적으로 반영합니다. Ledger, Transaction 및 Order와 같은 각 도메인별 클래스는 관련 도메인 컨텍스트 내에 배치됩니다. 이러한 구조를 통해 시스템이 무엇인지, 각 구성 요소가 어디에 적합한지 즉시 알 수 있습니다.

코드 예시 1: 간단한 도메인 중심 구조

주문과 재고를 처리하는 전자상거래 애플리케이션을 생각해 보세요. Screaming Architecture를 사용하면 폴더 구조는 기술적인 역할보다는 비즈니스 로직을 반영해야 합니다.

/src
    /orders
        Order.cs
        OrderService.cs
        OrderRepository.cs
    /inventory
        InventoryItem.cs
        InventoryService.cs
        InventoryRepository.cs

다음은 주문 컨텍스트의 기본 코드 예시입니다.

public class Order
{
    public Guid Id { get; set; }
    public DateTime OrderDate { get; set; }
    public List<orderitem> Items { get; set; }
    public decimal TotalAmount { get; set; }

    public Order(List<orderitem> items)
    {
        Id = Guid.NewGuid();
        OrderDate = DateTime.Now;
        Items = items;
        TotalAmount = CalculateTotal(items);
    }

    private decimal CalculateTotal(List<orderitem> items)
    {
        return items.Sum(item => item.Price * item.Quantity);
    }
}

public class OrderItem
{
    public string ProductName { get; set; }
    public decimal Price { get; set; }
    public int Quantity { get; set; }
}
</orderitem></orderitem></orderitem>

이 코드에서는 도메인 개념(Order)이 전면 중앙에 있으며 OrderService 및 OrderRepository와 같은 지원 로직이 별도의 파일에 보관되어 있습니다. 비즈니스 로직(CalculateTotal)은 서비스나 컨트롤러에 숨겨져 있는 것이 아니라 Order 엔터티의 일부입니다.

기술적 방해 요소 방지

Frameworks and libraries are crucial for software development, but they shouldn't dictate how your business logic is structured. Screaming Architecture advocates for pushing technical details like HTTP controllers, persistence layers, and database frameworks to the periphery.

Here’s an example that contrasts the traditional and screaming architectures:

Traditional Architecture:

/src
    /controllers
        OrderController.cs
    /services
        OrderService.cs
    /repositories
        OrderRepository.cs
    /models
        Order.cs
        OrderItem.cs

While this is technically correct, it doesn’t tell you what the system is for. The folder structure reveals nothing about the domain. Is it an e-commerce system? A financial application? It’s impossible to know without diving deep into the code.

Screaming Architecture:

/src
    /orders
        OrderController.cs
        OrderService.cs
        OrderRepository.cs
        Order.cs
        OrderItem.cs
    /inventory
        InventoryController.cs
        InventoryService.cs
        InventoryRepository.cs
        InventoryItem.cs

This structure immediately clarifies that the system handles orders and inventory. If you add more domains in the future (e.g., customers, payments), they’ll have a dedicated place in the architecture.

The Role of Clean Architecture

Screaming Architecture often aligns with Uncle Bob’s broader Clean Architecture principles. Clean Architecture promotes a separation of concerns, focusing on ensuring that business rules are independent of frameworks, UI, and databases. Screaming Architecture takes this a step further by suggesting that the project’s structure should reveal the core business logic.

Here’s a quick recap of Clean Architecture:

Entities: Core business objects and logic.

Use Cases: Application-specific business rules.

Interfaces: Gateways for frameworks and external systems.

Frameworks & Drivers: UI, databases, and other external components.

In a Clean Architecture project, domain concepts like Order, Customer, and Invoice are part of the central layer. Frameworks like ASP.NET Core, Django, or Rails are relegated to the outer layers, serving as mechanisms to deliver the core functionality.

Code Example 2: Applying Clean Architecture in Screaming Architecture

In a Screaming Architecture, you’d structure the use cases and entities in a way that reflects the business domain. Let’s extend our e-commerce example:

/src
    /orders
        CreateOrderUseCase.cs
        OrderRepository.cs
        Order.cs
        OrderItem.cs
    /inventory
        AddInventoryItemUseCase.cs
        InventoryRepository.cs
        InventoryItem.cs

Here’s an example use case for creating an order:

public class CreateOrderUseCase
{
    private readonly IOrderRepository _orderRepository;
    private readonly IInventoryService _inventoryService;

    public CreateOrderUseCase(IOrderRepository orderRepository, IInventoryService inventoryService)
    {
        _orderRepository = orderRepository;
        _inventoryService = inventoryService;
    }

    public Order Execute(List<orderitem> items)
    {
        // Ensure all items are available in inventory
        foreach (var item in items)
        {
            _inventoryService.CheckInventory(item.ProductName, item.Quantity);
        }

        var order = new Order(items);
        _orderRepository.Save(order);
        return order;
    }
}
</orderitem>

In this example, the CreateOrderUseCase is part of the domain logic and interacts with the OrderRepository and InventoryService to fulfill the business need of creating an order.

Benefits of Screaming Architecture

Improved Readability: Anyone who opens your codebase will immediately understand what the system does.

Separation of Concerns: Business logic remains isolated from technical details, making it easier to change frameworks or technologies later.

Scalability: As the system grows, the domain structure remains consistent, allowing for easy addition of new features and modules.

Maintainability: Domain logic is easier to maintain when it’s cleanly separated from external dependencies and frameworks.

Framework Agnostic: Screaming Architecture allows the business logic to remain portable across different technical stacks, avoiding tight coupling with any particular framework.

Criticisms of Screaming Architecture

While Screaming Architecture has many benefits, it’s not without its criticisms:

Perceived Complexity: Developers unfamiliar with domain-driven design may find the separation of domain logic from technical details unnecessary or overly complex for small applications.
2

. Overhead: In small projects or simple CRUD applications, implementing Screaming Architecture may seem like overkill.

Learning Curve: For teams used to framework-first approaches, adopting Screaming Architecture requires a shift in thinking that may take time to internalize.

When to Use Screaming Architecture

Screaming Architecture is particularly useful in the following scenarios:

Domain-Driven Systems: Applications with complex business rules and domain logic.

Long-Term Projects: Systems expected to evolve over time, where scalability and maintainability are critical.

Cross-Platform Development: Systems that may switch frameworks or platforms, making a clean separation of business logic essential.

Conclusion

Screaming Architecture is more than just a catchy name; it’s a philosophy that advocates for making the core business logic the most prominent part of your codebase. By focusing on domain concepts rather than technical frameworks, developers can build systems that are more readable, maintainable, and scalable in the long run. Whether you’re working on a simple web application or a complex enterprise system, adopting Screaming Architecture can lead to cleaner, more focused code that clearly expresses its purpose.

To learn more about Screaming Architecture, you can check out some references and additional readings:

Architecture propre par Robert C. Martin

Conception basée sur le domaine par Eric Evans

Le blog de l'oncle Bob sur le code propre

En adoptant les principes de Screaming Architecture, vous pouvez créer des bases de code qui non seulement fonctionnent, mais qui « crient » également leur intention.

위 내용은 스크리밍 아키텍처란 무엇인가?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
JavaScript의 기원 : 구현 언어 탐색JavaScript의 기원 : 구현 언어 탐색Apr 29, 2025 am 12:51 AM

JavaScript는 1995 년에 시작하여 Brandon Ike에 의해 만들어졌으며 언어를 C로 실현했습니다. 1.C Language는 JavaScript의 고성능 및 시스템 수준 프로그래밍 기능을 제공합니다. 2. JavaScript의 메모리 관리 및 성능 최적화는 C 언어에 의존합니다. 3. C 언어의 크로스 플랫폼 기능은 자바 스크립트가 다른 운영 체제에서 효율적으로 실행하는 데 도움이됩니다.

무대 뒤에서 : 어떤 언어의 힘이 자바 스크립트입니까?무대 뒤에서 : 어떤 언어의 힘이 자바 스크립트입니까?Apr 28, 2025 am 12:01 AM

JavaScript는 브라우저 및 Node.js 환경에서 실행되며 JavaScript 엔진을 사용하여 코드를 구문 분석하고 실행합니다. 1) 구문 분석 단계에서 초록 구문 트리 (AST)를 생성합니다. 2) 컴파일 단계에서 AST를 바이트 코드 또는 기계 코드로 변환합니다. 3) 실행 단계에서 컴파일 된 코드를 실행하십시오.

파이썬과 자바 스크립트의 미래 : 트렌드와 예측파이썬과 자바 스크립트의 미래 : 트렌드와 예측Apr 27, 2025 am 12:21 AM

Python 및 JavaScript의 미래 추세에는 다음이 포함됩니다. 1. Python은 과학 컴퓨팅 분야에서의 위치를 ​​통합하고 AI, 2. JavaScript는 웹 기술의 개발을 촉진하고, 3. 교차 플랫폼 개발이 핫한 주제가되고 4. 성능 최적화가 중점을 둘 것입니다. 둘 다 해당 분야에서 응용 프로그램 시나리오를 계속 확장하고 성능이 더 많은 혁신을 일으킬 것입니다.

Python vs. JavaScript : 개발 환경 및 도구Python vs. JavaScript : 개발 환경 및 도구Apr 26, 2025 am 12:09 AM

개발 환경에서 Python과 JavaScript의 선택이 모두 중요합니다. 1) Python의 개발 환경에는 Pycharm, Jupyternotebook 및 Anaconda가 포함되어 있으며 데이터 과학 및 빠른 프로토 타이핑에 적합합니다. 2) JavaScript의 개발 환경에는 Node.js, VScode 및 Webpack이 포함되어 있으며 프론트 엔드 및 백엔드 개발에 적합합니다. 프로젝트 요구에 따라 올바른 도구를 선택하면 개발 효율성과 프로젝트 성공률이 향상 될 수 있습니다.

JavaScript가 C로 작성 되었습니까? 증거를 검토합니다JavaScript가 C로 작성 되었습니까? 증거를 검토합니다Apr 25, 2025 am 12:15 AM

예, JavaScript의 엔진 코어는 C로 작성되었습니다. 1) C 언어는 효율적인 성능과 기본 제어를 제공하며, 이는 JavaScript 엔진 개발에 적합합니다. 2) V8 엔진을 예를 들어, 핵심은 C로 작성되며 C의 효율성 및 객체 지향적 특성을 결합하여 C로 작성됩니다.

JavaScript의 역할 : 웹 대화식 및 역동적 인 웹JavaScript의 역할 : 웹 대화식 및 역동적 인 웹Apr 24, 2025 am 12:12 AM

JavaScript는 웹 페이지의 상호 작용과 역학을 향상시키기 때문에 현대 웹 사이트의 핵심입니다. 1) 페이지를 새로 고치지 않고 콘텐츠를 변경할 수 있습니다. 2) Domapi를 통해 웹 페이지 조작, 3) 애니메이션 및 드래그 앤 드롭과 같은 복잡한 대화식 효과를 지원합니다. 4) 성능 및 모범 사례를 최적화하여 사용자 경험을 향상시킵니다.

C 및 JavaScript : 연결이 설명되었습니다C 및 JavaScript : 연결이 설명되었습니다Apr 23, 2025 am 12:07 AM

C 및 JavaScript는 WebAssembly를 통한 상호 운용성을 달성합니다. 1) C 코드는 WebAssembly 모듈로 컴파일되어 컴퓨팅 전력을 향상시키기 위해 JavaScript 환경에 도입됩니다. 2) 게임 개발에서 C는 물리 엔진 및 그래픽 렌더링을 처리하며 JavaScript는 게임 로직 및 사용자 인터페이스를 담당합니다.

웹 사이트에서 앱으로 : 다양한 JavaScript 애플리케이션웹 사이트에서 앱으로 : 다양한 JavaScript 애플리케이션Apr 22, 2025 am 12:02 AM

JavaScript는 웹 사이트, 모바일 응용 프로그램, 데스크탑 응용 프로그램 및 서버 측 프로그래밍에서 널리 사용됩니다. 1) 웹 사이트 개발에서 JavaScript는 HTML 및 CSS와 함께 DOM을 운영하여 동적 효과를 달성하고 jQuery 및 React와 같은 프레임 워크를 지원합니다. 2) 반응 및 이온 성을 통해 JavaScript는 크로스 플랫폼 모바일 애플리케이션을 개발하는 데 사용됩니다. 3) 전자 프레임 워크를 사용하면 JavaScript가 데스크탑 애플리케이션을 구축 할 수 있습니다. 4) node.js는 JavaScript가 서버 측에서 실행되도록하고 동시 요청이 높은 높은 요청을 지원합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)