TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Against service layers in Django (2020)

1 点作者 animal_spirits8 个月前

1 comment

mattbillenstein8 个月前
I&#x27;ve been using this service pattern although not in Django - in Flask. The main benefit is a lot of code doesn&#x27;t need to depend on a request context. We can happily have backend scripts calling services and we intentionally don&#x27;t let the request context bleed into that layer.<p>Also, may just be me, but I&#x27;ve mostly seen just bad Django apps - God object patterns galore, the schema&#x2F;orm&#x2F;business logic all being very tightly coupled and essentially nothing is able to be refactored because of this. They often have to be simply thrown away and you start over.<p>But, I think having an explicit service interface solves a lot of these problems - as long as you maintain the interface and pass back the same type of object, you&#x27;re free to talk to whatever backing store you like. And you get a lot less issues with circular imports and whatnot in my experience. ymmv
评论 #41640447 未加载