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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Modern Functional Programming: The Onion Architecture

283 点作者 Roxxik超过 8 年前

6 条评论

slashdotdash超过 8 年前
Gary Bernhardt describes a similar architecture using a &quot;Functional Core, Imperative Shell&quot; in his Boundaries talk[1].<p>&quot;Purely functional code makes some things easier to understand: because values don&#x27;t change, you can call functions and know that only their return value matters—they don&#x27;t change anything outside themselves. But this makes many real-world applications difficult: how do you write to a database, or to the screen?&quot;<p>&quot;This design has many nice side effects. For example, testing the functional pieces is very easy, and it often naturally allows isolated testing with no test doubles. It also leads to an imperative shell with few conditionals, making reasoning about the program&#x27;s state over time much easier.&quot;<p>[1] <a href="https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;talks&#x2F;boundaries" rel="nofollow">https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;talks&#x2F;boundaries</a><p>[2] <a href="https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;screencasts&#x2F;catalog&#x2F;functional-core-imperative-shell" rel="nofollow">https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;screencasts&#x2F;catalog&#x2F;funct...</a>
评论 #12605890 未加载
评论 #12607047 未加载
评论 #12607357 未加载
评论 #12605795 未加载
评论 #12605757 未加载
评论 #12611596 未加载
评论 #12605968 未加载
bad_user超过 8 年前
&gt; <i>Free monads permit unlimited introspection and transformation of the structure of your program; Free monads allow minimal specification of each semantic layer, since performance can be optimized via analysis and transformation.</i><p>That is not true and this overselling of the Free monad is hurting the concept.<p>The Free monad is nothing more than the flatMap&#x2F;bind operation, specified as a data-structure, much like how a binary-search tree describes binary search. And this means an imposed ordering of operations and loss of information due to computations being suspended by means of functions.<p>You see, if the statement I&#x27;m disagreeing with would be true, then you&#x27;d be able to build something like .NET LINQ on top of Free. But you can&#x27;t.
评论 #12606110 未加载
评论 #12606052 未加载
评论 #12605375 未加载
gravypod超过 8 年前
I&#x27;d not say this is a feature of functional programming. This is a feature of Object Oriented elements being included in fp languages.<p>These are the same things we were going to happen when using Java and C++ years ago.<p>You can even see similar graphics here: <a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;java&#x2F;concepts&#x2F;object.html" rel="nofollow">https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;java&#x2F;concepts&#x2F;object...</a><p>I remember there was another in this tutorial that shared more with the image in this post. Although this is the same idea. You&#x27;re just hiding Objects in Objects.
评论 #12605181 未加载
评论 #12605232 未加载
评论 #12605145 未加载
评论 #12610046 未加载
评论 #12608883 未加载
评论 #12613959 未加载
jackmott超过 8 年前
I didn&#x27;t understand a word, and I bet 99% of people who clicked the link didn&#x27;t either.
评论 #12608775 未加载
tucaz超过 8 年前
Unrelated to functional programming there is Onion Architecture defined by Jeffrey Palermo in 2008 which I find a very nice and simple way to architect&#x2F;organize a LoB application.<p><a href="http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-1&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-1...</a> <a href="http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-2&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-2...</a> <a href="http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-3&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;the-onion-architecture-part-3...</a> <a href="http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;onion-architecture-part-4-after-four-years&#x2F;" rel="nofollow">http:&#x2F;&#x2F;jeffreypalermo.com&#x2F;blog&#x2F;onion-architecture-part-4-aft...</a>
munro超过 8 年前
How does this architecture constrast with Rust? Has anyone built anything like this in Rust?<p>It makes me think of an article where the author tries to abstract the implementation of IO from the the domain logic. [1]<p>[1] <a href="https:&#x2F;&#x2F;blog.skcript.com&#x2F;asynchronous-io-in-rust-36b623e7b965" rel="nofollow">https:&#x2F;&#x2F;blog.skcript.com&#x2F;asynchronous-io-in-rust-36b623e7b96...</a>