<?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>Forem: Simeon</title>
    <description>The latest articles on Forem by Simeon (@boma).</description>
    <link>https://forem.com/boma</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%2F1266232%2Fad0ea27f-2c26-472a-8bb4-de8b16a6057e.jpeg</url>
      <title>Forem: Simeon</title>
      <link>https://forem.com/boma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boma"/>
    <language>en</language>
    <item>
      <title>Understanding Design Patterns With Laravel</title>
      <dc:creator>Simeon</dc:creator>
      <pubDate>Fri, 26 Jan 2024 14:03:40 +0000</pubDate>
      <link>https://forem.com/boma/understanding-design-patterns-with-laravel-5dci</link>
      <guid>https://forem.com/boma/understanding-design-patterns-with-laravel-5dci</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;​​In object-oriented languages, software developers do what's  needed to achieve their desired outcome. There are numerous kinds of objects, situations and problems in an application. &lt;br&gt;
​​As a result, multiple strategies are required to tackle various problems. Implementing design patterns is crucial for improving the quality of online apps. &lt;br&gt;
​​When a developer starts to consider issues like how to make the code more legible, maintainable, and upgradeable, he will run into design patterns.&lt;br&gt;
​​There are particular design patterns for each programming language. We'll learn about the design patterns Laravel uses, and how and why are they used, with examples.&lt;/p&gt;
&lt;h2&gt;
  
  
  Design Patterns
&lt;/h2&gt;

&lt;p&gt;Design patterns are established solutions to recurring problems in programming. They offer a reusable, optimized, and cost-effective approach to problem-solving and achieving desired outcomes. Designed by Eric Gamma and his colleagues in 1994, design patterns provide developers with a standardized and readable way of coding. Implementing design patterns in a project ensures clean and efficient code, as they have already been tested and used successfully by many other developers in similar situations. Design patterns not only provide robust systems but also offer friendly and efficient architectural solutions to common problems.&lt;/p&gt;
&lt;h3&gt;
  
  
  Benefits of using Design Patterns
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Implements the code reusability concept&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easier Maintenance and Documentation &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved readability &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ease in finding appropriate objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better specification of object interfaces&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ease of implementation even for complex software projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Factory Pattern
&lt;/h3&gt;

&lt;p&gt;As a hypothetical scenario, consider making cake. It requires several components, like eggs and milk. Obtaining milk involves sourcing it from a dairy animal and undergoing pasteurization, which might be tasking. However, instead of going through this procedure, milk can be easily obtained from a grocery store. Therefore, in this instance, the grocery store is deemed the creator of the milk, and it is of no concern how the milk is produced, as long as it can be purchased, a similar logic applies to the other components required.&lt;/p&gt;

&lt;p&gt;The factory pattern is a method for object creation that solves the problem of creating complex objects in a way that is maintainable, reusable, and testable. It acts as a central location for object creation and abstracts the process of object creation by providing an interface for it, without specifying the exact concrete class to be used.&lt;br&gt;
Let’s go with an example; &lt;br&gt;
The primary function of the cake factory is to produce cake and the details of the process are not important (abstract class), all that matters is the end product (instance). To be considered a valid factory, certain methods must be in place. For example, the cake factory produces the same type of cake, but with varying specifications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Cakefactorycontract
{  
  public function make(array $toppings  =[ ]): Cake;
 }
