<?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 Masudul Alam on Medium]]></title>
        <description><![CDATA[Stories by Masudul Alam on Medium]]></description>
        <link>https://medium.com/@malam172034?source=rss-36675a3844b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DY-5SIk9P_VxeiYf.jpg</url>
            <title>Stories by Masudul Alam on Medium</title>
            <link>https://medium.com/@malam172034?source=rss-36675a3844b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:00:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@malam172034/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[How to Manage Spring Boot Application Properties Safely and Effectively]]></title>
            <link>https://medium.com/@malam172034/how-to-manage-spring-boot-application-properties-safely-and-effectively-3d0ace1c15a0?source=rss-36675a3844b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d0ace1c15a0</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[configuration-management]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Masudul Alam]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 08:06:18 GMT</pubDate>
            <atom:updated>2025-10-07T08:11:49.120Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Boot makes it easy to externalize configuration with application.properties or application.yml. But as your application grows, using @Value annotations everywhere becomes cumbersome and error-prone.</p><p>Use <strong>@ConfigurationProperties</strong> , a powerful, type-safe way to map configuration values into Java objects. In this post, we’ll explore how to use @ConfigurationProperties with <strong>Java records</strong> (Java 17+) for clean and immutable configuration.</p><p>Why<strong> @ConfigurationProperties?</strong></p><ul><li><strong>Type-safe</strong>: Spring binds properties directly to fields, catching type mismatches at startup.</li><li><strong>Hierarchical mapping</strong>: Supports nested objects for structured properties.</li><li><strong>Validation support</strong>: Annotate fields with @NotBlank, @Min, @Max, etc., to validate configuration.</li><li><strong>Centralized</strong>: Keeps all configuration in one place instead of scattered @Value annotations.</li></ul><p><strong>Example Scenario: Payment Integration</strong></p><p>Suppose we are integrating with a payment system, and we have the following properties in application.properties:</p><pre>payment.keys.admin-key=super-secret-key<br>payment.client.store-id=12345<br>payment.client.password=abcd1234<br>payment.client.base-url=https://api.payment.com<br>payment.qr.base-url=https://api.payment.com/qr<br>payment.user-info.base-url=https://api.payment.com/user<br>payment.application.base-url=https://api.payment.com/app</pre><p><strong>Step 1: Create a Configuration Properties Record</strong></p><pre>package com.example.config;<br><br>import jakarta.validation.constraints.NotBlank;<br>import org.springframework.boot.context.properties.ConfigurationProperties;<br>import org.springframework.validation.annotation.Validated;<br><br>@ConfigurationProperties(prefix = &quot;payment&quot;)<br>@Validated<br>public record PaymentProperties(<br>        Keys keys,<br>        Client client,<br>        Qr qr,<br>        UserInfo userInfo,<br>        Application application<br>) {<br><br>    public record Keys(<br>            @NotBlank String adminKey<br>    ) {}<br><br>    public record Client(<br>            @NotBlank String storeId,<br>            @NotBlank String password,<br>            @NotBlank String baseUrl<br>    ) {}<br><br>    public record Qr(<br>            @NotBlank String baseUrl<br>    ) {}<br><br>    public record UserInfo(<br>            @NotBlank String baseUrl<br>    ) {}<br><br>    public record Application(<br>            @NotBlank String baseUrl<br>    ) {}<br>}</pre><p><strong>Key Points</strong></p><ol><li>@ConfigurationProperties(prefix = “payment”) tells Spring Boot to bind all payment.* properties.</li><li>@Validated ensures required fields are not blank (@NotBlank).</li></ol><p>3. Nested records (Keys, Client, Qr, etc.) represent <strong>hierarchical properties</strong>, making access type-safe.</p><p>4. You do not have to worry about the casing in properties file, you can keep it in camel case, kebab case, snake case. Spring boot got your back 🦾</p><p><strong>Step 2: Enable Configuration Properties</strong></p><p>In your Spring Boot application:</p><pre>package com.example;<br><br>import com.example.config.PaymentProperties;<br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.boot.context.properties.EnableConfigurationProperties;<br><br>@SpringBootApplication<br>@EnableConfigurationProperties(PaymentProperties.class)<br>public class PaymentApplication {<br><br>    public static void main(String[] args) {<br>        SpringApplication.run(PaymentApplication.class, args);<br>    }<br>}</pre><p>This ensures Spring Boot registers PaymentProperties as a bean, ready for injection.</p><p><strong>Usage example -1 :</strong></p><p>Now we can inject PaymentProperties wherever we need it. For example, in a security filter:</p><pre>package com.example.security;<br><br>import com.example.config.PaymentProperties;<br>import org.springframework.stereotype.Component;<br>import org.springframework.web.filter.OncePerRequestFilter;<br><br>@Component<br>public class ApiKeyAuthFilter extends OncePerRequestFilter {<br><br>    private final PaymentProperties paymentProperties;<br><br>    public ApiKeyAuthFilter(PaymentProperties paymentProperties) {<br>        this.paymentProperties = paymentProperties;<br>    }<br><br>    @Override<br>    protected void doFilterInternal(HttpServletRequest request,<br>                                    HttpServletResponse response,<br>                                    FilterChain filterChain) {<br>        String adminKey = paymentProperties.keys().adminKey();<br>        // use adminKey for authentication<br>    }<br>}</pre><p><strong>Usage example -2 :</strong></p><p>You can also use it in a WebClient configuration:</p><pre>@Bean<br>public WebClient paymentWebClient(PaymentProperties props) {<br>    return WebClient.builder()<br>            .baseUrl(props.client().baseUrl())<br>            .build();<br>}</pre><p><strong>Usage example -3 :</strong></p><pre>package com.example.service;<br><br>import com.example.config.PaymentProperties;<br>import org.springframework.stereotype.Service;<br><br>@Service<br>public class PaymentService {<br><br>    private final PaymentProperties paymentProperties;<br><br>    public PaymentService(PaymentProperties paymentProperties) {<br>        this.paymentProperties = paymentProperties;<br>    }<br><br>    public void printInfo() {<br>        System.out.println(&quot;Admin Key: &quot; + paymentProperties.keys().adminKey());<br>        System.out.println(&quot;Client Store ID: &quot; + paymentProperties.client().storeId());<br>        System.out.println(&quot;Client Base URL: &quot; + paymentProperties.client().baseUrl());<br>        System.out.println(&quot;QR Base URL: &quot; + paymentProperties.qr().baseUrl());<br>    }<br>}</pre><p><strong>Advantages of This Approach</strong></p><ul><li>You know if you are using @Value annotation 😁</li></ul><p><strong>Conclusion</strong></p><p>Using @ConfigurationProperties with Java records is an <strong>industry-standard approach</strong> for managing Spring Boot configurations. It removes boilerplate, reduces errors, and keeps your configuration type-safe and validated.</p><p>Whether you’re building internal services, API clients, or security filters, this pattern keeps your code clean and maintainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d0ace1c15a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring HTTP Interface Clients: Consuming HTTP services in Spring Boot]]></title>
            <link>https://medium.com/@malam172034/spring-http-interface-clients-consuming-http-services-in-spring-boot-2ab7848ceeaf?source=rss-36675a3844b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ab7848ceeaf</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[http-client]]></category>
            <dc:creator><![CDATA[Masudul Alam]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 19:33:05 GMT</pubDate>
            <atom:updated>2024-06-19T05:47:59.772Z</atom:updated>
            <content:encoded><![CDATA[<p>When calling a remote service we often use Webclient these days. At least before HTTP Interface came up. In all new HTTP Interface Client we will use webClient but in a different way which reduces all the complexity we face during a remote service call.</p><p>In my example I will use two services, from the first service I will call the second service using HTTP Interface Client.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40469b9fb321cd2166a901d9f0ba2920/href">https://medium.com/media/40469b9fb321cd2166a901d9f0ba2920/href</a></iframe><p>In above code it shows a product controller belongs to service-2 which I will be calling from service-1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc534ebcd189458b418c662c1df97203/href">https://medium.com/media/dc534ebcd189458b418c662c1df97203/href</a></iframe><p>Here, I have created a interface client in service-1 to call Product Controller from service-2. Wait! Where are the other stuffs like base url and how do i handle errors?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/139c9cebcbef3c74cca538350850334c/href">https://medium.com/media/139c9cebcbef3c74cca538350850334c/href</a></iframe><p>The factory object is used to create a proxy for the Client class. This proxy will use the webClient object to communicate with the service-2. And The createClient method is used to create a client proxy. The client proxy will be used to make HTTP requests to the remote service.<br>(Skip this part if you feel overwhelmed after reading this)</p><p>As I have a contract with the service-2 as every 4xx errors comes in a format I will throw this from here as a string and catch it in the exception handler like below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1bc2b3af363a9b0b3a3fcc4771263bf/href">https://medium.com/media/f1bc2b3af363a9b0b3a3fcc4771263bf/href</a></iframe><p>Okay let’s dive into the actual call.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e690f57036bed0ccbcc46f88898faf4/href">https://medium.com/media/3e690f57036bed0ccbcc46f88898faf4/href</a></iframe><p>Here , I have created a REST controller in service-1 to test calling service-2, I have injected the Client I built earlier and used it to call the service-2, that’s it. (Please do not hang me up for calling service-2 from service-1 controller, I am just being lazy. It gets aligned with the purpose anyways.)</p><p>Okay, let’s <strong>convince</strong> you why you should use it.</p><p>1. If you have multiple remote calls to a service this is the exactly what you should definitely follow, you do not need to create / construct that boring webclient every time.</p><p>2. Errors handling gets taken care of for a particular service calls in a place, you just write once how it should be treated.</p><p>3. You do not have to remember and google how you should send form data, how you should send x-www-form-urlencoded data, how you should send json data. Now, If you can write a controller, you can write your remote calls too. You just need to define the contentType, rest are taken care of by the proxy.</p><p>4. Last but not the least, your code is not messy anymore.</p><p><strong>Reference</strong> : <a href="https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface">https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ab7848ceeaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototype Pattern In Java]]></title>
            <link>https://medium.com/@malam172034/prototype-pattern-in-java-7609793863b3?source=rss-36675a3844b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7609793863b3</guid>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[software-design-patterns]]></category>
            <category><![CDATA[prototype-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Masudul Alam]]></dc:creator>
            <pubDate>Fri, 29 Oct 2021 22:02:39 GMT</pubDate>
            <atom:updated>2021-10-29T22:02:39.420Z</atom:updated>
            <content:encoded><![CDATA[<p>Prototype pattern is one of the creational design patterns which is also associated with object creation.</p><p>Imagine a situation where you are a bank’s employee, a new customer walks in, sits in front of you and asks for the interest rate of your Bank according to the type of the bank accounts.</p><p>You can’t remember the details at this moment but you know your bank uses a software which provides such information about the interest rate depending on the account types. You asked for a few moments from your customer and logged into your software using your authorized credentials. You clicked and saw the following information.</p><p><strong>Account type: Current Account</strong></p><p><strong>Interest rate: 0.0%</strong></p><p><strong>Account type: Savings account</strong></p><p><strong>Interest rate: 5.5%</strong></p><p>You checked and said our interest rate for the current account is 0% and for the savings account it’s 5.5%. Customer received that information, said he wants to open a savings account and you instruct him to go to another counter to open an account.</p><p>The bank’s employee who used that software to retrieve the information, what should be the design of it?</p><p>First of all, look at the following question.</p><p>1.Does a current account vary a lot more than a savings account except the account type and rate only?</p><p>The answer is <strong>NO</strong>, it’s all just of type <strong>Account</strong> and the <strong>Current account</strong> and <strong>Savings account</strong> (Subclasses) changes the implementation (sets Account type and Rate).</p><p>So, we will modify our<strong> Account</strong> (base class) according to the implementation of <strong>Current Account</strong> and <strong>Savings Account</strong> by cloning <strong>Account</strong>. No direct object creation of subclasses using <strong>new</strong> keyword rather we will use <strong>clone</strong>. To do this we will have to implement <strong>Cloneable</strong> interface in our base class.</p><p>Let’s see how it looks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5769dd16fa668c704da88fedba20466c/href">https://medium.com/media/5769dd16fa668c704da88fedba20466c/href</a></iframe><p>Let’s look at our base classes now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/657e28cafde8f27039b7d02977202da4/href">https://medium.com/media/657e28cafde8f27039b7d02977202da4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14bd20cb999ca2831f57a74dd648d836/href">https://medium.com/media/14bd20cb999ca2831f57a74dd648d836/href</a></iframe><p>Here, in both cases we have set the type of the account and interest rate</p><p>Now, we will have a class dedicated to these cloning and object creation stuffs named <strong>AccountCache</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88b5bdad3cfcad1d87cf73c1282099c3/href">https://medium.com/media/88b5bdad3cfcad1d87cf73c1282099c3/href</a></iframe><p>Here we will maintain a <strong>hashtable</strong> to put our concrete class cloned objects against a value so that our codes are decoupled and open for extension if needed without breaking existing codebase.</p><p>Here, static method <strong>loadCache()</strong> does all the cloning and putting cloned concrete objects into hashmap.</p><p>When we call <strong>getAccount()</strong> with accountId parameter the getAccount() method will retrieve the object from the <strong>accountMap</strong> and return its cloned version.</p><p>Now look at our client side of the code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6884cc87344059eebe3dacd56635513/href">https://medium.com/media/d6884cc87344059eebe3dacd56635513/href</a></iframe><p>You can see First of all we called<strong> loadCache()</strong> method of <strong>AccountCache</strong> to instantiate and put all the values and objects in place. After that we can see we wanted to retrieve the data of id “1” and then of id “2”.</p><p>If you look closely you can see that the client side doesn’t know what type of objects he is going to get in return. Client just knows how to use <strong>AccountCache</strong> and it returns an object / objects. So.the code successfully <em>encapsulates</em> the implementation details of the solution.</p><p>Now, look at the output of the solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*43nLHFfDT_UWBKav6-yhjw.png" /></figure><p>You can find the code of this example in <a href="https://github.com/Masud034/Design-Patterns/tree/main/Prototype-Pattern">https://github.com/Masud034/Design-Patterns/tree/main/Prototype-Pattern</a> here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7609793863b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Factory Method Pattern In Java]]></title>
            <link>https://medium.com/@malam172034/factory-method-pattern-in-java-ee14d2a25700?source=rss-36675a3844b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee14d2a25700</guid>
            <category><![CDATA[factory-method-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Masudul Alam]]></dc:creator>
            <pubDate>Mon, 18 Oct 2021 08:09:23 GMT</pubDate>
            <atom:updated>2021-10-18T12:52:42.385Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Creational design patterns</strong> are design patterns that deal with object creation mechanisms. <strong>Factory method pattern</strong> is one of the creational design patterns.</p><p>It is mostly used when our client side (could be a frontend code or other part of the application) should not care about the implementations of subclasses. All it wants is an object of subclasses. It also helps decoupling the codes from other parts of the code which is very effective in terms of maintenance, reusability and gives us flexibility integrating new behavior.</p><p>It hides the implementation logic of related subclasses using <strong>Factory</strong>. Factory is the place where our <strong>concrete class</strong> objects are actually created inside a method and it is completely <strong>encapsulated</strong> in that place. The client is not aware of the different implementations of the <strong>abstract class or interface</strong>. The client should only know about how to use the <strong>factory method</strong>.</p><p>If these seem to be overwhelming let’s get started with an example.</p><p>Suppose you are assigned to develop a module of a bike racing game where the player will be riding a bike and your task is to provide vehicle surrounding the rider. For example, a rider will see bike / car / bus / truck et cetera as he/she moves forward as his/her surroundings .Suppose you don’t care what vehicle comes as surroundings. You just need a vehicle, that could be bus, could be car, could be truck et cetera. Doesn’t really matter.</p><p>What might be your first approach?</p><p>You might choose inheritance to solve this problem where your parent class is a abstract class or an interface named <strong>Vehicle</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/079fd92d434a1d940163c6c44aa00f52/href">https://medium.com/media/079fd92d434a1d940163c6c44aa00f52/href</a></iframe><p>and the <strong>concrete classes </strong>(Bike, Car, Truck, Bus) provide the implementations of the abstract class <strong>Vehicle</strong>. Don’t worry about the <strong>abstract methods</strong> for now, I have added these methods to demonstrate how things work at the end.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5673f4241d61f773294f62d5b1dd089/href">https://medium.com/media/d5673f4241d61f773294f62d5b1dd089/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/147f440b52364beedb418a16c0125861/href">https://medium.com/media/147f440b52364beedb418a16c0125861/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc3475652cbf1e38fa0ec406e29187b2/href">https://medium.com/media/bc3475652cbf1e38fa0ec406e29187b2/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6b33765ef5c2fda4e5f5e6417137b90/href">https://medium.com/media/f6b33765ef5c2fda4e5f5e6417137b90/href</a></iframe><p>And whenever you need an object of the concrete class you create using a new keyword.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89943bd73385c8a3d784e102d9b89691/href">https://medium.com/media/89943bd73385c8a3d784e102d9b89691/href</a></iframe><p>Well done! You got the idea but there is a problem with this approach, you are tightly coupling your code in this way and the client is bound to know the implementation logic in order to instantiate the concrete classes. We didn’t want that.</p><p>So, what could be the solution?</p><p>Let’s see another way, we want to make the object creation of concrete classes more dynamic, not static like the one we just did. We will use “Random” class to randomly pick a number between the number of concrete classes(Bike, Car, Truck, Bus -&gt; 1–4 for our use case) and it should instantiate a concrete class based on that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/639c40140df28682307de61e95663f3d/href">https://medium.com/media/639c40140df28682307de61e95663f3d/href</a></iframe><p>Yes, it did add a dynamic behavior into our code along with the polymorphic behavior but look at the code! It looks like some parasites (if-else) swirling in my main method! I don’t want it either.</p><p>What do you want actually???</p><p>I want clean code.</p><p>Fair enough! How do you do it?</p><p>Okay, let’s see our most awaited way of doing things right now.</p><p>We will use the good old OOP concept here. We will move all of our concrete class instantiation logic in a separate class<strong> VehicleFactory </strong>where all of my concrete class instantiation logic will be encapsulated inside a method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02e09c99358a8ef65884edcdb50b7e3d/href">https://medium.com/media/02e09c99358a8ef65884edcdb50b7e3d/href</a></iframe><p>The client code should not really care about what it gets as a vehicle because as I said we don’t care what vehicles come as the surrounding. We just want one of the four vehicles. It’s a random vehicle we will be putting in the surroundings of the rider.</p><p><strong>VehicleFactory</strong> is the place from where our vehicles will be provided. In there we will use a getVehicle(int randomNumber) method whose task is to provide concrete class objects based on the random number coming from the client code (other part of application code).Simple as that.</p><p>As I said earlier, I added two abstract methods to demonstrate how things work according to our design. Now look at the code fragment and the object got returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*cVPXw8kJ3vAMo4FgibFmhw.png" /><figcaption>Returned object type : <strong>Car</strong></figcaption></figure><p>By looking at the console we can see the returned object was <strong>Car</strong> and <strong>accelerator()</strong> and <strong>braking()</strong> methods of <strong>Car</strong> were called.</p><p>Similarly in the second and third run I got <strong>Truck </strong>and <strong>Bike</strong> object respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBX-YhM7qCacQdyVrv48Tg.png" /><figcaption>Returned object type : <strong>Truck</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ii7It8dbn3U222pOM_HxfQ.png" /><figcaption>Returned object type : <strong>Bike</strong></figcaption></figure><p>Let’s get back to the problems we addressed earlier. Look at the codes now and answer some questions.</p><p>Q. Does client need to know the implementation logic?</p><p>A.<strong> No.</strong></p><p>Q. Is the solution dynamic?</p><p>A. <strong>Yes.</strong></p><p>Q. Is it cleaner?</p><p>A. <strong>Yes.</strong></p><p>Kudos to the factory method pattern. You can find the code of this example in <a href="https://github.com/Masud034/Design-Patterns/tree/main/FactoryMethod-Pattern"><em>https://github.com/Masud034/Design-Patterns/tree/main/FactoryMethod-Pattern</em></a> here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee14d2a25700" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>