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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Collection Pipeline

39 点作者 chillax将近 11 年前

4 条评论

rikkus将近 11 年前
Half my code looks like this, these days:<p><pre><code> return products .Where(p =&gt; p.Type == ProductType.Bean) .OrderBy(p =&gt; p.Group) .ThenBy(p =&gt; p.Name) .Select(p =&gt; p.Name) ; </code></pre> Sometimes I&#x27;ll write it like this:<p><pre><code> return from p in Products where p.ProductType == ProductType.Bean orderby ... etc. </code></pre> Everything&#x27;s a query, or a sh pipeline, or...<p>One of the nice things about this idiom is that it&#x27;s supported all over the place, so you can write similar code in many different languages, for many different platforms.
评论 #8064238 未加载
评论 #8064560 未加载
CoffeeDregs将近 11 年前
I&#x27;ve generally appreciated Fowler&#x27;s work on cataloging software patterns (and based my MBA thesis on doing something similar for organizational design), but I find this post a bit puzzling. Having spent a bunch of time with Haskell 6-7 years ago, the treatment of functions such as these was much more rigorous and generalized (e.g. <a href="http://en.wikibooks.org/wiki/Haskell/The_Functor_class" rel="nofollow">http:&#x2F;&#x2F;en.wikibooks.org&#x2F;wiki&#x2F;Haskell&#x2F;The_Functor_class</a>).<p><pre><code> However the items this time are generic collection types themselves - where an OO collection pipeline would use objects, a functional language would use a hashmap. </code></pre> Again, I&#x27;m a bit confused (though I might have missed some context). Functional languages tend to be much more generic so that a &quot;collection pipeline&quot; or map can operate over a wide range of types.<p>I&#x27;m reasonably certain that I&#x27;m missing some critical point, but I&#x27;m not sure about what?
评论 #8065462 未加载
jgrodziski将近 11 年前
I would have liked to have seen Martin Fowler mentioned the parallelism and state implication of the unix pipeline, somewhat limited (see <a href="http://www.quora.com/Parallel-Computing/Do-pipelined-unix-commands-run-faster-on-multicore" rel="nofollow">http:&#x2F;&#x2F;www.quora.com&#x2F;Parallel-Computing&#x2F;Do-pipelined-unix-co...</a>) but this is for me a very profond way of looking at this kind of pattern: whether you finish completely your processing on the data structure or you emit the result downstream as soon as you have finished processing one element.<p>Stream is for me the fundamental nature of the unix pipeline, and this is rarely met in programming language (channels to the rescue like in Clojure and Go). The Java Streams seems to work this way with the distinction between stateless and stateful processing element (<a href="http://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html" rel="nofollow">http:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;8&#x2F;docs&#x2F;api&#x2F;java&#x2F;util&#x2F;stream&#x2F;pa...</a>).
platz将近 11 年前
Not really a mention of whether these &#x27;chained&#x27; methods should be returning a new collection, mutating an existing collection, or returning something completely different.<p>Would expect to at least see some kind of discussion on this here - otherwise <i>every</i> method call is a &quot;pipeline&quot;
评论 #8064743 未加载