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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve been writing elixir for 3 years, and the patterns I find most useful are the ‘CRC pattern(token base)’ and ‘Functional core, imperative patter’,  the world of Elixir is almost everywhere CRC, Ecto.Changeset, Plug.Conn, Absinthe blueprint and so on,  Bruce has a book on this topic: <a href="https://pragprog.com/titles/jgotp/designing-elixir-systems-with-otp/" class="inline-onebox" rel="noopener nofollow ugc">Designing Elixir Systems with OTP: Write Highly Scalable, Self-Healing Software with Layers by James Edward Gray, II and Bruce A. Tate</a></p>
<p>For functional core pattern, there is a screencast with Ruby language: <a href="https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell" class="inline-onebox" rel="noopener nofollow ugc">Functional Core, Imperative Shell</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="257672" data-batch-url="/posts/batch_likers">
                        3
                      </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/design-pattern-for-functional-concurrent-programming/49371/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-257672" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="257672"
                     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="257761" data-post-id="257761">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="zookzook" data-post="10" data-topic="49371" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zookzook/48/15276_2.png" class="avatar"> zookzook:</div>
<blockquote>
<p>Once you understand what a monad is, you can’t explain it.</p>
</blockquote>
</aside>
<p>My first steps towards functional programming were in haskell. Never really did get it. Thats why I like Elixir, its a functional language that I can understand as a programming-craftsman. Imo using patterns like monads builds a wall around your code, which makes onboarding “craftsmen” nearly impossible (like you said, everyone that gets the code cant explain it).</p>
<p>I’d really like to see an example were using monads gives that much of a benefit over the Elixir way (tagged tuples, lists, with, …) that justifies the brainf***.</p>
<aside class="quote no-group quote-modified" data-username="scottming" data-post="12" data-topic="49371">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scottming/48/13006_2.png" class="avatar"> scottming:</div>
<blockquote>
<p>For functional core pattern, there is a screencast with Ruby language: <a href="https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell" rel="noopener nofollow ugc">Functional Core, Imperative Shell</a></p>
</blockquote>
</aside>
<p><img src="https://forum.elixirforum.com/images/emoji/apple/+1.png?v=15" title=":+1:" class="emoji only-emoji" alt=":+1:" 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="257761" data-batch-url="/posts/batch_likers">
                        4
                      </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/design-pattern-for-functional-concurrent-programming/49371/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-257761" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="257761"
                     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="257812" data-post-id="257812">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><em>Bit of a rant, sorry. Skip if you are not in the mood for one.</em></p>
