Code Monkey home page Code Monkey logo

cola's Introduction

🥤 COLA 4.0

Build Status Maven Central GitHub release JDK support
License GitHub Stars GitHub Forks GitHub issues

COLA 是 Clean Object-Oriented and Layered Architecture的缩写,代表“整洁面向对象分层架构”。 目前COLA已经发展到COLA 4.0

COLA分为两个部分,COLA架构和COLA组件。

COLA架构

COLA 概述

架构意义 就是 要素结构:

  • 要素 是 组成架构的重要元素;
  • 结构 是 要素之间的关系。

应用架构意义 就在于

  • 定义一套良好的结构;
  • 治理应用复杂度,降低系统熵值;
  • 从随心所欲的混乱状态,走向井井有条的有序状态。

archWhy

COLA架构就是为此而生,其核心职责就是定义良好的应用结构,提供最佳应用架构的最佳实践。通过不断探索,我们发现良好的分层结构,良好的包结构定义,可以帮助我们治理混乱不堪的业务应用系统。

cure

经过多次迭代,我们定义出了相对稳定、可靠的应用架构:COLA 4.0

cola

COLA Archetype

好的应用架构,都遵循一些共同模式,不管是六边形架构、洋葱圈架构、整洁架构、还是COLA架构,都提倡以业务为核心,解耦外部依赖,分离业务复杂度和技术复杂度等

COLA架构区别于这些架构的地方,在于除了**之外,我们还提供了可落地的工具和实践指导。

为了能够快速创建满足COLA架构的应用,我们提供了两个archetype,位于cola-archetypes目录下:

  1. cola-archetype-service:用来创建纯后端服务的archetype
  2. cola-archetype-web:用来创建adapter和后端服务一体的web应用archetype

COLA Components

此外,我们还提供了一些非常有用的通用组件,这些组件可以帮助我们提升研发效率。

这些功能组件被收拢在cola-components目录下面。到目前为止,我们已经沉淀了以下组件:

组件名称 功能 版本 依赖
cola-component-dto 定义了DTO格式,包括分页 1.0.0
cola-component-exception 定义了异常格式,
主要有BizExceptionSysException
1.0.0
cola-component-statemachine 状态机组件 1.0.0
cola-component-domain-starter Spring托管的领域实体组件 1.0.0
cola-component-catchlog-starter 异常处理和日志组件 1.0.0 exception
dto组件
cola-component-extension-starter 扩展点组件 1.0.0
cola-component-test-container 测试容器组件 1.0.0

如何使用COLA

1. 创建应用

执行以下命令:

mvn archetype:generate  \
    -DgroupId=com.alibaba.cola.demo.web \
    -DartifactId=demo-web \
    -Dversion=1.0.0-SNAPSHOT \
    -Dpackage=com.alibaba.demo \
    -DarchetypeArtifactId=cola-framework-archetype-web \
    -DarchetypeGroupId=com.alibaba.cola \
    -DarchetypeVersion=4.0.1

命令执行成功的话,会看到如下的应用代码结构:

demo

注:也可以使用阿里云的应用生成器:https://start.aliyun.com/bootstrap.html 生成cola应用。

2. 运行应用

  • 项目目录下运行mvn install(如果不想运行测试,可以加上-DskipTests参数)。
  • 进入start目录,执行mvn spring-boot:run
    运行成功的话,可以看到SpringBoot启动成功的界面。
  • 生成的应用中,已经实现了一个简单的Rest请求,可以在浏览器中输入 http://localhost:8080/helloworld 进行测试。

如果要生成不是web工程而是service工程也类似,执行的是下面的命令:

mvn archetype:generate  \
    -DgroupId=com.alibaba.cola.demo.service \
    -DartifactId=demo-service \
    -Dversion=1.0.0-SNAPSHOT \
    -Dpackage=com.alibaba.demo \
    -DarchetypeArtifactId=cola-framework-archetype-service \
    -DarchetypeGroupId=com.alibaba.cola \
    -DarchetypeVersion=4.0.1

版本迭代

4.0.0 版本

https://blog.csdn.net/significantfrank/article/details/110934799

3.1.0 版本

https://blog.csdn.net/significantfrank/article/details/109529311

  1. 进一步简化了cola-core,只保留了扩展能力。
  2. exceptioncola-core移入到cola-common
  3. archetype中的分包逻辑进行重构,改成按照domain做划分。
  4. cola-archetype-web中的controller改名为adapter,为了呼应六边形架构的命名。

3.0.0 版本

https://blog.csdn.net/significantfrank/article/details/106976804

2.0.0 版本

https://blog.csdn.net/significantfrank/article/details/100074716

1.0.0 版本

https://blog.csdn.net/significantfrank/article/details/85785565

关于COLA的更多信息,请关注微信公众号:

qrcode_60.jpg

如果你有技术热情,对阿里有兴趣,可以email:[email protected]

cola's People

Contributors

alibaba-oss avatar binghx avatar dependabot[bot] avatar dudiao avatar fanyi-zhao avatar fushun1990 avatar geyingqi777 avatar jutem avatar likaer avatar meishenme avatar n2xk avatar oldratlee avatar piaolingxue avatar richardstark avatar significantfrank avatar sinopower avatar whitebookman1994 avatar wzslw avatar xyz0001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.