<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="89195" data-post-id="89195">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sztosz" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sztosz/120/1251_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sztosz
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="NobbZ" data-post="10" data-topic="15247">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>This style often confused subject and object</p>
</blockquote>
</aside>
<p>I’m not sure what you mean by that, what’s in this context is object and what is a subject.</p>
<p>It very easy not to be confused if remember that nouns are the objects or in other words subjects of given function/transformation, and verbs are the functions or in other words labels for transformations we do to our data, objects, the nouns.</p>
<aside class="quote no-group" data-username="joaoevangelista" data-post="8" data-topic="15247">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/joaoevangelista/48/39742_2.png" class="avatar"> joaoevangelista:</div>
<blockquote>
<p><code>this piped into IO.inspect</code> is less readable than <code>IO.inspect this</code></p>
</blockquote>
</aside>
<p>It’s actually the case of: <code>IO inspects this</code> vs <code>this is being inspected by IO</code> And I think we do care more about <code>this</code> than <code>IO</code> and it’s easier to skim code if <code>this</code> is at the beginning of the line (or at least closer the the side which I’m starting to read given line).</p>
<p>If you are telling someone about your friend <code>Bob</code> and how you spend last evening, would you rather tell <code>I wen't with Bob to a bar</code> or <code>Bob and I wen't to a bar</code>? Both versions are perfectly understandable, but which one is the correct one? <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89195" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-89195" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89195"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="89203" data-post-id="89203">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sztosz" data-post="12" data-topic="15247">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sztosz/48/1251_2.png" class="avatar"> sztosz:</div>
<blockquote>
<p>It very easy not to be confused if remember that nouns are the objects or in other words subjects of given function/transformation, and verbs are the functions or in other words labels for transformations we do to our data, objects, the nouns.</p>
</blockquote>
</aside>
<p>The problem for me here is, that usually in a sentence the object comes first, so <code>thing |&gt; IO.inspect</code> reads for me as if <code>thing</code> were inspecting something not further mentioned.</p>
<p>But actually <code>thing</code> is (or better: should be) seen as the subject, the thing we do something with.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89203" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-89203" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89203"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="89204" data-post-id="89204">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sztosz" data-post="7" data-topic="15247">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sztosz/48/1251_2.png" class="avatar"> sztosz:</div>
<blockquote>
<p>I think we should not mistake readability with familiarity.</p>
</blockquote>
</aside>
<p>People should be <em>very familiar</em> with piping:</p>
<pre><code class="lang-plaintext">something 
|&gt; do_something()
|&gt; do_something_else()
|&gt; with_additional_param(param)
</code></pre>
<p>is essentially equivalent to OO</p>
<pre><code class="lang-plaintext">something 
  .do_something()
  .do_something_else()
  .with_additional_param(param)
</code></pre>
<p>i.e. <a href="https://en.wikipedia.org/wiki/Method_chaining" rel="noopener nofollow ugc">method chaining</a> and <a href="https://www.martinfowler.com/bliki/FluentInterface.html" rel="noopener nofollow ugc">fluent interface</a>.</p>
<p>The returned object and implicitly passed <code>this</code> (“parameter”) is replaced with the convention of the “result to the first parameter of the function”. That’s it.</p>
<p>From that perspective I’ve always found</p>
<pre><code class="lang-plaintext">something.do_something()
</code></pre>
<p>more <em>pretentious</em> (objects are the “leads”, methods only play “supporting” roles) than</p>
<pre><code class="lang-plaintext">do_something(some_thing)
</code></pre>
<p>I mean people always make such a big deal about “functions being first class citizens”. Therefore I have similar misgivings about:</p>
<pre><code class="lang-plaintext">something |&gt; do_something()
</code></pre>
<p>And the <a href="https://github.com/christopheradams/elixir_style_guide#avoid-single-pipelines" rel="noopener nofollow ugc">community style guide happens to agree</a>.</p>
<blockquote>
<p>Avoid using the pipe operator just once.</p>
</blockquote>
<p>There is <em>nothing messy</em> about:</p>
<pre><code class="lang-plaintext">do_something(some_thing)
</code></pre>
<p>which can’t be said about</p>
<pre><code class="lang-plaintext">with_additional_param(
  do_something_else(
    do_something(something)
  ), 
  param
)
</code></pre>
<p>which is why</p>
<pre><code class="lang-plaintext">something 
|&gt; do_something()
|&gt; do_something_else()
|&gt; with_additional_param(param)
</code></pre>
<p>is preferred.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89204" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-89204" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89204"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="89212" data-post-id="89212">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jamesnorton" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jamesnorton/120/1064_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jamesnorton
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I think you are confusing object and subject. Object is the thing upon which the subject acts  - subject is the thing performing the action.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89212" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-89212" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89212"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="89215" data-post-id="89215">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="50kudos" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/50kudos/120/4435_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  50kudos
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<pre><code>total_point = staging_items
|&gt; Enum.reduce(0, fn (item,acc) -&gt; Board.piece_point(item) + acc end)
|&gt; Kernel.+(Enum.reduce(const_board_items, 0, fn (item,acc) -&gt; item.point + acc end))
|&gt; Kernel.*(Enum.reduce(staging_items, 1, fn (item,acc) -&gt; Board.equation_mult(item) * acc end))
</code></pre>
<p>No kidding, this is my production code (not a serious app, 1 developer)</p>
<p>Wait! I think I could refactor it this way:</p>
<pre><code>total_point = 1
|&gt; Kernel.*(Enum.reduce(staging_items, 0, fn (item,acc) -&gt; Board.piece_point(item) + acc end))
|&gt; Kernel.+(Enum.reduce(const_board_items, 0, fn (item,acc) -&gt; item.point + acc end))
|&gt; Kernel.*(Enum.reduce(staging_items, 1, fn (item,acc) -&gt; Board.equation_mult(item) * acc end))
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89215" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-89215" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89215"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="89946" data-post-id="89946">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="robotarmy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/robotarmy/120/3044_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  robotarmy
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just to be explicit that’s not actually a different factoring .</p>
<p>A different factor would be</p>
<p>total_score = 1 + count(board_items) + count(const_board_items) + count(other_staging)</p>
<p>Maybe you can do pattern matching on count , maybe not - if you can’t- it is clear to say count_stage_items, count_const_board_items - this gives you abstraction over the details of how you count. Also it gives you a way to test In isolation the properties of “count_board_items” et.all</p>
<p>Refactoring typically refers to a set of specific operations (extract method, extract constant, extract class/module, merge method, merge class, rename class, rename method , etc ) and not simply rewriting a line of code into a different form.</p>
<p>I say this to help you become one with the art of appropriate abstractions which is a foundation for successful refactoring.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="89946" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-89946" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="89946"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="90078" data-post-id="90078">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="50kudos" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/50kudos/120/4435_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  50kudos
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Agreed on abstraction <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> that’s why I mentioned about seriousness and sole developer.<br>
Also my bad on saying “refactor”.</p>
<p>I just wanted to give one more pipe obsession example. Like anything can be piped will be piped.<br>
Thanks!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="90078" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-90078" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="90078"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="90082" data-post-id="90082">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="asummers" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/asummers/120/18515_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  asummers
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I very much dislike piping into cases/ifs/anything of that sort. I will 100% of the time extract that to a function and name it for readability purposes, and will always call it out in code review.  To me, it reads very poorly, and is the lesser of all alternatives. For full disclosure, I often do this with case statements in general, but it’s especially pronounced with pipes.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="90082" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/want-to-pipe-into-a-case-statement-you-can/15247/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-90082" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="90082"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>