<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Li Zi Ying</title>
    <description>The latest articles on DEV Community by Li Zi Ying (@ziyingli).</description>
    <link>https://dev.to/ziyingli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F503633%2Fb983ec83-cb45-432e-bf4b-0ea9f4f0095e.jpeg</url>
      <title>DEV Community: Li Zi Ying</title>
      <link>https://dev.to/ziyingli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ziyingli"/>
    <language>en</language>
    <item>
      <title>Object Interaction Patterns: Facade
</title>
      <dc:creator>Li Zi Ying</dc:creator>
      <pubDate>Fri, 06 Nov 2020 02:45:40 +0000</pubDate>
      <link>https://dev.to/ziyingli/object-interaction-patterns-facade-nna</link>
      <guid>https://dev.to/ziyingli/object-interaction-patterns-facade-nna</guid>
      <description>&lt;h2&gt;
  
  
  What are object interaction patterns?
&lt;/h2&gt;

&lt;p&gt;Object interaction patterns define how a set of objects interact and falls typically under 3 categories: creational patterns, structural patterns and behavioural patterns. These patterns are described below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creational patterns&lt;/strong&gt; provide ways to instantiate single objects or groups of related objects&lt;br&gt;
&lt;strong&gt;Structural patterns&lt;/strong&gt; provide a manner to define relationships between classes or objects&lt;br&gt;
&lt;strong&gt;Behavioural patterns&lt;/strong&gt; define manners of communication between classes and objects&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Facade?
&lt;/h2&gt;

&lt;p&gt;Facade pattern falls under the structural category, providing a simple and specific interface onto a group of complex objects. Similar to a facade in architecture, which is the outward facing appearance of a building, a facade serves as a front-facing interface, hiding the complex underlying code away from the client. The participants of the Facade pattern are as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Facade&lt;/strong&gt; delegates the client request to appropriate subsystem classes, allows only one way communication from facade to subsystem&lt;br&gt;
&lt;strong&gt;Subsystems&lt;/strong&gt; implement subsystem functionalities, does not know of facade&lt;br&gt;
&lt;strong&gt;Client&lt;/strong&gt; requests facade to perform an action&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits
&lt;/h3&gt;

&lt;p&gt;Now, adding a facade interface means the client can use the facade to request for a certain action without directly calling the subsystem objects. This reduces complexity for client interaction as calls to the underlying code can be concentrated at one single point.&lt;/p&gt;

&lt;p&gt;Having a facade also improves readability and usability, consolidating all the services as a single interface to make it more understandable. Creating facades also can allow you to define entry points to different levels of a subsystem. This also allows you to have loose coupling between subsystems by requiring them to only communicate through facades. &lt;/p&gt;

&lt;p&gt;As such, facades can be very helpful in simplifying large complex systems where there are multiple subsystems tightly coupled to each other, which makes it hard for the developer to maintain the codebase and for future developers to read and understand the structure of the system as well. &lt;/p&gt;

&lt;h3&gt;
  
  
  Drawbacks
&lt;/h3&gt;

&lt;p&gt;However, there can also be some drawbacks of the facade patten. By creating extra interfaces, more code is required to be maintained leading to a larger codebase. &lt;br&gt;
This may not be so efficient for smaller projects as the increase in workload creating facades may outweigh the benefits mentioned in the previous section.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real life example
&lt;/h3&gt;

