{"id":2374,"date":"2018-10-24T05:27:58","date_gmt":"2018-10-24T04:27:58","guid":{"rendered":"https:\/\/www.entropywins.wtf\/blog\/?p=2374"},"modified":"2019-03-01T16:32:43","modified_gmt":"2019-03-01T15:32:43","slug":"readable-functions-minimize-state","status":"publish","type":"post","link":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/","title":{"rendered":"Readable Functions: Minimize State"},"content":{"rendered":"<p>Several tricks and heuristics that I apply to write easy to understand functions keep coming up when I look at other peoples code. In this post I share the first of two key principles to writing readable functions. Follow up posts will contain the second key principle and specific tricks, often building on these general principles.<\/p>\n<p>What makes <a href=\"https:\/\/en.wikipedia.org\/wiki\/Functional_programming\">functional programming<\/a> so powerful? Why do developers that have mastered it say it makes them so much more productive? What amazing features or capabilities does the functional paradigm provide to enable this enhanced productivity? The answer is not what you might expect if you never looked into functional programming. The power of the functional paradigm does not come from new functionality, it comes from restricting something we are all familiar with: mutable state. By minimizing or altogether avoiding mutable state, functional programs skip a great source of complexity, thus becoming easier to understand and work with.<\/p>\n<h3>Minimize Mutability<\/h3>\n<p>If you are doing <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming\">Object Orientated Programming<\/a> you are hopefully aware of the drawbacks of having mutable objects. Similar drawbacks apply to mutable state within function scope, even if those functions are part of a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Procedural_programming\">procedural<\/a> program. Consider the below PHP code snippet:<\/p>\n<pre class=\"lang:php decode:true\">function getThing() {\n    var $thing = 'default';\n    \n    if (someCondition()) {\n        $thing = 'special case';\n    }\n    \n    return $thing;\n}<\/pre>\n<p>This function is needlessly complex because of mutable state. The variable <code>$thing<\/code> is in scope in the entire function and it gets modified. Thus to understand the function you need to keep track of the value that was assigned and how that value might get modified\/overridden. This mental overhead can easily be avoided by using what is called a <a href=\"https:\/\/www.entropywins.wtf\/blog\/2019\/01\/14\/readable-functions-guard-clause\/\">Guard Clause<\/a>:<\/p>\n<pre class=\"lang:php decode:true\">function getThing() {\n    if (someCondition()) {\n        return 'special case';\n    }\n    \n    return 'default';\n}<\/pre>\n<p>This code snippet is easier to understand because there is no state. The less state, the less things you need to remember while simulating the function in your head. Even though the logic in these code snippets is trivial, you can already notice how the <a href=\"https:\/\/www.quora.com\/What-are-essential-and-accidental-complexity\/answer\/Gordon-Lin-2\">Accidental Complexity<\/a> created by the mutable state makes understanding the code take more time and effort. It pays to write your functions in a functional manner even if you are not doing functional programming.<\/p>\n<h3>Minimize Scope<\/h3>\n<p>While mutable state is particularly harmful, non-mutable state also comes with a cost. What is the return value of this function?<\/p>\n<pre class=\"lang:php decode:true\">function getThing() {\n    $foo = 1;\n    $bar = 2;\n    $baz = 3;\n\n    $meh = $foo + $baz * 2;\n    $baz = square($meh);\n\n    print($baz);\n    return $bar;\n}<\/pre>\n<p>It is a lot easier to tell what the return value is when refactored as follows:<\/p>\n<pre class=\"lang:php decode:true\">function getThing() {\n    $foo = 1;\n    $baz = 3;\n\n    $meh = $foo + $baz * 2;\n    $baz = square($meh);\n    print($baz);\n\n    $bar = 2;\n    return $bar;\n}<\/pre>\n<p>To understand the return value you need to know where the last assignment to <code>$bar<\/code> happened. In the first snippet you, for no reason at all, need to scan up all the way to the first lines of the function. You can avoid this by minimizing the scope of <code>$bar<\/code>. This is especially important if, like in PHP, you cannot declare function scope values as constants. In the first snippet you likely spotted that <code>$bar = 2<\/code> before you went through the irrelevant details that follow. If instead the code had been <code>const bar = 2<\/code> like you can do in JavaScript, you would not have needed to make that effort.<\/p>\n<h3>Conclusion<\/h3>\n<p>With this understanding we arrive at two guidelines for scope in functions that you can&#8217;t avoid altogether in the first place. Thou shalt:<\/p>\n<ul>\n<li>Minimize mutability<\/li>\n<li>Minimize scope<\/li>\n<\/ul>\n<p>Indeed, these are two very general directives that you can apply in many other areas of software design. Keep in mind that these are just guidelines that serve as a starting point. Sometimes a little state or mutability can help readability.<\/p>\n<p>To minimize scope, create it as close as possible to where it is needed. The worst thing you can do is declare all state at the start of a function, as this maximizes scope. Yes, I&#8217;m looking at you JavaScript developers and university professors. If you find yourself in a team or community that follows the practice of declaring all variables at the start of a function, I recommend not going along with this custom because its harmful nature outweighs &#8220;consistency&#8221; and &#8220;tradition&#8221; benefits.<\/p>\n<p>To minimize mutability, stop every time you are about to override a variable and ask yourself if you cannot simplify the code. The answer is nearly always that you can via tricks such as Guard Clauses, many of which I will share in follow up posts. I myself rarely end up mutating variables, less than once per thousand 1000 lines of code. Because each removal of harmful mutability makes your code easier to work with you reap the benefits incrementally and can start applying this style right away. If you are lucky enough to work with a language that has constants in function scopes, use them as default instead of variables.<\/p>\n<h3>See also<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.entropywins.wtf\/blog\/tag\/readable-functions\/\">Readable Functions &#8211; all posts<\/a><\/li>\n<li><a href=\"https:\/\/www.entropywins.wtf\/blog\/2017\/01\/02\/simple-is-not-easy\/\">Simple is not easy<\/a><\/li>\n<li><a href=\"https:\/\/www.entropywins.wtf\/blog\/2017\/09\/06\/the-fallacy-of-dry\/\">The Fallacy of DRY<\/a><\/li>\n<li><a href=\"https:\/\/www.entropywins.wtf\/blog\/2016\/02\/01\/missing-in-php7-named-parameters\/\">Missing in PHP 7: Named parameters<\/a><\/li>\n<li><a href=\"https:\/\/www.entropywins.wtf\/blog\/2013\/09\/08\/clean-functions\/\">Clean Functions (2013 presentation)<\/a><\/li>\n<\/ul>\n<p>Thanks to <a href=\"http:\/\/gabriel-birke.de\/\">Gabriel Birke<\/a> for proofreading and making some suggestions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Several tricks and heuristics that I apply to write easy to understand functions keep coming up when I look at&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[452,328,363,439,455,377,400,459,197,460,316],"class_list":["post-2374","post","type-post","status-publish","format-standard","hentry","category-programming","tag-anti-patterns","tag-clean-code","tag-code-quality","tag-complexity","tag-design-principles","tag-functional-programming","tag-functions","tag-immutability","tag-planet-wikimedia","tag-readable-functions","tag-software-design"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Readable Functions: Minimize State - Blog of Jeroen De Dauw<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Readable Functions: Minimize State\" \/>\n<meta property=\"og:description\" content=\"Minimizing state is a key concept used by many tricks that make functions easier to read\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of Jeroen De Dauw\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-24T04:27:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-01T15:32:43+00:00\" \/>\n<meta name=\"author\" content=\"Jeroen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Readable Functions: Minimize State\" \/>\n<meta name=\"twitter:description\" content=\"Minimizing state is a key concept used by many tricks that make functions easier to read\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/JeroenDeDauw\" \/>\n<meta name=\"twitter:site\" content=\"@JeroenDeDauw\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeroen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/\"},\"author\":{\"name\":\"Jeroen\",\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#\\\/schema\\\/person\\\/4e2ef14f2ca7dc3a0ac137d1692b66b7\"},\"headline\":\"Readable Functions: Minimize State\",\"datePublished\":\"2018-10-24T04:27:58+00:00\",\"dateModified\":\"2019-03-01T15:32:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/\"},\"wordCount\":782,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#\\\/schema\\\/person\\\/4e2ef14f2ca7dc3a0ac137d1692b66b7\"},\"keywords\":[\"Anti-patterns\",\"Clean Code\",\"Code Quality\",\"Complexity\",\"Design principles\",\"Functional Programming\",\"Functions\",\"Immutability\",\"Planet Wikimedia\",\"Readable Functions\",\"Software design\"],\"articleSection\":[\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/\",\"url\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/\",\"name\":\"Readable Functions: Minimize State - Blog of Jeroen De Dauw\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#website\"},\"datePublished\":\"2018-10-24T04:27:58+00:00\",\"dateModified\":\"2019-03-01T15:32:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/2018\\\/10\\\/24\\\/readable-functions-minimize-state\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Readable Functions: Minimize State\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/\",\"name\":\"Entropy Wins\",\"description\":\"A blog on Software Architecture, Design and Craftsmanship\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#\\\/schema\\\/person\\\/4e2ef14f2ca7dc3a0ac137d1692b66b7\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.entropywins.wtf\\\/blog\\\/#\\\/schema\\\/person\\\/4e2ef14f2ca7dc3a0ac137d1692b66b7\",\"name\":\"Jeroen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g\",\"caption\":\"Jeroen\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/jeroendedauw\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/JeroenDeDauw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Readable Functions: Minimize State - Blog of Jeroen De Dauw","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/","og_locale":"en_US","og_type":"article","og_title":"Readable Functions: Minimize State","og_description":"Minimizing state is a key concept used by many tricks that make functions easier to read","og_url":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/","og_site_name":"Blog of Jeroen De Dauw","article_published_time":"2018-10-24T04:27:58+00:00","article_modified_time":"2019-03-01T15:32:43+00:00","author":"Jeroen","twitter_card":"summary_large_image","twitter_title":"Readable Functions: Minimize State","twitter_description":"Minimizing state is a key concept used by many tricks that make functions easier to read","twitter_creator":"@https:\/\/twitter.com\/JeroenDeDauw","twitter_site":"@JeroenDeDauw","twitter_misc":{"Written by":"Jeroen","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/#article","isPartOf":{"@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/"},"author":{"name":"Jeroen","@id":"https:\/\/www.entropywins.wtf\/blog\/#\/schema\/person\/4e2ef14f2ca7dc3a0ac137d1692b66b7"},"headline":"Readable Functions: Minimize State","datePublished":"2018-10-24T04:27:58+00:00","dateModified":"2019-03-01T15:32:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/"},"wordCount":782,"commentCount":3,"publisher":{"@id":"https:\/\/www.entropywins.wtf\/blog\/#\/schema\/person\/4e2ef14f2ca7dc3a0ac137d1692b66b7"},"keywords":["Anti-patterns","Clean Code","Code Quality","Complexity","Design principles","Functional Programming","Functions","Immutability","Planet Wikimedia","Readable Functions","Software design"],"articleSection":["Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/","url":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/","name":"Readable Functions: Minimize State - Blog of Jeroen De Dauw","isPartOf":{"@id":"https:\/\/www.entropywins.wtf\/blog\/#website"},"datePublished":"2018-10-24T04:27:58+00:00","dateModified":"2019-03-01T15:32:43+00:00","breadcrumb":{"@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/24\/readable-functions-minimize-state\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.entropywins.wtf\/blog\/"},{"@type":"ListItem","position":2,"name":"Readable Functions: Minimize State"}]},{"@type":"WebSite","@id":"https:\/\/www.entropywins.wtf\/blog\/#website","url":"https:\/\/www.entropywins.wtf\/blog\/","name":"Entropy Wins","description":"A blog on Software Architecture, Design and Craftsmanship","publisher":{"@id":"https:\/\/www.entropywins.wtf\/blog\/#\/schema\/person\/4e2ef14f2ca7dc3a0ac137d1692b66b7"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.entropywins.wtf\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.entropywins.wtf\/blog\/#\/schema\/person\/4e2ef14f2ca7dc3a0ac137d1692b66b7","name":"Jeroen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g","caption":"Jeroen"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d62e6b5b8e332335cf17854fac850d9c70ba367c4692872613c3110ebd4e009b?s=96&d=mm&r=g"},"sameAs":["https:\/\/www.linkedin.com\/in\/jeroendedauw\/","https:\/\/x.com\/https:\/\/twitter.com\/JeroenDeDauw"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p74TBF-Ci","jetpack-related-posts":[{"id":2392,"url":"https:\/\/www.entropywins.wtf\/blog\/2018\/10\/30\/readable-functions-do-one-thing\/","url_meta":{"origin":2374,"position":0},"title":"Readable Functions: Do One Thing","author":"Jeroen","date":"2018-10-30","format":false,"excerpt":"Several tricks and heuristics that I apply to write easy to understand functions keep coming up when I look at other people their code. This post outlines the second key principle. The first principle is Minimize State. Following posts will contain specific tips and tricks, often building on these two\u2026","rel":"","context":"In \"Clean Code\"","block_context":{"text":"Clean Code","link":"https:\/\/www.entropywins.wtf\/blog\/tag\/clean-code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2407,"url":"https:\/\/www.entropywins.wtf\/blog\/2019\/01\/14\/readable-functions-guard-clause\/","url_meta":{"origin":2374,"position":1},"title":"Readable Functions: Guard Clause","author":"Jeroen","date":"2019-01-14","format":false,"excerpt":"Guard Clauses are one of my favorite little tricks that allow simplifying code. A guard clause is an if statement with a return in it. Consider the following code: function doThing() { var $thing = 'default'; if (someCondition()) { $thing = 'special case'; } return $thing; } Using a Guard\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.entropywins.wtf\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2877,"url":"https:\/\/www.entropywins.wtf\/blog\/2022\/09\/21\/advice-for-junior-developers\/","url_meta":{"origin":2374,"position":2},"title":"Advice for junior developers","author":"Jeroen","date":"2022-09-21","format":false,"excerpt":"Over the 15+ years of my development career, I have learned several things that significantly increase my effectiveness. In this post, I share those learnings with you. Structure: Generic Advice -- Important context and motivation for the technical advice Technical Advice -- The main course Recommended Reading -- Links to\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.entropywins.wtf\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2022\/09\/code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2022\/09\/code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2022\/09\/code.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2022\/09\/code.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2022\/09\/code.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1582,"url":"https:\/\/www.entropywins.wtf\/blog\/2016\/02\/01\/missing-in-php7-named-parameters\/","url_meta":{"origin":2374,"position":3},"title":"Missing in PHP7: Named parameters","author":"Jeroen","date":"2016-02-01","format":false,"excerpt":"This is the second\u00a0post in my Missing in PHP7 series. The previous one is about\u00a0function references. 2020 update: named parameters will be in PHP 8 since the RFC passed. Readability of code is very important, and this is most certainly not readable: getCatPictures( 10, 0, true ); You can make\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.entropywins.wtf\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1821,"url":"https:\/\/www.entropywins.wtf\/blog\/2016\/10\/29\/refactoring-horrible-lua-code\/","url_meta":{"origin":2374,"position":4},"title":"Object Orientated Lua code","author":"Jeroen","date":"2016-10-29","format":false,"excerpt":"During the last few weeks I've been refactoring some horrible Lua code. This has been a ton of fun so far, and I learned many new things about Lua that I'd like to share. Such\u00a0Horrible Code The code in question is that of a scripted Supreme Commander Forged Alliance Forever\u2026","rel":"","context":"In &quot;Gaming&quot;","block_context":{"text":"Gaming","link":"https:\/\/www.entropywins.wtf\/blog\/category\/gaming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.entropywins.wtf\/blog\/wp-content\/uploads\/2016\/10\/final-rush-loc.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1577,"url":"https:\/\/www.entropywins.wtf\/blog\/2016\/01\/30\/missing-in-php7-function-references\/","url_meta":{"origin":2374,"position":5},"title":"Missing in PHP7: function references","author":"Jeroen","date":"2016-01-30","format":false,"excerpt":"This is the first post in my Missing in PHP7 series. Over time, PHP has improved its capabilities with regards to functions.\u00a0As of PHP 5.3 you can create anonymous functions and as of 5.4 you can use the callable type hint. However referencing a function still requires using a string.\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.entropywins.wtf\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/posts\/2374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/comments?post=2374"}],"version-history":[{"count":7,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/posts\/2374\/revisions"}],"predecessor-version":[{"id":2515,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/posts\/2374\/revisions\/2515"}],"wp:attachment":[{"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/media?parent=2374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/categories?post=2374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.entropywins.wtf\/blog\/wp-json\/wp\/v2\/tags?post=2374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}