Class Cakefactory implements Cakefactorycontract
{
     public function make(array $toppings = [ ]: Cake
       {
          return new Cake($toppings);
         }
}
$cake = (new Cakefactory)-&amp;gt;make([ ‘fruits’ , ‘Oreos’ , ‘candy’ ]);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, if we look at this simple cake factory example, we have a Cake factory  which is responsible for making a cake, and in the end, we get an instance of a cake.&lt;/p&gt;

&lt;p&gt;Laravel implements the factory pattern, not only for creating complex objects, but also for generating views.&lt;br&gt;
Let’s see an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
Class Postcontroller
{
  public function index( ): \Illuminate\view\view
    {
         $posts = Post: : all( );
           return view (’posts.index’ , [’posts’ =&amp;gt; $posts]); 
     }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this scenario, we utilize the view helper and call the view method. The view method acts as the helper method and eventually calls the factory. We provide the view with the necessary data for it to construct.&lt;br&gt;
When you return a view in Laravel, it utilizes the factory pattern in the background to generate the view. This pattern is also utilized for creating notifications and validators.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/ / Illuminate\foundation\helpers.php

/**
*@return \Illuminate\view\view|\Illuminate\contracts\view\factory
*/
function view ($view = null,  $data  = [ ],  $mergedata = [ ])
{
  $factory =  app(viewFactory: :class): 
   if (func_num_args( ) === 0)  {  
        return $factory:
   }
   return $factory-&amp;gt;make($view, data, $merge data): 
 }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we examine the helper method, we can see that a factory called the view factory is formed. The make() function, which is a factory method that ultimately generates a view and returns it back to us, is called by this factory. The views we utilize in our controller are produced by this factory.&lt;br&gt;
This makes it easier for us to reuse and maintain clean code. Now we have a designated location for creating the view, which is easily maintainable, reusable, and testable.&lt;/p&gt;
&lt;h3&gt;
  
  
  Builder Pattern
&lt;/h3&gt;

&lt;p&gt;Having learned how to make the cake ingredients from the previous abstract example, we now have the capability to assemble a cake using the factory. Each cake is different. To accommodate this, you can create a new builder for your cake. The cake baker acts as the builder, constructing various cakes to suit your personal taste.&lt;/p&gt;

&lt;p&gt;The builder pattern is tasked with constructing complicated objects and utilizes factories for this purpose. In Laravel, it is commonly referred to as the manager pattern. The objective of this design pattern is to create simpler and reusable objects by separating complex object construction layers from the rest of the application, allowing for the separated layers to be utilized in various parts of the program.&lt;br&gt;
The primary objective of all design patterns is to create objects. However, some objects can be inherently complex, and in such situations, it can be useful to have a director and builder to manage the construction process.&lt;br&gt;
  Using our previous example, let’s say we have a builder class called &lt;code&gt;"CakeBuilder"&lt;/code&gt;.&lt;br&gt;
.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cakebuilder
 {
      public function make(CakebuilderInterface $cake): Cake
      {
          //returns object of type cake
       }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All objects of the "Builder" type should conform to the same interface, which is defined by the &lt;code&gt;CakebuilderInterface&lt;/code&gt;. The "make" method, specified by the interface, accepts an object that implements the &lt;code&gt;CakebuilderInterface&lt;/code&gt;and returns a &lt;code&gt;Cake&lt;/code&gt; object.&lt;br&gt;
Therefore, when we call the "make method," our goal is to perform these steps: prepare the cake, add toppings, bake it, and ultimately obtain a &lt;code&gt;Cake&lt;/code&gt;object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cakebuilder
{ 
   public function make(CakeBuilderInterface $cake): Cake
    {
           return $cake
                   -&amp;gt;prepare()
                   -&amp;gt;applyToppings()
                   -&amp;gt;bake()
        }
 }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Cakebuilder&lt;/code&gt;uses these methods which every &lt;code&gt;Cakebuilder&lt;/code&gt;object must adhere to;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Cakebuilder interface
  {
      public function prepare(): Cake;
      public function applyToppings(): Cake;
      public function bake(): Cake;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In another instance let’s say we want to build a chocolate cake, we make a chocolate builder which implements the cake builder interface and from there we can implement the methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Chocolatebuilder implements Cakebuilder interface
   { 
       protected cake;

           public function prepare(): Pizza
      {
          $this-&amp;gt;cake = new Cake:
           return this-&amp;gt;cake;
      }
         public function applyToppings(): Cake
      {
           $this-&amp;gt;cake setToppings([‘fruits’, ‘candy’ ]):
            return this-&amp;gt;cake;
      }
            public function bake(): Cake;
      {
          $this-&amp;gt;pizza setBakingTemperature (180):
           $this-&amp;gt;pizza setBakingMinutes (45):

       return $this-&amp;gt;cake:
       }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the blueprint of each cake object. And our &lt;code&gt;Cakebuilder&lt;/code&gt;understands the chocolate builder because it’s adhering to the &lt;code&gt;Cakebuilder&lt;/code&gt; interface. &lt;br&gt;
This is what we get by putting it all together;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cakebuilder
{ 
    public function make(CakeBuilderInterface $cake): Cake
    { 
            return $cake
                   -&amp;gt;prepare()
                   -&amp;gt;applyToppings()
                   -&amp;gt;bake()
        }
 }
  // Create a Cakebuilder
  $cakebuilder = new Cakebuilder 

 // Create cake using Builderwhich returns Cake instance
$cake = $cakeBuilder-&amp;gt;make(new ChocolateBuilder()):

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this example, we can create more builders by applying the same Interface.&lt;/p&gt;

&lt;p&gt;Laravel uses this pattern in a bit of a different way. Laravel uses an &lt;a href="https://laravel.com/docs/5.0/extending#:~:text=Laravel%20has%20several%20Manager%20classes,based%20on%20the%20application's%20configuration."&gt;abstract manager&lt;/a&gt; class which is adhered to by a lot of other classes that defines how the builder should work. And this is useful throughout the codebase a lot.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Illuminate\Mail\TransportManager
Class TransportsManager extends Manager
{
    protected function createSmtpDriver()
    {
          //Code for building a SmtpTransport class
    }
protected function createMailgunDriver()
   {
        //Code for building a MailgunTransport class
    }
    protected function createSparkpostDriver()
    {
        //Code for building a SparkpostTransport class
    }
    protected function createLogDriver()
    {
        //Code for building a LogTransport class
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Laravel uses this technique in a lot of places and the most apparent one is the mail class also called the transport manager, which is used for sending emails. Based on the drive name it will try to call a correct transport class and all classes extend the same transport class so they always return the same object.&lt;br&gt;
Let's look at the default driver method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class TransportManager extends Manager
{
    public function getDefaultDriver()
    {
        return $this-&amp;gt;app['config']['mail.driver'];
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Laravel, the default driver method utilizes the configuration, making it simple to switch between different email services. For example, if you are currently using &lt;a href="https://mailtrap.io/blog/send-email-in-laravel/"&gt;SMTP &lt;/a&gt;and want to switch to &lt;a href="https://enlear.academy/using-mailgun-to-send-emails-from-laravel-framework-9d5a39ba946a"&gt;Mailgun&lt;/a&gt; or another service, this can easily be done through the default driver. This is made possible by the manager pattern, which is responsible for creating and returning objects. The SMTP driver is specified in the configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//config/mail.php
'driver' =&amp;gt; env('MAIL_DRIVER', 'smtp'),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the Transport manager calls the &lt;code&gt;getDefaultDriver()&lt;/code&gt; method and determines that Smtp is configured, it will create the &lt;code&gt;SmtpDriver&lt;/code&gt;. This allows for sending an email.&lt;/p&gt;

&lt;p&gt;Laravel manager pattern example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Illuminate\Auth\AuthManager
Illuminate\Broadcasting\BroadcastManager
Illuminate\Cache\CacheManager
Illuminate\Filesystem\FilesystemManager
Illuminate\Mail\TransportManager
Illuminate\Notifications\ChannelManager
Illuminate\Queue\QueueManager
Illuminate\Session\SessionManager

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Repository Pattern
&lt;/h3&gt;

&lt;p&gt;The repository is the interface between the data source and the part of the code that wants to interact with the data. &lt;br&gt;
In simple terms, the Repository pattern in a Laravel application serves as a link between &lt;a href="https://www.educba.com/laravel-models/"&gt;models&lt;/a&gt; and &lt;a href="https://www.tutorialspoint.com/laravel/laravel_controllers.htm"&gt;controllers&lt;/a&gt;. The model should not be in charge of connecting to or retrieving data from the database during this process. As a result, using the repository is required to keep our code clean and secure. It cuts down on code duplication and errors.&lt;/p&gt;

&lt;p&gt;For example, we have a client table in our database, where we can add, store, edit and delete client data. We also have a Client model. The idea is, we’re going to create an interface and define some methods, using this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UserInterface.php

&amp;lt;?php
//(Here the App\Repositories is the folder name)
namespace App\Repositories;

interface UserInterface
{
   public function all();

   public function get($id);

   public function store(array $data);

   public function update($id, array $data); 

   public function delete($id);
}
?&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our &lt;code&gt;UserInterface&lt;/code&gt;interface has five methods called; all(), get(), store(), update(), and delete (). We now need to establish a repository after creating our interface. We'll implement these functions in the repository by calling them from the interface. Let's setup a repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EloquentuserRepository.php

&amp;lt;?php
//(Here the App\Repositories is the folder name)
namespace App\Repositories;
use App\Models\Client;

class EloquentuserRepository implements UserInterface
{
    //To view all the data
    public function all()
    {
        return Client::get();
    }
    //Get an individual record
    public function get($id)
    {
        return Client::find($id);
    }
    //Store the data
    public function store(array $data)
    {
        return Client::create($data);
    }
    //Update the data
    public function update($id, array $data)
    {
        return Client::find($id)-&amp;gt;update($data);
    }
    //Delete the data
    public function delete($id)
    {
        return Client::destroy($id);
    }
}
?&amp;gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;EloquentuserRepository&lt;/code&gt; is the name of the repository in this case, and it implements the &lt;code&gt;UserInterface&lt;/code&gt;. Now that we can access all of those interface methods in this repository, we can use them. For instance, the get() method is used by the all() function to return all the data from the Client model. The other functions work in the same way.&lt;br&gt;
We now have a repository and an interface. To make use of it, we'll need a bridge that connects the interface to the repository. We  can use a &lt;code&gt;ServiceProvider class&lt;/code&gt; as a bridge. Let's build a service provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Repositoryserviceprovider:
&amp;lt;?php
//(Here the App\Repositories is the folder name)
namespace App\Repositories;
use Illuminate\Support\ServiceProvider;

class RepositoriesServiceProvider extends ServiceProvider
{
    public function register()
    {
    $this-&amp;gt;app-&amp;gt;bind(
      'App\Repositories\UserInterface',
      'App\Repositories\EloquentuserRepository'
    );
    }
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our Service provider name is &lt;code&gt;RepositoriesServiceProvider&lt;/code&gt;. We use a register function in this &lt;code&gt;ServiceProvider class&lt;/code&gt; to bind the interface and repository. They will now be included in the Config.php file. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Config.php:&lt;br&gt;
App\Repositories\RepositoriesServiceProvider::class,&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
We can now employ the &lt;code&gt;UserInterface&lt;/code&gt;class with a construct function in the &lt;code&gt;UserController&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UserController:
use App\Repositories\UserInterface;

class UserController extends Controller
{
    protected $user;
    public function __construct(UserInterface $user){
        $this-&amp;gt;user = $user;
    }
    //Get the data
    public function index(){
        $data= $this-&amp;gt;user-&amp;gt;all();
        return view('index', compact(data));
    }
    //Store the data
    public function store(Request $request){
    $this-&amp;gt;user-&amp;gt;store($request-&amp;gt;all());
        return redirect()-&amp;gt;route('client.index');
    }
    //Edit the data
    public function edit($id){
        $data= $this-&amp;gt;user-&amp;gt;get($id);
        return view('edit', compact(data));
    }
    //Update the data
    public function update($id, Request $request){
        $this-&amp;gt;user-&amp;gt;update($id, $request-&amp;gt;all());
        return redirect()-&amp;gt;route('client.index');
    }
    //Delete the data
    public function delete($id){
        $this-&amp;gt;user-&amp;gt;delete($id);
        return redirect()-&amp;gt;route('client.index');
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Typically, when using a &lt;a href="https://www.crowdstrike.com/cybersecurity-101/observability/crud/"&gt;CRUD&lt;/a&gt; system, the functions would be implemented in the controller. However, if there is another controller for the product table that requires the same CRUD system, it would not be efficient to write the same code repeatedly. Instead, both controllers can implement the same interface, &lt;code&gt;UserInterface&lt;/code&gt;, to avoid duplicating the functions. This approach becomes even more important if the application has complex issues, as it makes maintenance and testing easier by keeping the controllers clean and organized through the use of different repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Design patterns are a set of recipes for building maintainable code that makes our code look clean, is reusable and solves complex problems.&lt;br&gt;
In this article we've learned about three of the Laravel design patterns and how we can apply them in real-world examples. To gain a better understanding of them, you must dive deeper and practice more. I hope you found this article useful. &lt;/p&gt;

</description>
      <category>laravel</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Is Gatsby The Future?</title>
      <dc:creator>Simeon</dc:creator>
      <pubDate>Fri, 26 Jan 2024 07:53:12 +0000</pubDate>
      <link>https://forem.com/boma/is-gatsby-the-future-4b7</link>
      <guid>https://forem.com/boma/is-gatsby-the-future-4b7</guid>
      <description>&lt;p&gt;Web developers are creating a plethora of frameworks that allow developers to build websites in our rapidly evolving web society. Despite the increase in the number of frameworks being developed, Gatsby is still a top pick. Gatsby is a contemporary website framework, a static site generator, based on React, Webpack, and GraphQL that fosters the production of static HTML files that are loaded onto a server.&lt;br&gt;
This article will explain to a rookie what Gatsby is and whether it is the future of open-source frameworks.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Gatsby?
&lt;/h2&gt;

&lt;p&gt;Gatsby is an open-source framework based on React that enables developers to build fast, secure, and powerful websites using an innovative &lt;a href="https://www.gatsbyjs.com/docs/reference/graphql-data-layer/"&gt;Gatsby Data layer&lt;/a&gt; that makes integrating different content, APIs, and services into one web experience exceptionally simple. &lt;br&gt;
Simply put Gatsby is a static site generator. Being a static site, it will produce static HTML files that are loaded up on a server unlike how other websites work- where you visit a website and it has to query a database or do some programming on the server to serve your web pages. Gatsby already has all that pre-configured ahead of time and just serves it up. It is important to know that static sites do not connote a non-interactive or non-dynamic site. We can load Javascript into the HTML files that Gatsby serves, make API calls and interactions, and build fast and secure websites even though they're static HTML files served without running programming server-side languages. &lt;br&gt;
As a generator, it is a tool that is run on the server or your local computer to generate content for you, this includes HTML, CSS, Javascript and images, basically everything we need for a website to run. &lt;/p&gt;

&lt;p&gt;Gatsby uses nodeJs. Nodes run in a development environment on your computer, however, the final site when you ship a Gatsby site live will not need nodejs on the server because it is a static site. In other words, as part of its tooling system, Gatsby uses node to help generate the files but the final part doesn't require node to run on the server side.&lt;/p&gt;

&lt;p&gt;Gatsby uses GraphQL to obtain data from anywhere. GraphQL makes API calls simpler and more efficient. We can use markdown files, databases, common CSS, common CMS like &lt;a href="https://www.contentful.com/headless-cms/#:~:text=A%20headless%20CMS%20is%20a,any%20digital%20channel%20you%20choose."&gt;headless cms &lt;/a&gt;and WordPress, and &lt;a href="https://en.m.wikipedia.org/wiki/Comma-separated_values"&gt;CSV file &lt;/a&gt;to get our data into a Gatsby site. It is important to note that Gatsby isn't going to handle our data for us. However, it will get that data pulled into Gatsby and generate the site from the data. &lt;/p&gt;

&lt;p&gt;Gatsby uses React and CSS for templates and the latter, for styling. When Gatsby pulls in our data, React will be in charge of what the &lt;a href="https://reactjsexample.com/tag/templates/"&gt;template&lt;/a&gt; should look like and the styling for CSS, eventually exporting the files into the Gatsby site. &lt;/p&gt;

&lt;p&gt;Gatsby is built with a &lt;a href="https://en.m.wikipedia.org/wiki/Plug-in_(computing)"&gt;plugin&lt;/a&gt; architecture. Interacting with Javascript, CSS, and HTML might get a bit complicated because what we're serving up is a static site. It makes it a seamless process when we pull in complex code into plugins while being able to rely on huge ecosystems of other plugin authors to do some of the heavy-lifting. &lt;/p&gt;

&lt;h3&gt;
  
  
  How can you use Gatsby?
&lt;/h3&gt;

&lt;p&gt;For you to be able to integrate different content, APIs, and services seamlessly into one web experience, you need a unified GraphQL data layer. Gatsby enables you to converge your front end.&lt;br&gt;
You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Source From: Gatsby can pull data from any data source and build pages using just one line of code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build with: You can write your app fast and future Proof with React.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Measure with: Easily drop in third-party analytics to measure important behavior.    &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Some of the practical step-to-step guides&lt;/strong&gt;&lt;br&gt;
We’ll be discussing just 3 of these guides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use Gatsby image&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a Plugin to your site&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy (set up) using the &lt;a href="https://www.gatsbyjs.com/docs/reference/cloud/"&gt;Gatsby cloud&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Gatsby Image&lt;/strong&gt;&lt;br&gt;
 Images and media play a huge role in making websites rich and interactive. It allows you to pull images, videos, GIFs, and other media into your site. Gatsby image optimizes page performance and user experience. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guides&lt;/strong&gt;; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Assets from the filesystem&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gatsby image plugin&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static folder&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Plugins And Themes&lt;/strong&gt;&lt;br&gt;
Gatsby offers a wide range of plug-in functionality, including CMS interfaces and image optimizations. Themes enable the reuse of pages and sections between multiple sites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deploy Using Gatsby cloud&lt;/strong&gt;&lt;br&gt;
Gatsby cloud is the Gatsby team's optimized platform for previewing, building, deploying, and hosting Gatsby sites. Gatsby Cloud interacts with the website-building applications you already use. When you make changes, Gatsby Cloud automatically builds and deploys your site by connecting to the GitHub repository for your Gatsby project. The Gatsby team created Gatsby Cloud to be the quickest way to create and host your website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some of its exceptional features include:
&lt;/h2&gt;

&lt;p&gt;Quick Connect; Using Quick Connect, your CMS's webhooks may be instantly configured.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Preview; By offering a temporary URL that can be shared so that everyone can see changes right away and in context. Preview makes content production and collaboration easier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automated Lighthouse performance checks and deploys previews to fix errors before they’re published.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Free Tier; A Free tier created to accommodate tiny and private sites.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages of  Gatsby
&lt;/h3&gt;

&lt;p&gt;Here are some of the benefits of using Gatsby:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Scale: Gatsby helps deploy and host on Content Delivery Networks, delivering content to visitors faster than traditional servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security: Considering that Gatsby is a static generated site, it has fewer vulnerabilities than traditional websites and rigid platforms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Rich Web Experiences: Gatsby has a unified data layer that enables developers to easily combine data from different sources and render them alongside each other. Consistently add content to your website from sources like Shopify, WordPress, Stripe, and others.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unparalleled speed and responsiveness: Gatsby combines Static site generation, deferred static generation, and intelligent page rendering to selectively preload the content that matters. Provides the user with a blazing-fast website that feels incredibly fast and performant. Gatsby also enhances your Lighthouse score, SEO traffic, and conversations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide Developers With A Fun Experience: To offer an extraordinarily elegant developer experience, Gatsby is built on top of React and incorporates cutting-edge technologies like GraphQL, Webpack, and more. With Gatsby, you can spend more time building your app and less time maintaining and optimizing it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can speed up the development and delivery of websites and apps for your companies with the aid of a wonderful community and a vast ecosystem of plugins, themes, and starter kits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limits of Gatsby
&lt;/h3&gt;

&lt;p&gt;Gatsby has a lot of strengths however, there are some downsides. Therefore, there are some cases when Gatsby is not the best choice. Here are some of that;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Long build time: Since it's a corporate-size webshop, and you have a lot of content, there will be a longer build time. However, the solution to this problem is using the Gatsby cloud but it is not free.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learning a new CMS: This is one of the most significant disadvantages for most companies moving from WordPress to Gatsby. Learning a new CMS is usually hard because it might be unfamiliar to the new user and learning new processes and technologies is one of the flexibility of an organization. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Updating content: If you need to keep updating or amending your content, using Gatsby might take up time because those updates won’t be instantly visible as in, for example, WordPress.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack of plug-and-play functionality: Gatsby is a framework for creating websites and generating code that works with other platforms like content management systems, but it lacks a graphical user interface. &lt;br&gt;
Installing Gatsby and getting started is difficult for non-technical users. Before the website can be used, there must be a lot of planning, designing, and development. Now, a major firm might not have a problem with this, but a small business that is just starting might.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why use Gatsby?
&lt;/h3&gt;

&lt;p&gt;In reference to the advantages stated earlier, these are the core reasons you should use Gatsby. As it provides better speed, security, and improved developer experience. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Speed: One of the benefits of using Gatsby is its speed and performance. Gatsby is going to be way  faster than most of its alternatives such as cached websites using Wordpress. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security: Because of its static nature and just shipping HTML files, this will be innately secure since there won't be any database to hack nor user data to be stored on the server. Even if the site were susceptible to hacking, there wouldn't be as much damage as there would be if they had access to a WordPress site, user data or credit card information. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved developer experience: Having a modern development environment is one vantage of using Gatsby. The tooling is simple and robust, the Languages are modern and apt. Overall it's a nice environment to be working in, that extends into a community that is used by other developers as well. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open-source, free and great documentation: Gatsby is an open-source project, that is people contribute to it to grow. It is also free, has good documentation, and a team of experienced paid people who are available to help the open-source project continue to flourish. With Gatsby, you don't have to worry about a technology that doesn't have long-term support. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Alternatives To Gatsby
&lt;/h3&gt;

&lt;p&gt;If you're considering using Gatsby to build your website, here are some excellent alternatives;&lt;br&gt;
Jamstack Frameworks; such as Jekyll, Next.js, and Nuxt.js.&lt;br&gt;
Traditional content management systems CMS; such as Word press and Drupal. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Gatsby is a static site generator that uses React, NodeJs, GraphQl and a fitting plugin architecture system under the hood to create a seamless and rich website for users. It has a stable and thriving community providing developers with an improved developer experience. However, it has its drawbacks, but this doesn't impede its benefits. It is still a top pick if you want your website to be fast and robust. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Domain Driven Design: Should you apply it?</title>
      <dc:creator>Simeon</dc:creator>
      <pubDate>Fri, 26 Jan 2024 06:57:58 +0000</pubDate>
      <link>https://forem.com/boma/domain-driven-design-should-you-apply-it-570o</link>
      <guid>https://forem.com/boma/domain-driven-design-should-you-apply-it-570o</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;​​Eric Evans introduced the concept of Domain Driven Design (DDD) to the public through his book published in 2003, which is titled "Domain Driven Design: Tackling Complexity in the Heart of Software". Since then, DDD has become a well-known term in the software industry and is regarded as a crucial practice for creating high-quality software.&lt;br&gt;
​​If you are an expert in technology and planning to develop a large, complex business application, DDD is a safe approach to consider. The goal of DDD is to make your software reflect a real-world system or process, and you are required to collaborate closely with a domain expert who understands the workings of the real-world system. However, it's important to keep in mind that DDD may not be necessary for all software projects, and you should only consider it if you recognize the problems it solves. This article will help you determine if you should use it.&lt;br&gt;
​​&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Domain-driven design (DDD)?
&lt;/h2&gt;

&lt;p&gt;​​Domain-Driven Design (DDD) is a method of software design that is centered around the subject or "domain" of the application being developed. For example, if an app is being created for online shopping, the subject area of the app would be the "domain." To manage large domains, the model can be divided into smaller sections known as &lt;a href="https://martinfowler.com/bliki/BoundedContext.html"&gt;"bounded contexts"&lt;/a&gt;. In an organization that deals with food, for example, this could mean separating the sales and delivery departments, each with its own responsibilities and experts. This approach helps to simplify and organize the development process.&lt;br&gt;
​​DDD is an agile method for developing complex software that closely aligns with the business domain. It places a significant focus on communication and collaboration with business domain experts, who can provide insights into how the real-world system works. This approach is mainly applicable to large-scale applications and organizations, but is not suitable for smaller, simpler applications like &lt;a href="https://www.freecodecamp.org/news/crud-operations-explained/#whatisupdateoperationandhowdoesitwork"&gt;CRUD systems&lt;/a&gt;.&lt;br&gt;
​​Effective communication between domain experts and developers is critical for successful collaboration in DDD. The approach uses "ubiquitous language," which means using the same terminology for the real-world concept being modeled, the software equivalent, and any structures that may be used to store the concept. This helps to avoid misunderstandings and inaccuracies, and the concepts described in the ubiquitous language should form the basis for the domain model.&lt;br&gt;
​​&lt;br&gt;
​​&lt;/p&gt;

&lt;h3&gt;
  
  
  Guiding principles of Domain driven design
&lt;/h3&gt;

&lt;p&gt;​​Basically, DDD is about developing software that models real-world systems and processes. The principles guiding the DDD approach include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Focus on the core domain: Before you begin coding, talk to people who work in that domain. They can help you to define all of the processes, procedures, and terminology of that domain. For example, if you are designing software to manage retail inventory, talk to the people who manage the store inventory rather than employees in HR or finance.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By basing designs on domain models, you can reduce complexity: Create a model that reflects the real-world domain once you have a firm understanding of the business domain. Inventory trend analysis, automatic restocking, barcode scanning, and other capabilities that are crucial to inventory managers should be included in your inventory management software. The organization and abstraction of the domain expert's knowledge are represented by the model, which can be a written paragraph, chart, or diagram.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;​​Speak a common language: In his book, Evans talks about the importance of ubiquitous language. All project participants should communicate using a consistent language when discussing the domain. Listen to the words and phrases your domain experts use. Adopt the same terminology in your requirements document, in the model, and in the code itself.&lt;br&gt;
​​&lt;/p&gt;
&lt;h3&gt;
  
  
  Structure of Domain-driven design
&lt;/h3&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Application layer: In our online shopping application example, the business domain here is to process an order. So the customer needs to browse the product, choose an item, confirm the order, pick a shopping fee, and pay. The user interface is where the customer can browse or initiate their order. This layer shows information to the client and interprets their actions. This is the front end of the application and is all the user can see. The application layer leads the user from one UI layer to another and interacts with other application layers. Its purpose is to organize and delegate domain objects to do their job and it's the only layer accessible to other bounded contexts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;​​Domain layer: The domain model layer is the core of business software, where concepts of the business, information about the business situation, and business rules are represented. The state that reflects the business situation is managed here, while the technical aspects of storing it are handed off to the infrastructure. It is the center for expressing the business. These include:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;​​Entities: &lt;a href="https://stackoverflow.com/questions/57367017/the-meaning-of-entity-in-domain-driven-design"&gt;Entities&lt;/a&gt; represent objects by giving them a common identity. Typically, entities are stored in persistence with a key that allows for later retrieval.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://martinfowler.com/bliki/DDD_Aggregate.html"&gt;Aggregates&lt;/a&gt;: These represent groups of objects that should be persisted as a unit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;​​&lt;a href="https://www.dremio.com/wiki/value-object/#:~:text=A%20Value%20Object%20is%20an,concepts%20in%20a%20problem%20domain."&gt;Value objects&lt;/a&gt;: these represent concepts that can be compared on the basis of the sum of their property values. For example, date range consists of a start and end date.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Domain events: represent things happening within the system that are of interest to other parts of the system.&lt;br&gt;
​​The domain layer should encapsulate complex behaviors and not just be a collection of properties. An anemic domain model, lacking behaviors, is not considered desirable in Domain-Driven Design (DDD).&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.&lt;br&gt;
Infrastructure Layer:&lt;br&gt;
​​This layer provides support for communication between other layers and may contain libraries to aid the UI layer.&lt;br&gt;
​​&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the patterns Domain-driven design employs?
&lt;/h3&gt;

&lt;p&gt;​​DDD employs various patterns to structure its design, including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repository Pattern&lt;/strong&gt;&lt;br&gt;
This pattern provides an abstraction for data storage, allowing the application to interact with a simple interface that resembles a collection. Operations such as adding, removing, updating, and retrieving items from the collection are straightforward methods that do not require knowledge of database concerns, like connections, commands, cursors, or readers. The repository pattern promotes loose coupling and can keep domain objects' persistence ignorant. &lt;br&gt;
​​&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Factory Pattern&lt;/strong&gt;&lt;br&gt;
This creational pattern uses factory methods to create objects without specifying their exact class. It encapsulates the complexity of object creation.&lt;/p&gt;

&lt;p&gt;​​&lt;strong&gt;Services&lt;/strong&gt;&lt;br&gt;
Services are used to encapsulate complex behaviors and infrastructure implementation details. According to Eric Evans' definition of a service in his book "Domain-Driven Design," a service is a DDD building component that symbolizes a major process or domain transformation that is not an inherent duty of an entity or value object. Services should be declared as stateless interfaces defined in the language of the model and should have operation names that are part of the ubiquitous language.&lt;br&gt;
​​&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;&lt;br&gt;
This pattern decouples the act of issuing commands and executing the command itself.&lt;br&gt;
​​Specification: DDD uses the Specification pattern to solve the problem of placing querying, sorting, and paging logic. The specification pattern describes a query as an object, allowing for a more flexible and scalable solution.&lt;br&gt;
​​&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics of a good domain model
&lt;/h3&gt;

&lt;h2&gt;
  
  
  ​​
&lt;/h2&gt;

&lt;p&gt;Models the problem domain correctly: A well-crafted domain model accurately represents the problem domain, but it does not have to be a replica of the real world. It should only include relevant information that is necessary to solve the problem at hand, while excluding any unnecessary details. Additionally, the relationships between the entities in the model must be accurate. However, to assess a domain model using these criteria, one must have a good understanding of the problem domain.&lt;br&gt;
​​&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Speaks the right language: It is crucial to use appropriate terminology in a domain model, which is a depiction of a specific problem area. This helps to eliminate confusion and miscommunication between the expert and developer. Proper naming of the elements in the domain model ensures that both parties are on the same page and minimizes the risk of misunderstandings that can compromise the quality of the delivered product. Determining if the domain model meets this requirement is straightforward. If the elements are correctly named, the customer should be able to comprehend the model with ease.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Claims ownership of its information: A Good domain model asserts control over its information. It should have methods for modifying its contents and block any unauthorized changes to the information under its jurisdiction. The use of a single entry point to the information in a domain model offers two key benefits: it eliminates redundant code and ensures the consistency of the domain model. Adhering to this principle leads to clearer and less prone to errors in code, which should be the aim of every software developer.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides built-in support for logging: The domain model should have integrated logging functionality for ease of use. Because it is often useful to include the details of an object in a log message, the domain model should be straightforward to retrieve the information of an entity as a string. This eliminates the need for manual construction of log messages, as all you have to do is attach the relevant object to the log.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Is covered by unit tests: This aspect of having a well-constructed domain model being covered by unit tests is self-evident for experts, but relying on assumptions can be hazardous. I understand that strict guidelines can sometimes be problematic, however, I believe that it is possible to provide a clear rule for unit testing any domain model. The rule is straightforward: test every method that is not a getter or setter.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;​​&lt;br&gt;
​​&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of Domain-driven design
&lt;/h3&gt;

&lt;h2&gt;
  
  
  ​​
&lt;/h2&gt;

&lt;p&gt;Easier communication: Thanks to the ubiquitous language, communication between developers and domain experts are much easier.&lt;br&gt;
​​&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Object-Oriented: As DDD follows an object-oriented approach, the entire domain is based on objects which provide more flexibility, making it easier to modify and improve the system.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cleaner Code: Adopting DDD leads to cleaner, more robust code. By using best practices and design patterns, future projects are likely to run more efficiently.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Emphasizes Domain Over Interface: DDD places a strong emphasis on the domain and takes into consideration the input of domain experts, resulting in applications that accurately reflect the domain and resonate well with its audience. This approach prioritizes the domain over the UI/UX.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;​&lt;/p&gt;

&lt;h3&gt;
  
  
  Disadvantages of Domain-driven design
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;​​Requires Domain Expertise: One of the limitations of DDD is that it requires deep domain knowledge, even for experienced development teams. There needs to be at least one specialist who understands the subject that is the focus of the application.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inappropriate for Highly Technical Projects: While DDD is well-suited for complex business domains and logic, it may not work as effectively in highly technical projects where it is challenging to establish a common language that can be understood by both developers and domain experts.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Emphasizes Iterative Processes: While some may see this as a positive aspect, DDD relies heavily on iterative practices and continuous integration to build a flexible project that can adapt as necessary. This may not be suitable for organizations that are used to less-adaptable development models.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Communication Problems: Communication problems within development teams often stem from misunderstandings of the domain language and ambiguities in the language itself.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;High Cost: To maintain the domain model as a clear and helpful language construct, a lot of isolation and encapsulation must be implemented, which can result in a relatively high cost for a DDD-based system.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;​​###When should you apply Domain-driven design?&lt;br&gt;
​​DDD is appropriate for large applications with significant business complexity and the need for domain expert knowledge. The domain model should have significant behavior that represents business rules and interactions beyond just storing and retrieving records.&lt;br&gt;
​​&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If your system has 25-30 service interfaces, each with multiple methods, it might be considered complex and would benefit from using DDD. If there are 30-40 user stories or use case flows, it could also indicate the need for DDD.&lt;br&gt;
​​&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even if the application does not seem complex now, consider whether it may grow in complexity in the future. If there are indications of moderate complexity, it may be best to assume it will be more complex and use DDD. Working through complex usage scenarios with domain experts can help determine the level of complexity. If domain experts are already asking for more complex features, it may indicate that the application is or will soon become too complex to use a CRUD approach.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;​​If the domain is new and unknown to you and your team, it is likely to be complex and DDD is recommended. You will need to work with domain experts and experiment with models to determine the complexity level.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;​​&lt;/p&gt;

&lt;h3&gt;
  
  
  When shouldn't you apply Domain-driven design?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;​​The practice of Domain-Driven Design (DDD) involves significant investments in modeling, architecture, and communication, which may not be necessary for smaller or CRUD (create, read, update, delete) applications. If you follow DDD, but find that your domain model lacks behavior, it's possible that DDD is not required for your application or you may need to refactor it to include business logic in the domain model, instead of the database or user interface.&lt;br&gt;
​​A practical approach would be to use DDD only for complex or transactional parts of the application and not for the simpler CRUD or read-only parts. For example, there's no need for Aggregate constraints when querying data for a report or dashboard. In such cases, a separate, simpler read model is sufficient.&lt;br&gt;
​​&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If your system requires less than 30 business operations, it is likely to be straightforward. This would mean that your application would have a maximum of 30 user stories or use case flows, each with minimal business logic. If you can easily develop such an application using frameworks such as Ruby on Rails or Groovy and Grails without struggling with complexity and change, then DDD is probably not necessary for your system.&lt;br&gt;
​​&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;​​&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
​​In this article we have discussed when and when not to employ Domain driven designs. For example we shouldn't use DDD when we want to develop a simple app that uses the CRUD(create, read, update and delete) system and use it for large applications with business complexity. If your organization wants to develop software that seamlessly integrates with the business domain, you may want to consider implementing DDD. I hope you found this article beneficial. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>learning</category>
      <category>ddd</category>
    </item>
  </channel>
</rss>