&lt;p&gt;An example where the facade pattern could be used is in the Key Word in Context (KWIC) problem system. The KWIC index system accepts an ordered set of lines, where each line is an ordered set of words and each word is an ordered set of characters. KWIC outputs a list of all circular shifts of all given lines in alphabetical order, where circular shifting is done by repeatedly removing the first word and appending it at the end of the line. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XZFKwgAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wao1l6zu3mrph51u4x6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XZFKwgAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wao1l6zu3mrph51u4x6t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two main subsystems in the KWIC index system, namely the circular shift, which circular shifts each line, and alphabetizer, which arranges the final output in alphabetical order. These two subsystems ultimately create the output that the client wants, but the client does not have to know how exactly the output is formed. Therefore, as seen in the diagram, a facade can be used to separate the logical implementation of KWIC. The client only needs to know of the facade and the facade subsequently calls the various subsystems to get the final result through unidirectional communication, as shown by the single headed arrow. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Messaging Patterns: Pub/Sub</title>
      <dc:creator>Li Zi Ying</dc:creator>
      <pubDate>Tue, 03 Nov 2020 07:45:23 +0000</pubDate>
      <link>https://dev.to/ziyingli/messaging-patterns-pub-sub-2ilg</link>
      <guid>https://dev.to/ziyingli/messaging-patterns-pub-sub-2ilg</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Messaging and message patterns are important parts of software development as they enable high-speed program-to-program communication with reliable delivery. Without it, services in the software will not be able to communicate with each other efficiently. This article mainly focuses on the publisher/subscriber message channel pattern. &lt;/p&gt;

&lt;h2&gt;
  
  
  Messaging and messaging patterns
&lt;/h2&gt;

&lt;p&gt;Messaging in software engineering is typically asynchronous and used for inter-service communication. For software engineering, messaging patterns refer how services carry out messaging with each other, talking to one another through exchanging standardised messages over messaging channels. &lt;/p&gt;

&lt;h2&gt;
  
  
  Publisher/subscriber pattern
&lt;/h2&gt;

&lt;p&gt;The pub/sub pattern is a message channel pattern, which connects the collaborating senders and receivers using a message channel that allows them to exchange messages. In the pub/sub pattern, senders are publishers and receivers are subscribers. In particular, the pub/sub mechanism removes the need for publishers to program the messages directly to specific subscribers. Instead, publishers can categorise published messages without any knowledge of subscribers and interested subscribers can subscribe to the categories of interest without any knowledge of the publishers. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0C0ljFMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29pei1jwtnmdvdsmg3iw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0C0ljFMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29pei1jwtnmdvdsmg3iw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits
&lt;/h3&gt;

&lt;p&gt;From the diagram, we can see that the publisher and subscriber do not need to know of each other, only knowledge of the event channel is needed and is sufficient to communicate. The benefit of this is that the components are loosely coupled, each publisher and subscriber can operate normally while independent of each other. This also provides scalability as publishers and subscribers can be scaled independently in the system without sending ripple effects across to the other components. &lt;/p&gt;

&lt;h3&gt;
  
  
  How is it applied in real life?
&lt;/h3&gt;

&lt;p&gt;Pub/sub message pattern can be implemented through software like RabbitMQ, which is an open source message broker software or message-oriented middleware (MOM) that can be used irrespective of the language that the application is running on. In particular, RabbitMQ is able to support different kinds of messaging exchanges, including one-to-one direct messaging, pub/sub and broadcast types of exchanges. This flexibility makes RabbitMQ very popular and utilised by companies like Reddit, Trivago and Accenture. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h78D8uNm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2yl4xkvogc61n1orfbwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h78D8uNm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2yl4xkvogc61n1orfbwg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The role of RabbitMQ is similar to that of the Event Channel in the first diagram, acting as a message broker to determine which messages are sent to which queues. The producer acts as the publisher, supplying messages to the broker (RabbitMQ) without any knowledge of the consumer or subscriber who consumes messages from the message broker. In the first diagram, the event channel simply acts as a message channel for subscribers to receive the message. However, for RabbitMQ, messages are not published directly to a queue. Instead, it provides an additional step, where the "Exchange" receives the message and routes it to a specific queue. This is done with the help of bindings and routing keys that will determine which queue the message will be added to. These messages then stay in their respective queues until the consumer handles the message. &lt;br&gt;
The pub/sub pattern is clearly applied here as consumers and producers do not have to know of each other's existence, rather relying on RabbitMQ, a message broker, to help route the messages to their respective queues. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
