<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eugenio Carocci on Medium]]></title>
        <description><![CDATA[Stories by Eugenio Carocci on Medium]]></description>
        <link>https://medium.com/@carocci-eugenio?source=rss-77b5e895a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kO2wnguTRf3kw2ljOS3tuw.jpeg</url>
            <title>Stories by Eugenio Carocci on Medium</title>
            <link>https://medium.com/@carocci-eugenio?source=rss-77b5e895a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 08:19:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carocci-eugenio/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DRY Principle and Domain-Driven Design: A Synergistic Approach to Efficient Software Development]]></title>
            <link>https://carocci-eugenio.medium.com/dry-principle-and-domain-driven-design-a-synergistic-approach-to-efficient-software-development-63cea4c87736?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/63cea4c87736</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 17:56:00 GMT</pubDate>
            <atom:updated>2024-01-16T17:56:00.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aQr5YUwGjdlZQHpf" /><figcaption>Photo by <a href="https://unsplash.com/@kaitlynbaker?utm_source=medium&amp;utm_medium=referral">Kaitlyn Baker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the evolving landscape of software development, principles like the DRY <em>(Don’t Repeat Yourself)</em> principle and methodologies such as DDD <em>(Domain-Driven Design)</em> have significantly impacted how we approach software development. This article explores the synergy between these methodologies and how they can be integrated to enhance code quality and maintainability.</p><h4>Understanding the DRY Principle</h4><p>The DRY principle, a concept emphasized by Andy Hunt and Dave Thomas in “The Pragmatic Programmer”, advocates for minimizing the repetition of software patterns. It is based on the premise that each piece of knowledge should have a single, authoritative representation in a system, reducing redundancy and fostering a more maintainable codebase.</p><h4>Exploring Domain-Driven Design</h4><p>Domain-Driven Design, formulated by Eric Evans, focuses on aligning software design closely with a specific business domain. It encourages collaboration between developers and domain experts to ensure the software architecture reflects the complexities and intricacies of the domain.</p><h4>Synergy Between DRY and DDD</h4><p>The integration of DRY and DDD offers several advantages. DRY ensures consistency in the domain model, simplifies maintenance, and enhances communication. However, as highlighted in <em>“Strategic Monoliths and Microservices — Driving Innovation Using Purposeful Architecture”</em> by Vaughn Vernon and Tomasz Jaskula, it’s crucial to understand the real essence of DRY:</p><blockquote>Disregarding DRY (Don’t Repeat Yourself)</blockquote><blockquote>There is a cost to code unification. It results in coupling and complexity, and leads to increased communication between modules and the teams working on them. Still, code repetition is bad. The zealous pursuit of DRY is often based on the misunderstanding that DRY is about code. It’s not. It’s about knowledge. DRY is meant to emphasize that duplication of knowledge is a poor choice. For Example, the Claims Context might have a Policy as a Value Object with all the properties needed by Claims. The Policy in the Underwriting Context is an Entity, and very different from the Policy in Claims. Those holding the wrong view of DRY would insist on unifying both into a single class; however, doing so would result in a complex model. including the creation of a “god class” that is highly coupled to everything else. Such unification blurs the boundaries between two separate contexts that should purposely model a Policy as two different concepts. Bounded Contexts are entirely about dividing concepts into contextually correct models by business language. Creating a unique kind of Policy in both Underwriting and Claims is not a violation of DRY, even if some aspects of the code in the different models bear some similarities.</blockquote><p>This excerpt emphasizes the importance of understanding DRY as a principle of knowledge unification rather than mere code reduction.</p><h4>Implementing DRY in a DDD Context</h4><p>In a DDD approach, implementing DRY involves identifying and defining aggregate roots, establishing a ubiquitous language, and creating a shared kernel. The goal is to maintain a single source of truth in domain models while respecting the distinct contexts of different business modules.</p><h4>Challenges and Considerations</h4><p>While the combination of DRY and DDD is beneficial, it requires a balance to avoid over-engineering. The key is understanding that DRY is about knowledge and not just code, and applying it judiciously within the context of DDD.</p><h4>Conclusion</h4><p>DRY and Domain-Driven Design, when correctly understood and applied, form a powerful duo in software development. They guide developers in creating systems that are not only efficient and maintainable but also closely aligned with business needs. The essence lies in understanding the principles deeply and applying them in a context-sensitive manner.</p><h4>References</h4><ul><li>Hunt, Andy, and Dave Thomas. “The Pragmatic Programmer.”</li><li>Evans, Eric. “Domain-Driven Design: Tackling Complexity in the Heart of Software.”</li><li>Vernon, Vaughn, and Tomasz Jaskula. “Strategic Monoliths and Microservices — Driving Innovation Using Purposeful Architecture.”</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63cea4c87736" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Easily Manage Multiple Git Configurations]]></title>
            <link>https://medium.com/geekculture/how-to-easily-manage-multiple-git-configurations-8795d915367c?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8795d915367c</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[dev]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 03:31:25 GMT</pubDate>
            <atom:updated>2023-03-05T03:31:25.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZYyeC_U4O_XpG7sE" /><figcaption>Photo by <a href="https://unsplash.com/@dancristianpaduret?utm_source=medium&amp;utm_medium=referral">Dan Cristian Pădureț</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Some time ago, I had the necessity to work on my machine for different clients and to do so I needed to configure my Git client differently based on the project.</p><p>I looked around for common solutions out there, looking at pros and cons, and apparently the best approach is the one that I’m going to share with you all today.</p><blockquote>You will thank me, I know it!</blockquote><h3>How does Git config works?</h3><p>First, we need to understand how Git configuration actually works.</p><p>Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places</p><ul><li>[path]/etc/gitconfig file: Contains values applied to every user on the system and all their repositories. If you pass the option --system to git config, it reads and writes from this file specifically. Because this is a system configuration file, you would need administrative or superuser privilege to make changes to it.</li><li>~/.gitconfig or ~/.config/git/config file: Values specific personally to you, the user. You can make Git read and write to this file specifically by passing the --global option, and this affects <strong>all</strong> of the repositories you work with on your system.</li><li>config file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository. You can force Git to read from and write to this file with the --local option, but that is in fact the default. Unsurprisingly, you need to be located somewhere in a Git repository for this option to work properly.</li></ul><p>Each level overrides values in the previous level, so values in .git/config trump those in [path]/etc/gitconfig.</p><p>If you want to understand more about this look at <a href="https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup">this</a> :)</p><h3>And here’s the solution you’re looking for</h3><p>For the purpose of explaining my solution I’m gonna suppose that I need to work for a couple of clients that will be called, with a lot of fantasy, <strong>client A </strong>and <strong>client B</strong>.</p><p>The idea is that all the projects belonging to client A will be in ~/clientA/ whereas those for client B will be in ~/clientB/.</p><p>Now you can define the following files</p><ul><li>~/.gitconfig-clientA</li><li>~/.gitconfig-clientB</li></ul><p>Each of those will hold client specific configuration such as the email, SSH configuration and all the other possible items.</p><p>Last piece of the solution is to update the already existing ~/.gitconfig file with the following</p><pre>[includeIf &quot;gitdir:~/clientA/&quot;]<br>  path = .gitconfig-clientA<br>[includeIf &quot;gitdir:~/clientB/&quot;]<br>  path = .gitconfig-clientB</pre><p>If you need to use different SSH keys based on the client folder you can simply add the following configuration to the correct ~/.gitconfig-clientA file.</p><pre>[core]<br>  sshCommand = ssh -i ~/.ssh/ssh_private_key_for_client</pre><p>You can read more about how this sshCommand works by looking at the official documentation <a href="https://git-scm.com/docs/git-config#Documentation/git-config.txt-coresshCommand">here</a>.</p><p>So, what are you waiting for? Don’t be shy and give it a try! I hope you have enjoyed this article and see you all in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8795d915367c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-easily-manage-multiple-git-configurations-8795d915367c">How To Easily Manage Multiple Git Configurations</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in PHP 8.2]]></title>
            <link>https://medium.com/better-programming/whats-new-in-php-8-2-bcdf951cbd11?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcdf951cbd11</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Sat, 17 Dec 2022 01:10:15 GMT</pubDate>
            <atom:updated>2022-12-17T01:10:15.326Z</atom:updated>
            <content:encoded><![CDATA[<h4>Readonly classes, a new “Random” extension, and more</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*88G6aS-zp6vNYRJw" /><figcaption>Photo by <a href="https://unsplash.com/@timmossholder?utm_source=medium&amp;utm_medium=referral">Tim Mossholder</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article I’m going to quickly explaining the new goodies PHP is providing to us for Christmas with the <a href="https://www.php.net/index.php#2022-12-08-1">PHP 8.2 release</a>.</p><p>This is a major update of the PHP language. It contains many new features, including readonly classes, null, false, and true as stand-alone types, deprecated dynamic properties, performance improvements and more.</p><h3>Readonly classes</h3><p>PHP &lt; 8.2</p><pre>class BlogData<br>{<br>    public readonly string $title;<br><br>    public readonly Status $status;<br><br>    public function __construct(string $title, Status $status)<br>    {<br>        $this-&gt;title = $title;<br>        $this-&gt;status = $status;<br>    }<br>}</pre><p>PHP ≥ 8.2</p><pre>readonly class BlogData<br>{<br>    public string $title;<br><br>    public Status $status;<br><br>    public function __construct(string $title, Status $status)<br>    {<br>        $this-&gt;title = $title;<br>        $this-&gt;status = $status;<br>    }<br>}</pre><p>As of PHP 8.2.0, a class can be marked with the readonly modifier. Marking a class as readonly will add the <a href="https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.readonly-properties">readonly modifier</a> to every declared property, and prevent the creation of <a href="https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.dynamic-properties">dynamic properties</a>.</p><p>Moreover, it is impossible to add support for them by using the <a href="https://www.php.net/manual/en/class.allow-dynamic-properties.php">AllowDynamicProperties</a> attribute. Attempting to do so will trigger a compile-time error.</p><pre>#[AllowDynamicProperties]<br>readonly class Foo {<br>}<br><br>// Fatal error: Cannot apply #[AllowDynamicProperties] to readonly class Foo</pre><p>As neither untyped, nor static properties can be marked with the readonly modifier, readonly classes cannot declare them either.</p><pre>readonly class Foo<br>{<br>    public $bar;<br>}<br><br>// Fatal error: Readonly property Foo::$bar must have type<br>?&gt;</pre><pre>readonly class Foo<br>{<br>    public static int $bar;<br>}<br><br>// Fatal error: Readonly class Foo cannot declare static properties</pre><p>Remember that a readonly class can be extended if, and only if, the child class is also a readonly class.</p><h3>Disjunctive Normal Form (DNF) Types</h3><p>PHP &lt; 8.2</p><pre>class Foo {<br>    public function bar(mixed $entity) {<br>        if ((($entity instanceof A) &amp;&amp; ($entity instanceof B)) || ($entity === null)) {<br>            return $entity;<br>        }<br><br>        throw new Exception(&#39;Invalid entity&#39;);<br>    }<br>}</pre><p>PHP ≥ 8.2</p><pre>class Foo {<br>    public function bar((A&amp;B)|null $entity) {<br>        return $entity;<br>    }<br>}</pre><p>DNF <em>(psss, if you want to learn more about Disjunctive Normal Form see </em><a href="https://en.wikipedia.org/wiki/Disjunctive_normal_form"><em>this Wikipedia page</em></a><em>)</em> types allow us to combine <a href="https://www.php.net/manual/en/language.types.type-system.php#language.types.type-system.composite.union">union</a> and <a href="https://www.php.net/manual/en/language.types.type-system.php#language.types.type-system.composite.intersection">intersection</a> types, following a strict rule: when combining union and intersection types, intersection types must be grouped with brackets.</p><p>See some examples below to understand it a little bit more</p><pre>// Accepts an object that implements both A and B,<br>// OR an object that implements D.<br>(A&amp;B)|D<br><br>// Accepts an object that implements C, <br>// OR a child of X that also implements D,<br>// OR null.<br>C|(X&amp;D)|null<br><br>// Accepts an object that implements all three of A, B, and D, <br>// OR an int, <br>// OR null.<br>(A&amp;B&amp;D)|int|null</pre><h3>Allow null, false, and true as stand-alone types</h3><p>PHP &lt; 8.2</p><pre>class Falsy<br>{<br>    public function almostFalse(): bool { /* ... */ *}<br><br>    public function almostTrue(): bool { /* ... */ *}<br><br>    public function almostNull(): string|null { /* ... */ *}<br>}</pre><p>PHP ≥ 8.2</p><pre>class Falsy<br>{<br>    public function alwaysFalse(): false { /* ... */ *}<br><br>    public function alwaysTrue(): true { /* ... */ *}<br><br>    public function alwaysNull(): null { /* ... */ *}<br>}</pre><p>See an example of why the definition of the true type does make sense indeed</p><pre>class User {<br>    function isAdmin(): bool<br>}<br> <br>class Admin extends User<br>{<br>    function isAdmin(): true<br>    {<br>        return true;<br>    }<br>}</pre><h3>New “Random” extension</h3><p>PHP ≥ 8.2</p><pre>use Random\Engine\Xoshiro256StarStar;<br>use Random\Randomizer;<br><br>$blueprintRng = new Xoshiro256StarStar(<br>    hash(&#39;sha256&#39;, &quot;Example seed that is converted to a 256 Bit string via SHA-256&quot;, true)<br>);<br><br>$fibers = [];<br>for ($i = 0; $i &lt; 8; $i++) {<br>    $fiberRng = clone $blueprintRng;<br>    // Xoshiro256**&#39;s &#39;jump()&#39; method moves the blueprint ahead 2**128 steps, as if calling<br>    // &#39;generate()&#39; 2**128 times, giving the Fiber 2**128 unique values without needing to reseed.<br>    $blueprintRng-&gt;jump();<br><br>    $fibers[] = new Fiber(function () use ($fiberRng, $i): void {<br>        $randomizer = new Randomizer($fiberRng);<br><br>        echo &quot;{$i}: &quot; . $randomizer-&gt;getInt(0, 100), PHP_EOL;<br>    });<br>}<br><br>// The randomizer will use a CSPRNG by default.<br>$randomizer = new Randomizer();<br><br>// Even though the fibers execute in a random order, they will print the same value<br>// each time, because each has its own unique instance of the RNG.<br>$fibers = $randomizer-&gt;shuffleArray($fibers);<br>foreach ($fibers as $fiber) {<br>    $fiber-&gt;start();<br>}</pre><p>The “random” extension provides a new object-oriented API to random number generation. Instead of relying on a globally seeded random number generator (RNG) using the <a href="https://en.wikipedia.org/wiki/Mersenne_Twister">Mersenne Twister algorithm</a> the object-oriented API provides several classes (“Engine”s) providing access to modern algorithms that store their state within objects to allow for multiple independent seedable sequences.</p><p>The \Random\Randomizer class provides a high-level interface to use the engine&#39;s randomness to generate a random integer, to shuffle an array or string, to select random array keys and more.</p><h3>Constants in traits</h3><p>PHP ≥ 8.2</p><pre>trait Foo<br>{<br>    public const CONSTANT = 1;<br>}<br><br>class Bar<br>{<br>    use Foo;<br>}<br><br>var_dump(Bar::CONSTANT); // 1<br>var_dump(Foo::CONSTANT); // Error</pre><p>Trait constants can be defined in the same way as class constants, and are flattened into the definition of the composing class in the same way as property and method definitions in traits.</p><p>You cannot access the constant through the name of the trait, but, you can access the constant through the class that uses the trait.</p><h3>Deprecate dynamic properties</h3><p>PHP &lt; 8.2</p><pre>class User<br>{<br>    public $name;<br>}<br><br>$user = new User();<br>$user-&gt;last_name = &#39;Doe&#39;;<br><br>$user = new stdClass();<br>$user-&gt;last_name = &#39;Doe&#39;;</pre><p>PHP ≥ 8.2</p><pre>class User<br>{<br>    public $name;<br>}<br><br>$user = new User();<br>$user-&gt;last_name = &#39;Doe&#39;; // Deprecated notice<br><br>$user = new stdClass();<br>$user-&gt;last_name = &#39;Doe&#39;; // Still allowed</pre><p>The creation of dynamic properties is deprecated to help avoid mistakes and typos, unless the class opts in by using the #[\AllowDynamicProperties] attribute. stdClass allows dynamic properties.</p><p>Usage of the __get/__set magic methods is not affected by this change.</p><p>Removing support for dynamic properties constitutes a significant backwards compatibility break. While modern PHP code consistently declares used properties, this is not necessarily the case for legacy code.</p><p>When encountering a dynamic property deprecation warning, there are a number of things that can be done to avoid it. The simplest and most common would be to simply add the property declaration:</p><pre>class Test {<br>    public $value; // &lt;-- Add property declaration.<br> <br>    public function __construct($value) {<br>        $this-&gt;value = $value;<br>    }<br>}</pre><p>So, what are you waiting for? Check out the migration guide to upgrade to PHP 8.2 and give it a try! I hope you have enjoyed this article and see you all in the next one!</p><h3>Resources</h3><ul><li><a href="https://www.php.net/releases/8.2/en.php">https://www.php.net/releases/8.2/en.php</a></li><li><a href="https://wiki.php.net/rfc/dnf_types">https://wiki.php.net/rfc/dnf_types</a></li><li><a href="https://wiki.php.net/rfc/true-type">https://wiki.php.net/rfc/true-type</a></li><li><a href="https://wiki.php.net/rfc/constants_in_traits">https://wiki.php.net/rfc/constants_in_traits</a></li><li><a href="https://wiki.php.net/rfc/deprecate_dynamic_properties">https://wiki.php.net/rfc/deprecate_dynamic_properties</a></li><li><a href="https://www.php.net/manual/en/migration82.php">https://www.php.net/manual/en/migration82.php</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcdf951cbd11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/whats-new-in-php-8-2-bcdf951cbd11">What’s New in PHP 8.2</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decorator Pattern? What That’s All About?]]></title>
            <link>https://medium.com/geekculture/decorator-pattern-what-thats-all-about-11b7aa6bceeb?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/11b7aa6bceeb</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Wed, 07 Dec 2022 22:01:37 GMT</pubDate>
            <atom:updated>2022-12-07T22:01:37.677Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UOUsZSlDqLJZ3hyy" /><figcaption>Photo by <a href="https://unsplash.com/@christopher__burns?utm_source=medium&amp;utm_medium=referral">Christopher Burns</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I remember when I was attending software engineering course back at the university some years ago <em>(quite a few, time fliiiiies)</em>, it was a spring afternoon and I was quite tired due to some kind of heavy lunch <em>(you know, we italians, do like to eat a lot when it comes to lunch).</em></p><p>At some point the professor went through his presentation and best guess about my thoughts is “oh my god this is boring, when is it going to finish?”.</p><p>Lesson was about the Decorator design pattern from the Gang of Four.</p><p>Fast forward to today, in my current job I use this pattern regularly to create flexible, extensible, easy to test and all the other good adjectives solution.</p><p>So, the goal of this article is to share with you why you should know this pattern and how you could benefit from it :)</p><h3>So what is this Decorator design pattern?</h3><p>In object-oriented programming, the decorator is a design pattern that allows behaviour to be added to an individual object, dynamically, without affecting the behaviour of other objects from the same class.</p><p>This one allows functionality to be divided between classes with unique areas of concern. Decorator use can be more efficient than subclassing, because an object’s behaviour can be augmented without defining an entirely new object.</p><p>If you want to know more about this one I suggest to either read the Decorator chapter in the <a href="https://en.wikipedia.org/wiki/Design_Patterns">GoF design pattern book</a> or check out <a href="https://en.wikipedia.org/wiki/Decorator_pattern">the Wikipedia article</a>.</p><h3>A report generation problem</h3><p>So, recently I had to face a new challenge at work where I needed to create multiple reports to show customers some <em>preeecious</em> data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*pQAGO96rOr_Xj7gvL48JYA.jpeg" /></figure><p>Obviously, when you need to show data to user you have to:</p><ul><li>Check if the user requesting it is authorized to do so</li><li>Check if it is needed to show only a subset of the requested data</li><li>Check if the request is valid and all the required information are provided</li></ul><p>And the list could go on and on depending on your use-case.</p><p>And to demonstrate that software development is an always changing process, along the way, product team asked for a way to provide a cached version of the report <strong>but</strong> only if user permissions were not changed between the storage of the report in cache and the request time.</p><h3>Naive solution</h3><p>At first I started to write these reports one-by-one in a pretty independent manner, meaning that, I was slowly but steadily duplicating my code to take into account all the business necessities.</p><p>The solution wasn’t that bad, it was something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/0*022FZto1IU50ybn8" /></figure><p>Basically, for each report I defined one request, generator and response object with the simple factory responsible for retrieving the correct generator based on the request.</p><p>The business logic was all located inside the generator class that was responsible for taking into account <strong>all</strong> the business requirements.</p><p>It was nice since and easily extensible, if you needed to work on a specific report you were able to do that on a single class and it was easily testable.</p><p>But, the more reports I was creating the more I was getting to the point that I could have improved something a little bit by being more mindful about my approach, especially, I thought that I could have find a better way to handle some of the common business requirements.</p><h3>Solution with the Decorator design pattern</h3><p>Soooo, here’s what I did to improve my solution by taking advantage of the Decorator design pattern :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*pp1U6uR5KOWfEj8u" /></figure><p>Basically the idea is to define multiple decorator classes, each one with a very specific responsibility: one to retrieve what the user can and can’t access, one to check if there’s already a cached version of the report and so on.</p><p>The beauty of having decorators with just one clear responsibility is that they are easy to be developed, tested and composed together. Is this ringing some bell such as <a href="https://en.wikipedia.org/wiki/Single-responsibility_principle">single responsibility</a> or <a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle">open-closed</a> principle? 👀</p><p>Each generator will work on the request object and will execute its thing, for instance:</p><ul><li>PermissionDecorator will remove item from the request that can not be accessed by the user</li><li>CacheDecorator will check if the same request has already been processed and the response it’s available in cache, if that’s the case no more processing will be done and the cached response will be provided back to the client</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3sjntSOaofW3neth" /></figure><h3>Final Thoughts</h3><p>I hope that this article helped some of you figure out the potential of this design pattern when you have to deal with similar problems!</p><p>Thanks for reading and feel free to add comments about your experiences :)</p><p><em>All the diagrams have been created using </em><a href="https://plantuml.com/"><em>https://plantuml.com/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11b7aa6bceeb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/decorator-pattern-what-thats-all-about-11b7aa6bceeb">Decorator Pattern? What That’s All About?</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mocking third-party services in integration testing]]></title>
            <link>https://medium.com/geekculture/mocking-third-party-services-in-integration-testing-7ded9ac1fe83?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ded9ac1fe83</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-test-automation]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Mon, 25 Oct 2021 13:11:19 GMT</pubDate>
            <atom:updated>2021-10-25T13:11:19.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mocking Third-Party Services in Integration Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4YpiS1gwGLOiy61Q" /><figcaption>Photo by <a href="https://unsplash.com/@glencarrie?utm_source=medium&amp;utm_medium=referral">Glen Carrie</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Current application development is more and more subjected to the use of third-party services for a variety of reasons, to speed up the development process, to rely on some robust and reliable solutions and many other reasonable reasons.</p><p>Yet, we need an effective way to be able to write and execute automated tests for our applications in an isolated environment, because, always remember that…</p><blockquote>A code that cannot be tested is flawed.</blockquote><p>In this article, I’ll explain the strategy that I’ve found effective to mock external services with a tool called <a href="https://www.mock-server.com/">MockServer</a> while doing integration testing.</p><p>Suppose that you’re dealing with an application, that among other things, needs to validate an <a href="https://it.wikipedia.org/wiki/International_Bank_Account_Number">IBAN</a> in different scenarios, for instance, while creating a new user. To do so different approaches can be adopted, starting from just validating the IBAN format <em>(a weak check)</em>, up to the real-time validation interacting with a third-party service like <a href="https://www.iban.com/validation-api">this one</a>.</p><p>So, first thing first, let’s give some details about this tool.</p><h3>MockServer</h3><p>I’ve found this great tool a while ago, and it’s been love at first sight ❤</p><p>This tool can be used as:</p><ul><li>a mock configured to return specific responses for different requests.</li><li>a proxy recording and optionally modifying requests and responses.</li><li>both a proxy for some requests and a mock for other requests at the same time.</li></ul><p>When the MockServer receives a request it matches the request against active <strong>expectations</strong> that have been configured, if no matches are found it proxies the request if appropriate otherwise a 404 is returned.</p><p>An <strong>expectation</strong> defines the <strong>action</strong> that is taken, for example, a response could be returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yREPLNumM3Zbe1IW.png" /><figcaption>Example of mocking with MockServer</figcaption></figure><p>It is possible to use this tool in a variety of ways, yet my preferred approach is to use the <a href="https://hub.docker.com/r/mockserver/mockserver">official Docker image</a>, which, at the time of writing, has been pulled more than 50 million times.</p><h3>How does it work?</h3><p>As briefly explained, the MockServer can be configured by defining expectations, which are blocks of request-response.</p><p>I’m in love with examples, I think they’re the best thing to let someone understand concepts, so let’s go back to our application that needs to validate an IBAN.</p><p>Probably we will execute an HTTPs request similar to the following one</p><pre>GET <a href="https://iban-validator-service.com/">https://iban-validator-service.com</a>/api/v1/validate?iban=NL95RABO9809158653</pre><pre>Authorization: Bearer api-key</pre><p>So, we will need to define an expectation like this</p><pre>{<br>        &quot;httpRequest&quot;: {<br>            &quot;method&quot;: &quot;GET&quot;,<br>            &quot;path&quot;: &quot;/api/v1/validate&quot;,<br>            &quot;queryStringParameters&quot;: {<br>                &quot;iban&quot;: [ &quot;NL95RABO9809158653&quot; ]<br>            },<br>            &quot;headers&quot;: {<br>                &quot;Authorization&quot;: [<br>                    &quot;Bearer api-key&quot;<br>                ]<br>            },<br>        },<br>        &quot;httpResponse&quot;: {<br>            &quot;statusCode&quot;: 200,<br>            &quot;body&quot;: {<br>                &quot;bank_data&quot;: {<br>                    &quot;bic&quot;: &quot;RABONL2UXXX&quot;,<br>                    &quot;branch&quot;: null,<br>                    &quot;bank&quot;: &quot;RABOBANK NEDERLAND&quot;,<br>                    &quot;address&quot;: &quot;CROESELAAN 18&quot;,<br>                    &quot;city&quot;: &quot;UTRECHT&quot;,<br>                    &quot;state&quot;: null,<br>                    &quot;zip&quot;: &quot;3500 HG&quot;,<br>                    &quot;phone&quot;: null,<br>                    &quot;fax&quot;: null,<br>                    &quot;www&quot;: null,<br>                    &quot;email&quot;: null,<br>                    &quot;country&quot;: &quot;Netherlands&quot;,<br>                    &quot;country_iso&quot;: &quot;NL&quot;,<br>                    &quot;account&quot;: &quot;9809158653&quot;,<br>                    &quot;bank_code&quot;: &quot;RABO&quot;,<br>                    &quot;branch_code&quot;: &quot;&quot;<br>                },<br>                &quot;sepa_data&quot;: {<br>                    &quot;SCT&quot;: &quot;YES&quot;,<br>                    &quot;SDD&quot;: &quot;YES&quot;,<br>                    &quot;COR1&quot;: &quot;YES&quot;,<br>                    &quot;B2B&quot;: &quot;YES&quot;,<br>                    &quot;SCC&quot;: &quot;NO&quot;<br>                },<br>                &quot;validations&quot;: {<br>                    &quot;chars&quot;: {<br>                        &quot;code&quot;: &quot;006&quot;,<br>                        &quot;message&quot;: &quot;IBAN does not contain illegal characters&quot;<br>                    },<br>                    &quot;account&quot;: {<br>                        &quot;code&quot;: &quot;002&quot;,<br>                        &quot;message&quot;: &quot;Account Number check digit is correct&quot;<br>                    },<br>                    &quot;iban&quot;: {<br>                        &quot;code&quot;: &quot;001&quot;,<br>                        &quot;message&quot;: &quot;IBAN Check digit is correct&quot;<br>                    },<br>                    &quot;structure&quot;: {<br>                        &quot;code&quot;: &quot;005&quot;,<br>                        &quot;message&quot;: &quot;IBAN structure is correct&quot;<br>                    },<br>                    &quot;length&quot;: {<br>                        &quot;code&quot;: &quot;003&quot;,<br>                        &quot;message&quot;: &quot;IBAN Length is correct&quot;<br>                    },<br>                    &quot;country_support&quot;: {<br>                        &quot;code&quot;: &quot;007&quot;,<br>                        &quot;message&quot;: &quot;Country supports IBAN standard&quot;<br>                    }<br>                },<br>                &quot;errors&quot;: []<br>            }<br>        }<br>    }</pre><p>With this expectation defined the mock-server will reply as if we would interact with the real service.</p><p>Obviously, this is a very simple example just to show the main idea behind the usage of this tool. More examples of expectations can be found on the <a href="https://www.mock-server.com/mock_server/creating_expectations.html">official documentation page</a>.</p><h3>How can I use it?</h3><p>As previously said, the MockServer can be found in different forms yet my preferred one is through the official Docker image.</p><p>Let’s suppose we have a PHP application with a <a href="https://docs.docker.com/compose/">Docker Compose</a> cluster defined on the <em>docker-compose.yml</em> like this</p><pre>version: &#39;3.8&#39;<br># --------- #<br># Services  #<br># --------- #<br>services:<br>  nginx:<br>    ...<br>  php-fpm:<br>    networks:<br>      internal:<br>        aliases:<br>          - php-fpm.internal<br>    ...<br># --------- #<br># Networks  #<br># --------- #<br>networks:<br>  internal:</pre><p>Then what we want to do is to add a MockServer instance for the IBAN validator service transforming the configuration to this one</p><pre>version: &#39;3.8&#39;<br># --------- #<br># Services  #<br># --------- #<br>services:<br>  nginx:<br>    ...<br>  php-fpm:<br>    networks:<br>      internal:<br>        aliases:<br>          - php-fpm.internal<br>    ...<br>  mock-iban-validator:<br>    image: mockserver/mockserver<br>    networks:<br>      internal:<br>        aliases:<br>          - mock-iban-validator.internal<br>    volumes:<br>      - $PWD/docker/mock-server/iban-checker/:/config/<br>    environment:<br>      SERVER_PORT: 1080<br>      MOCKSERVER_INITIALIZATION_JSON_PATH: /config/expectations.json<br># --------- #<br># Networks  #<br># --------- #<br>networks:<br>  internal:</pre><p>Note that inside the <em>$PWD/docker/mock-server/iban-checker </em>folder, a file called <em>expectations.json</em> is stored containing all the needed expectations.</p><p>With this configuration, the <em>php-fpm</em> service is able to ping the <em>mock-iban-validator</em> service, and in addition to that, is able to do something like the following</p><pre>$ curl mock-iban-validator.internal:1080/api/v1/validate?iban=NL95RABO9809158653 -H &quot;Authorization: Bearer api-key&quot;</pre><p>Obtaining the expected response.</p><h3>Final Thoughts</h3><p>I hope that this article helped some of you figure out the potential of this tool for the creation of integration testing!</p><p>Thanks for reading and feel free to add comments about your experiences :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ded9ac1fe83" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/mocking-third-party-services-in-integration-testing-7ded9ac1fe83">Mocking third-party services in integration testing</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHP 8.1 — Welcome Enumeration]]></title>
            <link>https://medium.com/geekculture/php-8-1-welcome-enumeration-5b9ed1063ec0?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9ed1063ec0</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Sun, 04 Jul 2021 16:57:30 GMT</pubDate>
            <atom:updated>2021-07-05T15:21:18.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>PHP 8.1 — Welcome Enumeration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D_KY2zjzASagIWUr" /><figcaption>Photo by <a href="https://unsplash.com/@spacex?utm_source=medium&amp;utm_medium=referral">SpaceX</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is a story of a software developer, a very normal one, that used to write code in Java, and enjoyed working with enumeration to define a closed set of data.</p><p>That same developer one day started to work with PHP and realized that they were missing, which grew quite a sadness in him :(</p><p>But, finally, that developer is no longer sad since version 8.1 of PHP added enumeration to the language.</p><h3>How does it work?</h3><p>Enums are similar to classes, it defines a new type, which has a fixed, limited number of possible allowed values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*uVQJikJE7fA_m-1hlOFClw.png" /></figure><p>This declaration creates a new simple enumerated type UserState, which has four valid values: UserState::Registered, UserState::Activated, UserState::Disabled, and UserState::Blocked.</p><p>A function may be type-checked against an enumerated type, in which case only values of that type may be passed.</p><p>By default, cases are not intrinsically backed by a scalar value. That is, User::Registered is not equal to 0. Instead, each case is backed by a singleton object of that name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*rVYyE6kOjIb85iGXF15WQA.png" /></figure><p>This type of case, with no related data, is called a <em>Pure Case </em>and an Enum that contains only Pure Cases is called a <em>Pure Enum</em>.</p><p>All Cases have a read-only property, name, that is the case-sensitive name of the case itself. That is largely an implementation artifact, but may also be used for debugging purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*gNKn_pi8Zjox6V3AKQc8-g.png" /></figure><h4>Backed Enum</h4><p>By default, Enumerated Cases have no scalar equivalent. However, there are cases where an Enumerated Case needs to be able to <em>round-trip</em> to a database or similar datastore, so having a built-in scalar <em>(and thus trivially serializable)</em> equivalent defined intrinsically is useful.</p><p>To define a scalar equivalent for an Enumeration, the syntax is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*mx172S0ELR2vpHDWHmQdJQ.png" /></figure><p>A case that has a scalar equivalent is called a Backed Case, as it is “Backed” by a simpler value. An Enum that contains all Backed Cases is called a “Backed Enum.” A Backed Enum may contain only Backed Cases. A Pure Enum may contain only Pure Cases.</p><p>A Backed Enum may be backed by types of int or string, and a given enumeration supports only a single type at a time. If an enumeration is marked as having a scalar equivalent, then <strong>all cases</strong> must have a unique scalar equivalent defined explicitly.</p><p>There are no auto-generated scalar equivalents <em>(e.g., sequential integers)</em>. Value cases must be unique; two backed enum cases can’t have the same scalar equivalent.</p><p>Value Cases have an additional read-only property, value, which is the value specified in the definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*k9b8gVIDu_ALXL50jh358w.png" /></figure><p>In order to enforce the value property as read-only, a variable cannot be assigned as a reference to it.</p><p>Backed enums implement an internal BackedEnum interface, which exposes two additional methods:</p><ul><li>from(int|string): self will take a scalar and return the corresponding Enum Case. If one is not found, it will throw a ValueError. This is mainly useful in cases where the input scalar is trusted and a missing enum value should be considered an application-stopping error.</li><li>tryFrom(int|string): ?self will take a scalar and return the corresponding Enum Case. If one is not found, it will return null. This is mainly useful in cases where the input scalar is untrusted and the caller wants to implement their own error handling or default-value logic.</li></ul><h4>Methods</h4><p>Enums may contain methods and may implement interfaces. If an Enum implements an interface, then any type check for that interface will also accept all cases of that Enum.</p><p>Methods may be public, private, or protected, although in practice private and protected are equivalent as inheritance is not allowed.</p><h4>Static Methods</h4><p>Enumerations may also have static methods. The use for static methods on the enumeration itself is primarily for alternative constructors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*TD4G_5_8iFR-afAK3ApKkQ.png" /></figure><p>Static methods may be public, private, or protected, although in practice private and protected are equivalent as inheritance is not allowed.</p><h4>Value listing</h4><p>Both Pure Enums and Backed Enums implement an internal interface named UnitEnum. UnitEnum includes a static method cases()that returns a packed array of all defined Cases in the order of declaration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lvW6aJhj1YqXCDmYxP6Fw.png" /></figure><h3>Final Toughts</h3><p>I hope that this article helped some of you figuring out the potential of enumerations, I think that this has been a great addition to the language and I’m curious to see how this new construct will be used to the libraries that each one of us use each day to create great products!</p><p>Thanks for reading and feel free to add comments about your experiences :)</p><h3>Resources</h3><ul><li><a href="https://wiki.php.net/rfc/enumerations">https://wiki.php.net/rfc/enumerations</a></li><li><a href="https://github.com/php/php-src/pull/6489">https://github.com/php/php-src/pull/6489</a></li><li><a href="https://carbon.now.sh/">https://carbon.now.sh/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9ed1063ec0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/php-8-1-welcome-enumeration-5b9ed1063ec0">PHP 8.1 — Welcome Enumeration</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect Cloudflare to AWS API Gateway]]></title>
            <link>https://carocci-eugenio.medium.com/connect-cloudflare-to-aws-api-gateway-18e961a6e24f?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/18e961a6e24f</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Sat, 30 Jan 2021 12:12:38 GMT</pubDate>
            <atom:updated>2021-01-30T12:12:38.643Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How To Connect Cloudflare to AWS API Gateway</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zX08-JFQOsWqeWxw" /><figcaption>Photo by <a href="https://unsplash.com/@ilumire?utm_source=medium&amp;utm_medium=referral">Jelleke Vanooteghem</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The goal of this article is to show how to connect a domain in Cloudflare with an endpoint exposed by AWS API Gateway.</p><p>I’ll show how to connect the <em>api.example.com</em> domain to an endpoint exposed by API Gateway.</p><p>Here the steps needed to reach the goal:</p><ul><li>Generate a certificate on Cloudflare</li><li>Import the Cloudflare certificate in the AWS Certificate Manager</li><li>Create the custom domain name in AWS API Gateway</li><li>Create a record in Cloudflare to connect it to the custom domain name</li></ul><h3>Generate a certificate on Cloudflare</h3><p>Go to the Cloudflare dashboard and select the domain of interest.</p><p>Select the <em>SSL/TLS</em> icon in the menu, then the <em>Origin Server</em> menu item and at this point click on <em>Create Certificate.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yK8uVKg5N7VLmT1V0sLJhA.png" /></figure><p>In the form that will be displayed insert the hostname of interest, in this case, we want that to create a certificate for <em>api.example.com.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSDgm4fhuFXVx17ysuaa6g.png" /></figure><p>Click on <em>Next</em> and copy both the certificate and the private key.</p><blockquote>Save the private key in a secret manager like KeePass since it will be available only at this step.</blockquote><p>Once the procedure is completed you’ll find the certificate listed.</p><h3>Import the Cloudflare certificate in the AWS Certificate Manager</h3><p>Go to the AWS Certificate Manager with a user with the proper privileges.</p><p>Click on <em>Import a certificate.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Axqun5QDILYfqw0A1TmsnQ.png" /></figure><p>Fill the required data with the ones obtained from Cloudflare.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JfZ_Arj612KlgDwLbhmkwg.png" /></figure><blockquote>The <em>Certificate chain</em> can be obtained going <a href="https://support.cloudflare.com/hc/en-us/articles/115000479507#h_30cc332c-8f6e-42d8-9c59-6c1f06650639">to this Cloudflare support page</a> and looking for the <em>Cloudflare Origin CA — RSA Root.</em></blockquote><p>Once the procedure is correctly completed you’ll find the certificate listed.</p><h3>Create the custom domain name in AWS API Gateway</h3><p>Go to AWS API Gateway with a user with the proper privileges.</p><p>Go to the <em>Custom domain names</em> section and click on the <em>Create</em> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*k_nLmoiDUTvCrWNTiZWiOQ.png" /></figure><p>Fill the <em>Domain Name</em> with <em>api.example.com</em> and then in the ACM certificate select the newly created certificate.</p><p>Click on the <em>Create domain name</em> button.</p><p>At this point select the created domain and go to <em>API mappings</em> and click the <em>Configure API mappings.</em></p><p>Add a new mapping selecting the API Gateway route and stage of interest.</p><h3>Create a record in Cloudflare to connect it to the custom domain name</h3><p>Go to Cloudflare dashboard and select the domain of interest.</p><p>Select the <em>DNS </em>icon in the menu and then click on <em>Add record.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTP55ICX8bwTr2krE5DDCw.png" /></figure><p>Create the record in this way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*p4D6oz3v7LI5SamgHIGD1g.png" /></figure><p>To fill the <em>Target</em> field extract the one from <em>AWS API Gateway &gt; Custom Domain Name &gt; Endpoint configuration &gt; API Gateway domain name.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ovrg688yZw9g0Xn93zth_Q.png" /></figure><p><em>Thanks for reading and feel free to add comments about your experience :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18e961a6e24f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Become a Remarkable Developer]]></title>
            <link>https://carocci-eugenio.medium.com/become-a-remarkable-developer-2dd61905abfd?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dd61905abfd</guid>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[principles]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 10:11:27 GMT</pubDate>
            <atom:updated>2020-12-07T10:11:27.862Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iT5ROEKOY0ZEsjQK" /><figcaption>Photo by <a href="https://unsplash.com/@jasonhogan?utm_source=medium&amp;utm_medium=referral">Jason Hogan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Isn’t it true that each one of us is always looking for the secret recipe to become successful in each area of our lives? We’re constantly searching for the latest secret technique to accomplish things easier, faster and better.</p><p>We want other people to refer to us as that person who knows how to properly manage and accomplish things in life.</p><p>We want to be a remarkable person, or more specifically in this case, a <em>remarkable developer</em>.</p><p>What I’ve learned so far is: there’s simply no magic.</p><p>There are no shortcuts for becoming that kind of person, but, I’ve known many great and bad developers, and what I’ve found out is that <em>great developers</em> always follow, no matter what, the right <strong>principles</strong>.</p><blockquote>He who merely knows right principles is not equal to him who loves them.</blockquote><blockquote>Confucio</blockquote><h3>TL;DR</h3><p>If you’re always in a rush, here are the principles that you might want to adopt to become a more effective developer.</p><ul><li>YAGNI — You Aren’t Going to Need It</li><li>KISS — Keep It Simple and Stupid</li><li>DRY — Don’t Repeat Yourself</li><li>Boy Scout Rule</li></ul><h3>YAGNI — You Aren’t Gonna Need It</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*frOxdcSQAe13vI8o" /><figcaption>Photo by <a href="https://unsplash.com/@isaacbenhesed?utm_source=medium&amp;utm_medium=referral">Isaac Benhesed</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>How many times were you about to start writing a new feature or thinking about a marvellous solution to solve a problem in an extra flexible way?</p><p>I know you’ve been there.</p><p><em>We’ve all been.</em></p><p>The fact here is that a lot of times we waste our precious resources working on things that we don’t need now and never will. We should invest our time carefully in order to extract value from it.</p><p>I know that this is not simple, I know that as software developers we tend to create flexible and extensible solutions, but sometimes we must force ourselves to be pragmatic and just solve the problem.</p><h3>KISS — Keep It Simple and Stupid</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_N13M3eGFzc5MNLX" /><figcaption>Photo by <a href="https://unsplash.com/@ttrapani?utm_source=medium&amp;utm_medium=referral">Todd Trapani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For each problem, there is a variety of possible solutions spanning from the easiest to the toughest one.</p><p>The idea behind this principle is that you should follow the easiest possible path in order to solve problems. This isn’t always possible but, one thing that I truly believe in is that when you’re facing a problem you should spend more time reflecting on it then actually solving it.</p><blockquote>If I had an hour to solve problem, I’d spend 55 minutes thinking about the problem and 5 minutes thinking about solutions.</blockquote><blockquote>Albert Einstein</blockquote><p>Once you fully understand a problem there are higher chances that a simple, yet effective solution comes out.</p><h3>DRY — Don’t Repeat Yourself</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KwqZ_k-TVSwxZv0o" /><figcaption>Photo by <a href="https://unsplash.com/@mitchel3uo?utm_source=medium&amp;utm_medium=referral">Mitchell Luo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Imagine this scenario.</p><p>Your beloved spouse tells you to sort out your socks by colour because she’s an aesthete and you love her for that ❤. Luckily, you&#39;ll easily accomplish that task because all your socks are in one place.</p><p>Now, think at software, wouldn’t it be great if someone asked you to change a particular behaviour you’d know exactly where to go to accomplish that request?</p><p>This is the main essence of the DRY principle, <em>Don’t Repeat Yourself.</em> This means that you should assign at all the components of the application a very specific responsibility.</p><p>There should never be a case where the same knowledge or responsibility is assigned to two different components of the application.</p><p>That would simply be the perfect recipe for a disaster :)</p><h3>Boy Scout rule</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RAuyvpzWxMbxtHOp" /><figcaption>Photo by <a href="https://unsplash.com/@kylejglenn?utm_source=medium&amp;utm_medium=referral">Kyle Glenn</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Leave your code better than you found it.</blockquote><p>We have to take care of the codebase, we should improve it on a daily basis and we must accept that it’s a never-ending task.</p><p>If we find a <em>broken window</em> in the codebase, we should not ignore it, we should take care of it. I know that not everything can be fixed, but anything can be improved.</p><p>Here some things that we might do:</p><ul><li>Share what has been found with the team.</li><li>Open an issue on the project’s issue tracker.</li><li>Fix it :)</li></ul><p>The idea is to accept to spend some additional time now in order to have great returns in the long run.</p><h3>Final thoughts</h3><p>During my years of development, I’ve learnt a fundamental thing:</p><blockquote>Most of the times we know what we should do and we must fight the lazy part of us that is an obstacle to achieve great results.</blockquote><p>We should print a card and attach it near to our screen with something like <em>“Kill the lazy you”.</em></p><p>If we internalize these principles then there are no doubts about it, we will become truly <em>remarkable developers</em>.</p><p>Thanks for reading and feel free to add comments about your experiences :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dd61905abfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What language should I learn next as a programmer?]]></title>
            <link>https://carocci-eugenio.medium.com/what-language-should-i-learn-next-as-a-programmer-b738f9378942?source=rss-77b5e895a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b738f9378942</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Eugenio Carocci]]></dc:creator>
            <pubDate>Wed, 06 Mar 2019 20:56:34 GMT</pubDate>
            <atom:updated>2019-03-06T20:56:34.002Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xAKA1mZB9TpcUWuz" /><figcaption>Photo by <a href="https://unsplash.com/@hiteshchoudhary?utm_source=medium&amp;utm_medium=referral">Hitesh Choudhary</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now more than ever there’s a constant and fast evolution in the technological environment.</p><p>Especially in the <em>programming language field</em> and all that whirling around it.</p><p>We can all agree saying that <strong>time is limited </strong>and each one of us want to <strong>optimise our resources</strong>. It’s pretty clear then why deciding what to study next is fundamental.</p><blockquote><strong>“It is in your moments of decision that your destiny is shaped” — <em>Tony Robbins</em></strong></blockquote><p>Before the search is being initiated we should be honest with ourselves and define what we want to achieve. For instance:</p><ul><li>Finding a brand new shining job?</li><li>Experimenting something in a new project?</li><li>Learning a new language for our personal growth?</li></ul><h3>Finding a brand new shining job?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s3Se-vSW5Ur57Sh8" /><figcaption>Photo by <a href="https://unsplash.com/@punttim?utm_source=medium&amp;utm_medium=referral">Tim Gouw</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For those who have this kind of necessity the best thing to do is to start looking around through the major platforms on the market like: <a href="https://linkedin.com/"><em>LinkedIn</em></a>, <a href="https://stackoverflow.com/jobs"><em>StackOverflow</em></a>, <a href="https://it.indeed.com/"><em>Indeed</em></a>, <a href="https://www.glassdoor.com/"><em>Glassdor</em></a> and many more.</p><p>From my personal experience, I can assure that through these tools it is easy to find which are the most common languages and technologies companies are looking for.</p><p>Thereafter understanding where to put our best effort to increase our chances to <strong>get a new satisfactory job</strong> should be <em>easy-peasy</em>.</p><p>Usually, the best thing to do is to move towards languages like: <em>Javascript, Java, Python, C#, PHP, C++</em>. The ones listed are <em>general-purpose</em> and for this reason they have a variety of application fields, from mobile development to the creation of enterprise backend services.</p><p>A special mention needs to be done for <em>Python</em>. As reported in <a href="https://stackoverflow.blog/2017/09/06/incredible-growth-python/">this article</a>, it has proved to be the language with the fastest growth observed during last years.</p><p>Python is also widely used in the <em>machine learning</em> development.</p><h3>Experimenting something in a new project?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i14JTvmTkhPUzd2O" /><figcaption>Photo by <a href="https://unsplash.com/@alvaroreyes?utm_source=medium&amp;utm_medium=referral">Alvaro Reyes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this particular area, the guiding element is related to what we either <strong>have</strong> <strong>or want to create</strong>.</p><p>Each project has a lot of constraints that should be taken into account when the adoption of the language is made.</p><p>There can be plenty of applications with completely different needs, ranging from the creation of a <em>machine learning model</em> to the development of <em>REST services.</em></p><p>In this case is quite difficult to suggest specific programming languages due to the different nature of the problem.</p><p>Deciding the language to use is a complete <strong>leap of faith</strong> that can significantly direct us towards a <em>smarter</em> future.</p><p>Even if we realise that we haven’t chosen the best way to solve our problems, we will have considerably enhanced our <em>decision-making skill</em> for future times.</p><blockquote><strong>Failure is simply the opportunity to begin again, this time more intelligently — Henry Ford</strong></blockquote><h3>Learning a new language for our personal growth?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CTNROSosi7ToFcJJ" /><figcaption>Photo by <a href="https://unsplash.com/@imgix?utm_source=medium&amp;utm_medium=referral">imgix</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the place where we can play around and just <strong>listen to ourselves</strong>.</p><p>What is that thing that would make us extremely happy and satisfied?</p><p>From my perspective approaching a brand new language is always exciting! It’s a way to <strong>challenge ourselves</strong> with unknown things proving which are our strengths and our weaknesses.</p><p>It’s not as easy as <em>snapping fingers</em> but the struggle is worth to become not only better software developers but also better humans.</p><p>If I decided to start right now something new I would probably give <a href="https://www.r-project.org/about.html"><em>R</em></a> a try since it is widely used in the <em>machine learning</em> field.</p><p>Another alternative might be either <a href="https://www.rust-lang.org/"><em>Rust</em></a> or <a href="https://kotlinlang.org/">Kotlin</a> languages that, from <a href="https://insights.stackoverflow.com/survey/2018/">StackOverflow’s 2018 survey</a> conducted on 100.000 developers around the world, turned out to be the most desired. Let’s see something more about the these new <strong>cool languages</strong>.</p><p>So, why is <strong>Rust </strong>considered<strong> </strong>the most desired language from this vast audience? Hundreds of companies around the world are using Rust in production today for fast, low-resource, cross-platform solutions.</p><p>Softwares we know and love, like <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.dropbox.com/">Dropbox</a> and <a href="https://www.cloudflare.com/">Cloudfare</a> use Rust. From <strong>startups</strong> to <strong>large corporations</strong>, from embedded devices to scalable web services, Rust is a great fit.</p><blockquote>“Rust is one of the few languages that really gives you a large amount of confidence that your parallel and concurrent code is anywhere near correct” —Chaterine West, Technical Lead at Chucklefish</blockquote><p><strong>Kotlin</strong> is widely used by developers, especially to make Android apps but also to create plenty of interesting things.</p><p>A lot of big companies such as <a href="https://www.pinterest.it/">Pinterest</a>, <a href="https://gradle.org/">Gradle</a>, <a href="https://evernote.com/">Evernote</a>, <a href="https://www.uber.com/">Uber</a> use it.</p><p>Created by <a href="https://www.jetbrains.com/">JetBrains</a> and sponsored by the latter and, among the others, one of the <a href="https://en.wikipedia.org/wiki/Big_Four_tech_companies">Big Four</a>: <strong>Google</strong>. If you are an experienced Java developer then you need to take a look at it.</p><p><em>So, what about you? Which language are you going to learn next? I’d really appreciate feedbacks from all of you, so don’t be shy and leave comments! :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b738f9378942" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>