<?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 Ibrahim Alraigi on Medium]]></title>
        <description><![CDATA[Stories by Ibrahim Alraigi on Medium]]></description>
        <link>https://medium.com/@ibra7am?source=rss-8382e033273f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eiI3uwZWe8z97-2fXFNQ-Q.jpeg</url>
            <title>Stories by Ibrahim Alraigi on Medium</title>
            <link>https://medium.com/@ibra7am?source=rss-8382e033273f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 07:15:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ibra7am/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[Simplifying Dealing with Legacy Systems]]></title>
            <link>https://medium.com/@ibra7am/simplifying-dealing-with-legacy-systems-ed29758f69f7?source=rss-8382e033273f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed29758f69f7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ibrahim Alraigi]]></dc:creator>
            <pubDate>Tue, 16 Nov 2021 23:35:54 GMT</pubDate>
            <atom:updated>2021-12-07T20:52:56.321Z</atom:updated>
            <content:encoded><![CDATA[<h4>SOFTWARE ARCHITECTURE</h4><h4>Great Architecture that Ease Dealing with Legacy Systems</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*onaLMfHgDKREW5vf" /></figure><p>The figure above illustrates how multiple systems rely on a legacy system, and in many cases, a legacy system that is hard to get rid of for several reasons, such as a legacy system that is being the source of truth and control, or when other systems that you don’t have control over depends on it, … etc.</p><p>In this article, I will discuss a great way of simplifying dealing with a legacy system that my team and I recently come to realize that all of our services are using that system in a repetitive way, and we came up with a great architecture that ultimately saved us time and effort (and potentially money) for maintaining those services and building new ones.</p><p>You may have already faced a similar situation, if not, this may enlighten you and give you some inspiration regardless.</p><h3>Explanation of the Architecture — Before the Improvement</h3><p>The issue was when multiple services dealt with the legacy system with no common logic or layer in between (refer to the figure above), which caused the following issues:</p><ul><li>Implementing the shared business logic by each service, scattering it all over, which makes the services code base larger and the legacy system’s business logic much harder to maintain.</li><li>Implementing the legacy system’s business logic in a very tailored way, that only serves that service, instead of implementing it in a general way that fits all services, in a more readable, maintainable, and scalable way, resulting in duplicate and redundant code;</li><li>Wasting time and effort, each developer had to first go with the hustle of understanding the legacy system and then implement the service need.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KnpK7HwmMMkfbKF2" /></figure><h3>Explanation of the Architecture — After the Improvement</h3><p>The figure above illustrates the main concept of the architecture and its components, in the following way:</p><h3>Components</h3><h4>— Complex Object Builder Package:</h4><p>This is mainly a helper package to facilitate making a complex object (i.e. the input) to be sent to the <strong>legacy system abstraction layer</strong>, (I wrote two articles that go in-depth on how to make a complex object builder: <a href="https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-319f6e10e41e">Part 1</a>, <a href="https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-part-2-df1b5cda5bad">Part 2</a>).</p><h4>— Legacy System Proxy Package</h4><p>This is also another package, it simply contains all the endpoints that the <strong>legacy system abstraction layer </strong>has, so that no need to re-write HTTP requests in all services and maintain them as they change in the <strong>legacy system abstraction layer.</strong></p><h4><strong>— Legacy System Abstraction Layer</strong></h4><p>This is the big one, it’s an internal microservice that is much more generic and represents the shared business logic of the legacy system which was scattered all over the services, and used by all other services that need to communicate with the <strong>legacy system</strong>.</p><p>So now, no service will directly communicate with the <strong>legacy system</strong>, they will go through this layer first.</p><h3>Cycle</h3><ol><li>A<strong> service</strong> will use the c<strong>omplex object builder package</strong> to construct an object to be sent to the <strong>legacy system abstraction layer</strong>, the benefits here are that this input has to follow the legacy system way so that it could be used (e.g. validating <strong>legacy system</strong> properties), as well as the other benefits that are mentioned in <a href="https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-319f6e10e41e">Builder Design Pattern Article - Part 1</a>.</li><li>Then, this object is sent to the <strong>legacy system abstraction layer</strong> via the <strong>legacy system proxy package.</strong></li><li>After that, the <strong>legacy system abstraction layer</strong> will receive the object, does the legacy system business logic needed (e.g. updating its database), and returns the response that the service needs.</li></ol><h3>Wrapping up …</h3><p>Dealing with legacy systems may not be too intuitive and may cause some issues, but with a good architecture, you can save time, effort, and potentially money, I’m only discussing the main concept with high-level details, the actual implementation took months of work to be achieved, and it was worth it for a number of benefits, such as:</p><ul><li>Dealing with the <strong>legacy system</strong> is much easier now, as services owners almost don’t need to understand how the legacy system works, instead, they only have to understand one package that is much more intuitive (thanks to cascading methods and a ton of input validation, discussed in-details here: <a href="https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-part-2-df1b5cda5bad">Builder Design Pattern - Part 2</a>).</li><li>Changing the <strong>legacy system</strong> business logic and rules no longer requires making changes in many services, it’s managed from a single point of control now, which is in the <strong>legacy system abstraction layer</strong>.</li><li>Maintaining the codebase for those services now is easier, as they are smaller and not decoupled from the <strong>legacy system</strong>, they are only linked over a regular HTTP proxy, as if it was a third-party API.</li><li>Replacing or even removing the <strong>legacy system</strong> is easily doable when needed, as all of its logic is managed in one place now.</li></ul><p>I hope you enjoyed reading this article and find it helpful or inspiring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed29758f69f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with Complex Objects with Builder Design Pattern — Part 2]]></title>
            <link>https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-part-2-df1b5cda5bad?source=rss-8382e033273f------2</link>
            <guid isPermaLink="false">https://medium.com/p/df1b5cda5bad</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Ibrahim Alraigi]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 19:12:53 GMT</pubDate>
            <atom:updated>2021-09-07T19:12:53.109Z</atom:updated>
            <content:encoded><![CDATA[<h4>SOFTWARE DESIGN PATTERNS</h4><h3>Dealing with Complex Objects with Builder Design Pattern — Part 2</h3><h4>Ensuring consistent object construction with input validation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0kKZrf05cJZzWVHDr6aZw.png" /></figure><p>In <a href="https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-319f6e10e41e">Part 1</a>, we discussed how to construct a complex object with many properties and nested objects multiple times in a readable way using the builder design pattern, <strong>in this article</strong>, we will go through the other three points, that are:</p><ul><li>Ensuring consistent object construction and prevent manual construction.</li><li>Allowing some optional properties and enforcing some others based on criteria.</li><li>Having different validation on the object properties based on criteria.</li></ul><p>To achieve those goals, we need to have a mechanism to distinguish between different flows based on each condition of the criteria, let’s call this mechanism <strong>Provider</strong>, which basically just specifies a special build logic based on the criteria, it will be clearer with examples below.</p><h3>BuilderProvider — special build logic</h3><p>So ultimately, we want to reuse the same builder, while having a different build logic based on the supplied input, lets assume that our criteria will be the order type, which is OrderDetails.Type, and for each order type, we will have a different <strong>Provider</strong>.</p><p>Now to use a specific <em>provider</em>, our call to theBuild method will be altered in the following way:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f0f9c141c8538bf568b6ac226205942/href">https://medium.com/media/9f0f9c141c8538bf568b6ac226205942/href</a></iframe><p>We’re just passing a new DeliveryBuilderProvider instance to the Build method, where the Build method inside OrderBuilder class now is implemented in the following way:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abf68423714b3f0da2581271049b2207/href">https://medium.com/media/abf68423714b3f0da2581271049b2207/href</a></iframe><p>So before, we used to just return the object after construction as is, but now, we delegate that to the <strong>Provider</strong>, so that we could have logic and validation before returning it; for the interface IBuilderProvider and DeliveryBuilderProvider implementation, it would be as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c832b0456d8888ffe74bd959ab5f75d/href">https://medium.com/media/1c832b0456d8888ffe74bd959ab5f75d/href</a></iframe><p>What happens here simply is:</p><ol><li>Doing the <strong>Provider</strong>’s special logic, in this case, setting some default properties.</li><li>Doing <strong>Provider</strong>’s special validation, using <a href="https://fluentvalidation.net/">FluentValidation</a> library.</li><li>Returning our order object ready to be used.</li></ol><h3>Adding Validation to Providers</h3><p>For validations, there are <strong>per-provider</strong> validators, and some smaller <strong>common</strong> validators that are used internally in those per-provider validators, as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec6894f73c62e392b9bcbf6ed28afd08/href">https://medium.com/media/ec6894f73c62e392b9bcbf6ed28afd08/href</a></iframe><p>If you’re familiar with <em>FluentValidation</em> this might be clear for you already, in DeliveryBuilderValidator we have some common and per-provider validators, the common ones are used in multiple per-provider validators for reusability, while the per-provider validator can still add some specific extra validations on top of those common ones.</p><h3>What you have learned so far — finishing up</h3><p>So by now, you should have a clear understanding of why and how Builder Design Pattern is implemented, as well as ways to achieve some benefits of using it with some extra flavors, consistent and readable complex object construction, and input validation.</p><p>You could definitely go beyond that with some more custom implementations, all of this was actually used in already-in-production solutions, the actual implementation was masked for confidentiality, but the concepts are the same.</p><p>In a future article, I will show how this was used as a package within internal microservices to facilitate communication between them and another system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df1b5cda5bad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with Complex Objects with Builder Design Pattern]]></title>
            <link>https://medium.com/@ibra7am/dealing-with-complex-objects-with-builder-design-pattern-319f6e10e41e?source=rss-8382e033273f------2</link>
            <guid isPermaLink="false">https://medium.com/p/319f6e10e41e</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ibrahim Alraigi]]></dc:creator>
            <pubDate>Wed, 11 Aug 2021 19:47:17 GMT</pubDate>
            <atom:updated>2021-08-11T19:47:17.912Z</atom:updated>
            <content:encoded><![CDATA[<h4>SOFTWARE DESIGN PATTERNS</h4><h3>Dealing with Complex Objects with Builder Design Pattern — Part 1</h3><h4>FluentBuilder with code examples — in c#</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0kKZrf05cJZzWVHDr6aZw.png" /></figure><p>Sometimes, we face situations where we have a really complex object (i.e. has a lot of properties and nested objects) to deal with, and breaking it down into multiple smaller objects isn’t an option, like in the case of when a client needs to send an object to a server.</p><h3>THE PROBLEM</h3><p>For example, consider that we have a complex object called Order that has optional properties and nested objects, we might end up with something similar to this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f814e0a35da95b91139dd3e3e5ee240/href">https://medium.com/media/6f814e0a35da95b91139dd3e3e5ee240/href</a></iframe><p>Which will lead to multiple constructors overloads, that are not so readable when used.</p><p>In this article, I will discuss a situation where I had to construct a complex object with multiple representations that needs to be sent from a server to another internal one, to be inserted in multiple database tables in a very specific way, and a very specific input validation before generating the object, and with what’s known as the “<strong>Builder Design Pattern</strong>” and some other flavors, I was able to achieve multiple objectives:</p><ul><li>Constructing a complex object with many properties and nested objects multiple times in a readable way.</li><li>Ensuring consistent object construction and prevent manual construction.</li><li>Allowing some optional properties and enforcing some others based on criteria.</li><li>Having different validation on the object properties based on criteria.</li></ul><p><em>So you can consider those bullet points as signs where the builder design pattern might be helpful for you.</em></p><h3>A POTENTIAL SOLUTION — going in-depth with code examples:</h3><p>Now, let’s discuss each benefit mentioned above with a code example.</p><h4><strong>– Constructing a complex object with many properties multiple times in a readable way.</strong></h4><p>The most common way of implementing builder design pattern is as cascading methods, where you construct the complex object as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169667d40af239fee3527281fc2d7a2f/href">https://medium.com/media/169667d40af239fee3527281fc2d7a2f/href</a></iframe><p>where each nested object is created as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d60ad25ed18b87dff1ad586c58dd0d67/href">https://medium.com/media/d60ad25ed18b87dff1ad586c58dd0d67/href</a></iframe><p>the implementation of the OrderBuilder and its cascading methods that construct our order object would be as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1849aab196128829b460e9cb7ca78bcf/href">https://medium.com/media/1849aab196128829b460e9cb7ca78bcf/href</a></iframe><p><strong>Key takeaways here:</strong></p><ul><li>The Order object is private here, and only accessible within by the builder and used inside the cascading methods.</li><li>Cascading methods pretty much append the nested object to the Order object and return itself (of type IOrderBuilder) to allow for another method to be called.</li><li>Cascading methods could do some other behavior instead, like having a default implementation instead of relying on its input.</li><li>The Build method returns our complex object (i.e. Order) and this case just returns the object and is meant to be called at the end of the chain.</li></ul><p>Note: I initialize the instance of Order the in the builder constructor here as I’m depending on dependency injection for creating a new instance of the builder each time I’m constructing a new object, <strong>if you intend to reuse the same builder for constructing multiple objects</strong>, you have two choices:</p><ul><li><strong>Option #1:</strong> you can make a cascading function that makes a new object and call it at the beginning of your call chain when constructing a new object, or</li><li><strong>Option #2: </strong>you can make an internal function that resets (i.e. create a new object) at the end of your build function.</li></ul><p>This is how these two options may look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20933afad2e42f1d97275f0b07c6c13b/href">https://medium.com/media/20933afad2e42f1d97275f0b07c6c13b/href</a></iframe><p><em>Note: in </em><strong><em>part 2</em></strong><em> I will show how to use different providers for the same builder to have some special build logic based on criteria, like special validation based on </em><em>OrderType .</em></p><h3>What we have learned so far</h3><p>So in this article, we went through the first benefit, namely:</p><ul><li>Constructing a complex object with many properties and nested objects multiple times in a readable way.</li></ul><p><strong>and for the other benefits mentioned above, which are:</strong></p><ul><li>Ensuring consistent object construction and prevent manual construction.</li><li>Allowing some optional properties and enforcing some others based on criteria.</li><li>Having different validation on the object properties based on criteria.</li></ul><p>They will be illustrated with code examples in <strong>part 2, </strong>I will show you how to use different providers for the same builder to have some special build logic based on criteria, like special validation based on OrderType.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=319f6e10e41e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>