<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Design Patterns Archives - Francesco Lelli %</title> <atom:link href="https://francescolelli.info/tag/design-patterns/feed/" rel="self" type="application/rss+xml" /><link>https://francescolelli.info/tag/design-patterns/</link> <description>Information Management, Computer Science,  Economics, Finance and more</description> <lastBuildDate>Mon, 20 Nov 2023 17:49:10 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod> hourly </sy:updatePeriod> <sy:updateFrequency> 1 </sy:updateFrequency> <generator>https://wordpress.org/?v=6.8.5</generator><image> <url>https://francescolelli.info/wp-content/uploads/2018/11/cropped-InstrumentElement-32x32.jpg</url><title>Design Patterns Archives - Francesco Lelli %</title><link>https://francescolelli.info/tag/design-patterns/</link> <width>32</width> <height>32</height> </image> <site
xmlns="com-wordpress:feed-additions:1">156264324</site> <item><title>Service Oriented Architecture (SOA) Design Principle: Coupling, Cohesion, and Granularity</title><link>https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/</link> <comments>https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/#respond</comments> <dc:creator><![CDATA[Francesco Lelli]]></dc:creator> <pubDate>Mon, 20 Nov 2023 17:49:02 +0000</pubDate> <category><![CDATA[Java]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software Engineering]]></category> <category><![CDATA[API]]></category> <category><![CDATA[APIs]]></category> <category><![CDATA[Cohesion]]></category> <category><![CDATA[computer science]]></category> <category><![CDATA[Coupling]]></category> <category><![CDATA[Design Patterns]]></category> <category><![CDATA[Granularity]]></category> <category><![CDATA[Service Oriented Architecture]]></category> <category><![CDATA[SOA]]></category> <category><![CDATA[software architecture]]></category> <category><![CDATA[software engineering]]></category> <category><![CDATA[Software Patterns]]></category> <guid
isPermaLink="false">https://francescolelli.info/?p=2526</guid><description><![CDATA[<p>In the realm of Service Oriented Architecture (SOA) design principles, the concepts of Service Coupling, Service Cohesion, and Service Granularity play pivotal roles in shaping a robust and effective architectural framework. Service Coupling refers to the degree of interdependence between any two business processes. In the context of SOA, weak coupling is highly preferred as [&#8230;]</p><p>The post <a
href="https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/">Service Oriented Architecture (SOA) Design Principle: Coupling, Cohesion, and Granularity</a> appeared first on <a
href="https://francescolelli.info">Francesco Lelli</a>.</p> ]]></description> <content:encoded><![CDATA[<p>In the realm of Service Oriented Architecture (SOA) design principles, the concepts of Service Coupling, Service Cohesion, and Service Granularity play pivotal roles in shaping a robust and effective architectural framework. Service Coupling refers to the degree of interdependence between any two business processes. In the context of SOA, weak coupling is highly preferred as it signifies a lower level of dependency between services, allowing for greater flexibility, scalability, and maintainability. On the other hand, Service Cohesion pertains to the degree of functional relatedness and focus of operations within a service. In SOA, strong cohesion is the desired state, emphasizing that a service should encapsulate a well-defined and closely related set of functionalities. Lastly, Service Granularity addresses the scope of functionality exposed by a service, with a preference for coarse granularity. This implies that services should provide broader, more encompassing functionalities to address the specific needs at hand, promoting reusability and minimizing the number of service invocations. Adhering to these principles ensures the creation of a service-oriented architecture that is agile, modular, and aligned with the overarching goals of the enterprise.</p><p>In short Coupling, Cohesion and Granularity are part of SOA Design Principle and they can be summarized as follows:</p><ul
class="wp-block-list"><li><strong>Service Coupling:</strong><ul
class="wp-block-list"><li><em>Definition:</em> Refers to the degree of interdependence between two business processes.</li><li><em>Preferable State:</em> Weak coupling is favored in SOA, indicating lower dependency for increased flexibility and maintainability.</li></ul></li><li><strong>Service Cohesion:</strong><ul
class="wp-block-list"><li><em>Definition:</em> Represents the degree of functional relatedness and focus of operations within a service.</li><li><em>Preferable State:</em> Strong cohesion is preferred in SOA, indicating that a service should encapsulate closely related and well-defined functionalities.</li></ul></li><li><strong>Service Granularity:</strong><ul
class="wp-block-list"><li><em>Definition:</em> Denotes the scope of functionality exposed by a service.</li><li><em>Preferable State:</em> Coarse granularity is recommended in SOA, suggesting that services should provide broad functionalities to address specific needs, promoting reusability.</li></ul></li></ul><figure
class="wp-block-image size-full"><img
fetchpriority="high" decoding="async" width="867" height="1300" data-attachment-id="2528" data-permalink="https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/attachment/pexels-photo-8470810/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810.jpeg" data-orig-size="867,1300" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;Photo by Thirdman on &lt;a href=\&quot;https:\/\/www.pexels.com\/photo\/blueprints-and-a-laptop-8470810\/\&quot; rel=\&quot;nofollow\&quot;&gt;Pexels.com&lt;\/a&gt;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;blueprints and a laptop&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="pexels-photo-8470810" data-image-description="" data-image-caption="" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-200x300.jpeg" data-large-file="https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-683x1024.jpeg" src="https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810.jpeg?8011c3&amp;8011c3" alt="Service Oriented Architecture (SOA) Design Principle: Coupling, Cohesion, and Granularity. The blueprint of Software Architecture" class="wp-image-2528" srcset="https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810.jpeg 867w, https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-200x300.jpeg 200w, https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-683x1024.jpeg 683w, https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-768x1152.jpeg 768w, https://francescolelli.info/wp-content/uploads/2023/11/pexels-photo-8470810-600x900.jpeg 600w" sizes="(max-width: 867px) 100vw, 867px" /></figure><h2 class="wp-block-heading">Service Coupling:</h2><p>Service Coupling is a critical design principle that examines the degree of interdependence between any two business processes or services within a system. It essentially evaluates how tightly or loosely these services are connected and the implications of changes in one on the others.</p><p>Characterized by the level of dependency, tight coupling signifies a strong interconnection where modifications in one service may necessitate corresponding changes in others. Conversely, weak coupling is the preferred state in SOA design. Weak coupling implies a lower level of dependency, allowing for greater flexibility, scalability, and ease of maintenance. Services with weak coupling can evolve independently, reducing the risk of unintended consequences when modifications or updates are made.</p><p>The benefits of weak coupling extend to the adaptability of the architecture to changes in business requirements. Services that are loosely coupled are more resilient to alterations, ensuring that adjustments in one part of the system do not propagate unexpectedly to other interconnected services.</p><p>For example, a service employing standardized interfaces and protocols can interact with other services more loosely, minimizing the impact of changes in one service on others. Achieving weak coupling often involves defining clear service interfaces, minimizing direct dependencies, and utilizing standards to facilitate interoperability between services. In essence, Service Coupling is a foundational principle in SOA design that promotes a modular, adaptable, and scalable architecture.</p><h2 class="wp-block-heading">Service Cohesion:</h2><p>Service Cohesion stands as a pivotal design principle governing the internal organization and functional relatedness within an individual service. It delves into the degree to which the operations encapsulated within a service are logically connected and focused on a specific set of functionalities.</p><p>Characterized by its emphasis on functional relatedness, strong cohesion is the ideal state for services in SOA. A service exhibiting strong cohesion encapsulates a well-defined and closely related set of functionalities, ensuring that its operations are united by a common purpose. This design approach enhances the service&#8217;s clarity, maintainability, and usability, as all contained functionalities contribute to a coherent and unified business capability.</p><p>In contrast, weak cohesion suggests a service with disparate functionalities that may not be logically connected, leading to a lack of clarity and potentially hindering the service&#8217;s effectiveness. Strong cohesion, on the other hand, facilitates a service&#8217;s reusability, as the encapsulated functionalities are designed to work together seamlessly, promoting a modular and extensible architecture.</p><p>For example, a service responsible for order processing should ideally encapsulate functionalities such as order validation, payment processing, and inventory management, exhibiting strong cohesion by focusing on a cohesive set of operations related to order fulfillment.</p><p>Achieving strong cohesion often involves careful analysis of the business processes and ensuring that the functionalities grouped within a service share a common context and purpose. This principle contributes to the creation of services that are not only well-defined and purposeful but also conducive to building a scalable and adaptable SOA.</p><h2 class="wp-block-heading">Service Granularity:</h2><p>The concept of Service Granularity plays a crucial role in defining the scope of functionality exposed by a service. It is essentially a measure of how broad or specific a set of functionalities needs to be in order to address a particular business need. The degree of granularity directly impacts the reusability, flexibility, and efficiency of the services within the architecture.</p><p>In SOA, the preferable state for Service Granularity is characterized by a tendency towards coarse granularity. Coarse-grained services encapsulate broader and more encompassing functionalities, capable of addressing significant business requirements in a single service invocation. This design approach promotes simplicity, reduces the number of service interactions, and facilitates easier maintenance.</p><p>Conversely, fine-grained services expose narrower sets of functionalities, potentially requiring multiple service invocations to fulfill a specific business operation. While fine granularity may seem intuitive for certain scenarios, it can lead to increased communication overhead and complexity, making the system more susceptible to performance issues and maintenance challenges.</p><p>For example, a coarse-grained service responsible for customer management might encompass functions such as creating, updating, and deleting customer profiles, providing a comprehensive set of functionalities within a single service interface.</p><p>Achieving the right level of granularity involves careful consideration of the business context and requirements. Coarse granularity is favored as it enhances the potential for service reuse, reduces the impact of changes on service interfaces, and aligns with the overarching goal of creating a modular and scalable architecture in SOA. Striking a balance between granularity and functionality is key to building an effective and adaptable service-oriented system.</p><hr
/><p><em>Unlock the power of Service Oriented Architecture (#SOA )! Learn how #service Coupling Cohesion, and Granularity influence flexibility and #scalability in your #System . #softwaredevelopment #programming #API</em><br
/><a
href='https://twitter.com/intent/tweet?url=https%3A%2F%2Ffrancescolelli.info%2Fsoftware-engineering%2Fservice-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity%2F&#038;text=Unlock%20the%20power%20of%20Service%20Oriented%20Architecture%20%28%23SOA%20%29%21%20Learn%20how%20%23service%20Coupling%20Cohesion%2C%20and%20Granularity%20influence%20flexibility%20and%20%23scalability%20in%20your%20%23System%20.%20%23softwaredevelopment%20%23programming%20%23API&#038;related' target='_blank' rel="noopener noreferrer" >Share on X</a><br
/><hr
/><h2 class="wp-block-heading">Service Oriented Architecture (SOA) Design Principle and Application Programming Interfaces (APIs)</h2><p>The concepts of Service Coupling, Service Cohesion, Service Granularity, and APIs (Application Programming Interfaces) are intricately related in the context of designing and implementing a Service Oriented Architecture (SOA) or any modular and scalable system. APIs act as the external interface for services, and their design choices have a direct impact on the level of coupling, the cohesion within services, and the granularity of functionalities exposed. A well-thought-out API strategy is crucial for realizing the principles of a modular, scalable, and adaptable Service Oriented Architecture.</p><p>APIs and SOA operate at different levels of abstraction and have distinct purposes within the realm of software architecture. The distinction in their level of abstraction is rooted in their design principles, scope, and intended use. APIs are considered more low-level than SOA because they provide detailed interfaces for developers to interact with specific functionalities, while SOA operates at a higher level, focusing on the overall organization and alignment of services within a system. APIs are tools that facilitate the implementation of SOA principles at a more granular level.</p><p>This specific article focus on SOA design principles; if you want to know more on <a
href="https://francescolelli.info/programming/how-to-design-a-good-api-advanced-object-oriented-programming/">how to design a good API you can find more information here</a>.</p><p></p><p>The post <a
href="https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/">Service Oriented Architecture (SOA) Design Principle: Coupling, Cohesion, and Granularity</a> appeared first on <a
href="https://francescolelli.info">Francesco Lelli</a>.</p> ]]></content:encoded> <wfw:commentRss>https://francescolelli.info/software-engineering/service-oriented-architecture-soa-design-principle-coupling-cohesion-and-granularity/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <post-id
xmlns="com-wordpress:feed-additions:1">2526</post-id> </item> <item><title>What Software Patterns (or Design Patterns) are and an introduction to the most common one</title><link>https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/</link> <comments>https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/#respond</comments> <dc:creator><![CDATA[Francesco Lelli]]></dc:creator> <pubDate>Tue, 03 Oct 2023 10:19:03 +0000</pubDate> <category><![CDATA[Java]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software Engineering]]></category> <category><![CDATA[adapter]]></category> <category><![CDATA[Class diagram]]></category> <category><![CDATA[computer science]]></category> <category><![CDATA[Design Patterns]]></category> <category><![CDATA[facade]]></category> <category><![CDATA[observer]]></category> <category><![CDATA[Proxy]]></category> <category><![CDATA[software architecture]]></category> <category><![CDATA[software engineering]]></category> <category><![CDATA[Software Patterns]]></category> <category><![CDATA[UML]]></category> <category><![CDATA[UML diagram]]></category> <guid
isPermaLink="false">https://francescolelli.info/?p=2511</guid><description><![CDATA[<p>Software patterns, often referred to as design patterns, are a reusable and generalizable solution to a common problem that software developers face when designing and building software applications. Design patterns are essentially templates or blueprints for solving recurring design problems in a systematic and efficient way. Design patterns serve several important purposes in software development: [&#8230;]</p><p>The post <a
href="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/">What Software Patterns (or Design Patterns) are and an introduction to the most common one</a> appeared first on <a
href="https://francescolelli.info">Francesco Lelli</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Software patterns, often referred to as design patterns, are a reusable and generalizable solution to a common problem that software developers face when designing and building software applications. Design patterns are essentially templates or blueprints for solving recurring design problems in a systematic and efficient way.</p><p>Design patterns serve several important purposes in software development:</p><ol
class="wp-block-list"><li><strong>Reusability</strong>: They encapsulate proven solutions to common problems, making it easier for developers to reuse these solutions in different parts of their code or in different projects.</li><li><strong>Abstraction</strong>: Design patterns provide a higher-level abstraction that helps developers think about and communicate the structure of their code more effectively. They provide a common language and framework for discussing design decisions.</li><li><strong>Maintainability</strong>: Using design patterns can improve the maintainability of software because they promote well-structured and organized code. Developers can more easily understand and modify code that follows established patterns.</li><li><strong>Scalability</strong>: Patterns can help ensure that software is designed in a way that allows it to scale and adapt to changing requirements without requiring major redesigns.</li><li><strong>Community Knowledge</strong>: Design patterns are well-documented and widely recognized within the software development community. This means that developers can leverage the collective wisdom and experience of the community when applying these patterns.</li></ol><figure
class="wp-block-image size-full"><img
decoding="async" width="1734" height="1300" data-attachment-id="2518" data-permalink="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/attachment/pexels-photo-577585/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585.jpeg" data-orig-size="1734,1300" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;Photo by Kevin Ku on &lt;a href=\&quot;https:\/\/www.pexels.com\/photo\/data-codes-through-eyeglasses-577585\/\&quot; rel=\&quot;nofollow\&quot;&gt;Pexels.com&lt;\/a&gt;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;data codes through eyeglasses&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="pexels-photo-577585" data-image-description="" data-image-caption="&lt;p&gt;Photo by Kevin Ku on &lt;a href=&quot;https://www.pexels.com/photo/data-codes-through-eyeglasses-577585/&quot; rel=&quot;nofollow&quot;&gt;Pexels.com&lt;/a&gt;&lt;/p&gt;
" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-300x225.jpeg" data-large-file="https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-1024x768.jpeg" src="https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585.jpeg?8011c3&amp;8011c3" alt="What is a Software Patterns or a Design Patterns and an introduction to the most common one" class="wp-image-2518" srcset="https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585.jpeg 1734w, https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-300x225.jpeg 300w, https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-1024x768.jpeg 1024w, https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-768x576.jpeg 768w, https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-600x450.jpeg 600w, https://francescolelli.info/wp-content/uploads/2023/10/pexels-photo-577585-1536x1152.jpeg 1536w" sizes="(max-width: 1734px) 100vw, 1734px" /><figcaption
class="wp-element-caption"><em>What are Software Patterns (or Design Patterns) and an introduction to the most common one</em></figcaption></figure><p>As the term software embrace a very large domain, there are several categories of design patterns. Each one is specialized for a particular portion portion of the code. These patterns includes:</p><ol
class="wp-block-list"><li><strong>Creational Patterns</strong>: These patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. Examples include the Singleton, Factory Method, and Abstract Factory patterns.</li><li><strong>Structural Patterns</strong>: Structural patterns focus on defining the composition of classes and objects. Examples include the Adapter, Bridge, and Decorator patterns.</li><li><strong>Behavioral Patterns</strong>: Behavioral patterns are concerned with the interaction and communication between objects. Examples include the Observer, Strategy, and Command patterns.</li><li><strong>Architectural Patterns</strong>: These are high-level patterns that deal with the overall structure of an application. Examples include the Model-View-Controller (MVC), Model-View-ViewModel (MVVM), and Layered Architecture patterns.</li><li><strong>Concurrency Patterns</strong>: These patterns address issues related to managing concurrent access to shared resources in multi-threaded applications. Examples include the Mutex, Semaphore, and Read-Write Lock patterns.</li></ol><p>Design patterns are not one-size-fits-all solutions, and they should be applied judiciously based on the specific requirements and constraints of a software project. Experienced developers use their knowledge of design patterns to make informed decisions about when and how to apply them to solve particular problems.</p><p>The list of pattern is long and is also evolving as the software developer community evolve. At the Some time pattern like <strong>facade</strong>, <strong>adapter</strong>/<strong>wrapper</strong>, <strong>proxy </strong>and <strong>observer </strong>stand the test of time and are the most known among developers. Let&#8217;s see each one of them</p><h2 class="wp-block-heading"><strong>Facade Pattern</strong>:</h2><ul
class="wp-block-list"><li><strong>Purpose</strong>: The Facade pattern provides a simplified, high-level interface to a complex subsystem or set of classes. It acts as a &#8220;facade&#8221; to shield clients from the underlying complexities of the system.</li><li><strong>Use Cases</strong>: It&#8217;s useful when you want to provide a simplified and unified interface to a complex system, making it easier for clients to interact with it. It promotes loose coupling between the client code and the subsystem.</li></ul><p>The image below present the pattern using a <a
href="https://francescolelli.info/generic/developing-uml-diagrams/">Class Diagram</a>:</p><figure
class="wp-block-image size-large"><img
decoding="async" width="1024" height="710" data-attachment-id="2512" data-permalink="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/attachment/facadedesingpattern/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern.jpg" data-orig-size="1138,789" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Francesco Lelli&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1696331786&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="FacadeDesingPattern" data-image-description="" data-image-caption="" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-300x208.jpg" data-large-file="https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-1024x710.jpg" src="https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-1024x710.jpg?8011c3&amp;8011c3" alt="What are Software Patterns (or Design Patterns) and an introduction to the Facade Pattern" class="wp-image-2512" srcset="https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-1024x710.jpg 1024w, https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-300x208.jpg 300w, https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-768x532.jpg 768w, https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern-600x416.jpg 600w, https://francescolelli.info/wp-content/uploads/2023/10/FacadeDesingPattern.jpg 1138w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><p><strong>Example of Use: Multimedia Player Facade</strong></p><p>Suppose you are building a multimedia player application that can play various types of media, such as audio and video files. The underlying multimedia framework is complex, with different classes and interfaces for handling codecs, rendering, audio output, and video display.</p><p>In this example, we could consider implementing a class of name <em><strong><code>MultimediaPlayerFacade</code> </strong></em>that acts as a simplified interface to the complex multimedia framework. It encapsulates the initialization and usage details of the audio and video players, making it much easier for client code to play multimedia. The client code is simplified and less coupled to the underlying multimedia framework, which can change without affecting the client code.</p><p>The Facade pattern here provides a cleaner and more maintainable way to interact with a complex subsystem, shielding the client code from its intricacies.</p><h2 class="wp-block-heading"><strong>Adapter Pattern</strong> also known as <strong>Wrapper Pattern</strong>::</h2><ul
class="wp-block-list"><li><strong>Purpose</strong>: The Adapter pattern allows two incompatible interfaces to work together by providing a wrapper around one of them. It acts as a bridge between two interfaces, making them compatible without changing their source code.</li><li><strong>Use Cases</strong>: It&#8217;s used when you have existing code with interfaces that are not compatible with the interfaces you need to use. The adapter pattern allows you to reuse existing code without modification.</li></ul><p>The image below present the pattern using a <a
href="https://francescolelli.info/generic/developing-uml-diagrams/">Class Diagram</a>:</p><figure
class="wp-block-image aligncenter size-full is-resized"><img
loading="lazy" decoding="async" data-attachment-id="2513" data-permalink="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/attachment/the-class-diagram-of-the-adapter-design-pattern_w640/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/10/The-class-diagram-of-the-Adapter-design-pattern_W640.jpg" data-orig-size="640,395" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="The-class-diagram-of-the-Adapter-design-pattern_W640" data-image-description="" data-image-caption="" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/10/The-class-diagram-of-the-Adapter-design-pattern_W640-300x185.jpg" data-large-file="https://francescolelli.info/wp-content/uploads/2023/10/The-class-diagram-of-the-Adapter-design-pattern_W640.jpg" src="https://francescolelli.info/wp-content/uploads/2023/10/The-class-diagram-of-the-Adapter-design-pattern_W640.jpg?8011c3&amp;8011c3" alt="What are Software Patterns (or Design Patterns) and an introduction to the Adapter/Wrapper Pattern" class="wp-image-2513" style="width:840px;height:395px" width="840" height="395"/></figure><p><strong>Example of use: Legacy System Integration</strong></p><p>Imagine you are working on a modern e-commerce application that needs to integrate with a legacy payment gateway. The legacy payment gateway has an outdated interface that doesn&#8217;t match the modern payment service interface your application uses. You can use the Adapter pattern to bridge the gap.</p><p>To integrate the legacy payment gateway with your modern payment service, you can create an adapter class. In this way you can use the <code><em>Legacy Payment Adapter</em></code> to make payments through the legacy payment gateway using the modern payment service. In this way the adapter acts as a bridge between the modern payment service interface and the legacy payment gateway.</p><h2 class="wp-block-heading"><strong>Proxy Pattern</strong>:</h2><ul
class="wp-block-list"><li><strong>Purpose</strong>: The Proxy pattern provides a surrogate or placeholder for another object to control access to it. It can be used to add an additional layer of control over an object, such as lazy loading, access control, or caching.</li><li><strong>Use Cases</strong>: It&#8217;s useful when you want to control access to an object, especially in situations where the creation or access to the object is expensive or where you need to add functionality around object access.</li></ul><p>The image below present the pattern using a <a
href="https://francescolelli.info/generic/developing-uml-diagrams/">Class Diagram</a>:</p><figure
class="wp-block-image size-large"><img
loading="lazy" decoding="async" width="1024" height="572" data-attachment-id="2514" data-permalink="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/attachment/proxy_pattern_diagram-svg_/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_.png" data-orig-size="1920,1072" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Proxy_pattern_diagram.svg_" data-image-description="" data-image-caption="" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-300x168.png" data-large-file="https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-1024x572.png" src="https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-1024x572.png?8011c3&amp;8011c3" alt="What are Software Patterns (or Design Patterns) and an introduction to the Proxy Pattern" class="wp-image-2514" srcset="https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-1024x572.png 1024w, https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-300x168.png 300w, https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-768x429.png 768w, https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-600x335.png 600w, https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_-1536x858.png 1536w, https://francescolelli.info/wp-content/uploads/2023/10/Proxy_pattern_diagram.svg_.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><p><strong>Example of use: Image Loading Proxy</strong></p><p>Suppose you are building an image viewer application, and you want to implement a feature that loads and displays high-resolution images from a remote server. However, loading these high-resolution images can be slow and resource-intensive. To improve user experience and optimize resource usage, you can use the Proxy pattern. You can use the <strong><em><code>ImageProxy</code> </em></strong>to load and display images in your application without loading the high-resolution image until it&#8217;s actually needed. Consequently you can delay the creation and loading of resource-intensive objects, improving the performance and resource utilization of your application.</p><h2 class="wp-block-heading"><strong>Observer Pattern</strong>:</h2><ul
class="wp-block-list"><li><strong>Purpose</strong>: The Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents (observers) are notified and updated automatically.</li><li><strong>Use Cases</strong>: It&#8217;s commonly used for implementing distributed event handling systems, where multiple objects need to react to changes in another object&#8217;s state. Examples include GUI frameworks where UI elements update when underlying data changes.</li></ul><p>The image below present the pattern using a <a
href="https://francescolelli.info/generic/developing-uml-diagrams/">Class Diagram</a>:</p><figure
class="wp-block-image size-large"><img
loading="lazy" decoding="async" width="1024" height="423" data-attachment-id="2515" data-permalink="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/attachment/1920px-observer_w_update-svg_/" data-orig-file="https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_.png" data-orig-size="1920,794" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="1920px-Observer_w_update.svg_" data-image-description="" data-image-caption="" data-medium-file="https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-300x124.png" data-large-file="https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-1024x423.png" src="https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-1024x423.png?8011c3&amp;8011c3" alt="What are Software Patterns (or Design Patterns) and an introduction to the Observer Pattern" class="wp-image-2515" srcset="https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-1024x423.png 1024w, https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-300x124.png 300w, https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-768x318.png 768w, https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-600x248.png 600w, https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_-1536x635.png 1536w, https://francescolelli.info/wp-content/uploads/2023/10/1920px-Observer_w_update.svg_.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><p><strong>Example of use: Weather Monitoring System</strong></p><p>Imagine you are building a weather monitoring system that collects weather data from various sensors and notifies multiple display devices when the weather conditions change. In this scenario, you can apply the Observer pattern to implement the system. You could imagine a class of name <code>ConcreteWeatherStation</code> as the subject that collects weather data and notifies its observers (in this case, maybe various display objects) when the data changes. The Observer pattern allows multiple display devices to receive and react to updates without being tightly coupled to the weather station.</p><h2 class="wp-block-heading">Summary of Software Patterns or Design patterns</h2><p>Software patterns, also known as design patterns, are widely recognized and essential approaches for organizing code and solving recurring design problems in software development. Among these patterns, the Facade pattern simplifies complex subsystems by providing a unified interface, making it easier for clients to interact with intricate systems. The Adapter pattern bridges the gap between incompatible interfaces, allowing different components to work seamlessly together. The Proxy pattern acts as a surrogate for an object, controlling access and adding functionality, which can be valuable for resource optimization and security. Lastly, the Observer pattern facilitates the creation of distributed event handling systems, enabling one object to notify multiple observers about changes, enhancing code modularity and flexibility. These patterns represent just a subset of the many design patterns available, and they serve as valuable tools in the developer&#8217;s toolkit for building maintainable, scalable, and efficient software systems.</p><p>In the case you would like to learn more I would recommend you to have a look at the following book from &#8220;<a
href="https://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional-ebook/dp/B000SEIBB8">the gang of 4</a>&#8220;</p><figure
class="wp-block-embed is-type-rich is-provider-amazon wp-block-embed-amazon"><div
class="wp-block-embed__wrapper"> <iframe
title="Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series)" type="text/html" width="800" height="550" frameborder="0" allowfullscreen style="max-width:100%" src="https://read.amazon.com/kp/card?preview=inline&#038;linkCode=kpd&#038;ref_=k4w_oembed_scruoIlirQiw0u&#038;asin=B000SEIBB8&#038;tag=kpembed-20"></iframe></div></figure><p>It is a classic and several libraries will probably have a copy.</p><p>The post <a
href="https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/">What Software Patterns (or Design Patterns) are and an introduction to the most common one</a> appeared first on <a
href="https://francescolelli.info">Francesco Lelli</a>.</p> ]]></content:encoded> <wfw:commentRss>https://francescolelli.info/software-engineering/what-software-patterns-or-design-patterns-are-and-an-introduction-to-the-most-common-one/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <post-id
xmlns="com-wordpress:feed-additions:1">2511</post-id> </item> </channel> </rss>