TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Spring Rites – a caution against annotation-based web frameworks

7 pointsby airspeedjangleover 1 year ago

1 comment

mrkeenover 1 year ago
Brilliant article.<p>I dislike annotation-driven code, as well as opinionated frameworks like Spring.<p>Throwing out Spring (or similar) is probably not going to happen if your team uses it.<p>I have found that you can greatly reduce your coupling to Spring (and other annotations) while still letting it work for you.<p>To do so, you use inheritance (which in general I dislike, but in this case - two wrongs make a right?)<p>Split your FooService into two: {SpringFooService and FooService}, where SFS inherits from FS.<p>* SFS may contain annotations, but FS must not. * FS must contain all your business logic. SFS must be a thin 1:1 wrapper over FS.<p>This means that: * SFS can be autowired, and managed by Spring. * Your business logic remains &quot;simply-instantiable&quot; with _new_ for the purposes of unit testing.
评论 #39468446 未加载
评论 #39469221 未加载