<aside class="quote no-group" data-username="Mraiih" data-post="1" data-topic="49371">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mraiih/48/26976_2.png" class="avatar"> Mraiih:</div>
<blockquote>
<p>I know design patterns came to resolve some common problems in OOP</p>
</blockquote>
</aside>
<p>I would challenge even that. I worked with Java for 8-9 years and I worked with it in its heyday (and I dropped it when it became too crazy and “programming” in Java was 80% writing XML and 10% writing <code>.properties</code> files). The other 10% you <em>maybe</em> wrote some Java. <img src="https://forum.elixirforum.com/uploads/default/original/2X/6/6c3193d1dd46244da3c8c6f719c9f5e2abdd5ae8.gif?v=15" title=":003:" class="emoji emoji-custom" alt=":003:" loading="lazy" width="20" height="20"></p>
<p>Those “patterns” helped only insofar as everyone was using them and thus onboarding in other people’s code was accelerated and made easier. They didn’t help with much else otherwise. They were like 90% social norms and 10% legitimately helpful ways of manipulating data via standardized code that made it future-proof-ish.</p>
<p>I also believe the entire “patterns” wording is quite unfortunate and does not at all capture the idea. “Dependency inversion” is just “don’t just pass one of the 17 implementations of this contract as a parameter to the using function, you idiot, use configuration!” and nothing else. “Factory pattern” is more or less “you don’t know the internal invariants of this data structure so please use a dedicated creator function for it and don’t try to be clever by directly setting the fields yourself”. Etc.</p>
<p>These should be common sense and should not be called “a pattern”; more like “an engineering guideline”.</p>
<p>That whole terminology only serves to make guys in suits-and-ties feel special and label themselves as consultants and bill insane sums of money for scratching their beards in meetings. Change my mind. <img src="https://forum.elixirforum.com/images/emoji/apple/person_shrugging.png?v=15" title=":person_shrugging:" class="emoji" alt=":person_shrugging:" loading="lazy" width="20" height="20"> (It’s going to be hard because I’ve seen how they work, closely, several times in my career, and was not impressed. Of course it could also be bad luck, sure.)</p>
<hr>
<p>On topic: for FP I think <span class="hashtag-raw">#1</span> principle would be: make the thing you want to manipulate composable and pipe-able (reference: <code>Ecto.Query</code>, <code>Ecto.Multi</code>, <code>Stream</code>). Make it so you can manipulate the thing and accumulate / modify state captured inside of it. Make it so this can be done by any function abiding to a certain contract. Finally, invoke a function that actually “executes” what this thing represents (like <code>Repo.transaction</code> actually does all the DB operations accumulated inside an <code>Ecto.Multi</code>; while at the same time <code>Ecto.Multi.insert</code> function does nothing but put a state/command inside the <code>Ecto.Multi</code> that says “OK, when this Multi gets executed, we want to create this DB record”).</p>
<p>I have very small amount of failures in my career (although they make up for it being hugely embarrassing! <img src="https://forum.elixirforum.com/uploads/default/original/2X/6/6c3193d1dd46244da3c8c6f719c9f5e2abdd5ae8.gif?v=15" title=":003:" class="emoji emoji-custom" alt=":003:" loading="lazy" width="20" height="20">) and the “patterns” thing very rarely clicked with me, or most teams I ever worked with for that matter. People just organically and iteratively find what works best <em>for their project</em>. Stuff like “hexagonal architecture” or “functional core, imperative shell” are in general very good ideas and are emergent properties of most projects. I do like them but they too are not universally applicable.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="257812" data-batch-url="/posts/batch_likers">
                        8
                      </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/design-pattern-for-functional-concurrent-programming/49371/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-257812" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="257812"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="258191" data-post-id="258191">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Like <a class="mention" href="/u/scottming" rel="nofollow">@scottming</a> mentioned</p>
<p>This book is excellent and sort of on the topic <a href="https://pragprog.com/titles/jgotp/designing-elixir-systems-with-otp/" class="inline-onebox" rel="noopener nofollow ugc">Designing Elixir Systems with OTP: Write Highly Scalable, Self-Healing Software with Layers by James Edward Gray, II and Bruce A. Tate</a></p>
<p>It does not give you a long list of patterns that you can name and say that you know. But it does give some very practical step-by-step guidelines with examples of how to design software with Elixir.</p>
<p>Like OOP design patterns, the book’s content is better consumed as ideas that you can safely ignore in some situations but can help you work toward simpler, more extensible/testable/maintainable code.</p>
<p>Some things probably apply in every situation I can think of, for example: “Try to keep the bulk of your complexity in modules with as-pure-as-possible functions and keep your process machinery (Genservers, etc.) as thin as possible.”</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="258191" 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/design-pattern-for-functional-concurrent-programming/49371/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-258191" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="258191"
                     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="258383" data-post-id="258383">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’d recommend checking out posts from <a href="https://fsharpforfunandprofit.com/fppatterns/" class="inline-onebox" rel="noopener nofollow ugc">Functional Programming Design Patterns | F# for fun and profit</a></p>
<p>This talk on Micropatterns by Cameron Price is also worth a look <a href="https://www.youtube.com/watch?v=9uvp4h7gXHg" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=9uvp4h7gXHg</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="258383" 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/design-pattern-for-functional-concurrent-programming/49371/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-258383" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="258383"
                     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>