电子商务网络应用程序中使用了哪些设计模式?

What design patterns are used in an ecommerce web apps?

在使用微服务或多层架构开发电子商务时,通常使用或一起使用哪些设计模式?假设我们将使用 Java 或 .NET 5 等面向对象语言编写代码,仅作为示例,我们使用 Java 脚本框架开发客户端应用程序。

如果我选择实施微服务架构,设计模式建议会改变吗?

有一个模式叫做“Pattern: Microservice Architecture:

Define an architecture that structures the application as a set of loosely coupled, collaborating services. This approach corresponds to the Y-axis of the Scale Cube. Each service is:

  • Highly maintainable and testable - enables rapid and frequent development and deployment
  • Loosely coupled with other services - enables a team to work independently the majority of time on their service(s) without being impacted by changes to other services and without affecting other services
  • Independently deployable - enables a team to deploy their service without having to coordinate with other teams
  • Capable of being developed by a small team - essential for high productivity by avoiding the high communication head of large teams

Services communicate using either synchronous protocols such as HTTP/REST or asynchronous protocols such as AMQP. Services can be developed and deployed independently of one another. Each service has its own database in order to be decoupled from other services. Data consistency between services is maintained using the Saga pattern

To learn more about the nature of a service, please read this article.

并且e-commerce application被认为是应用模式的示例:微服务架构。

因此可以创建按实体或业务领域划分的多个服务:

  • 客户
  • 库存
  • 运费

那么有必要提供服务之间的通信方式。可以是事件流平台Kafka.