Comments (1)
这个结构也是综合了其他项目的一些写法,我的理解是这样:logic是业务逻辑的处理,而service是IO操作,logic是对service的组合。举个例子,比如对于一个多角色用户模块(老师角色,学生角色),前端会传用户名+密码+用户类型过来,后端接收后先由logic层通过用户类型来选择使用特定的service进行数据库读取(老师、学生信息存在2张表中);这样一来logic层的每个方法专注点在某个特定的业务逻辑,而service专注于IO读写(数据库操作,网络请求,缓存等)而且应该是不带有业务逻辑判断的一个无状态的操作。
其实这种分离也是在代码复杂度和可维护性中的一种妥协,logic是对service的组合,但其实有时候logic也需要组合着使用,上面说不定还会多出另外一层,分离IO和业务逻辑只是一种比较典型的分法,比较试用于大作业这种包含比较多CURD的项目,这个结构也有悖于微服务的架构,在真实项目中还是根据实际的情况来设计:逻辑比较简单的话,我觉得完全就不需要有service层;如果逻辑复杂的话在logic层上再封装也是可以的。
from springboot-template.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springboot-template.