<?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: Ridwan Abiola</title>
    <description>The latest articles on DEV Community by Ridwan Abiola (@abuhasib).</description>
    <link>https://dev.to/abuhasib</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%2F84584%2F918b1351-f5fd-46c9-9075-fa9920ae2146.jpeg</url>
      <title>DEV Community: Ridwan Abiola</title>
      <link>https://dev.to/abuhasib</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abuhasib"/>
    <language>en</language>
    <item>
      <title>Software Design Principle: Inversion of Control(IOC) and Dependency Injection</title>
      <dc:creator>Ridwan Abiola</dc:creator>
      <pubDate>Fri, 26 Apr 2024 09:51:29 +0000</pubDate>
      <link>https://dev.to/abuhasib/software-design-principle-inversion-of-controlioc-and-dependency-injection-5e5l</link>
      <guid>https://dev.to/abuhasib/software-design-principle-inversion-of-controlioc-and-dependency-injection-5e5l</guid>
      <description>&lt;p&gt;Software engineering is an established discipline within the broader field of Computer Science. It is a discipline that has made great strides and impressive breakthroughs. Strides relating to powering spacecraft, advances in computer hardware, creating billion-dollar products and platforms, and more recently breakthroughs in AI. &lt;/p&gt;

&lt;p&gt;It has also granted individuals skilled in the software-making craft a means to taste freedom from remote work, make a global impact, experience great career opportunities, and more. &lt;/p&gt;

&lt;p&gt;Coming into software, some things we hear a lot are the sayings: "Do not reinvent the wheel" and "Standing on the shoulders of giants". These sayings aren't mere statements, they are enduring principles that have stood the test of time. &lt;/p&gt;

&lt;p&gt;Software engineering has numerous principles that help make your code maintainable and easy to test. Some popular ones include Separation of Concerns, KISS, SOLID, and Design Patterns. There are also less popular ones and controversial ones as well. Some are now being regarded as bad practices. Though there are a lot, the rest of this article will zoom in on the &lt;strong&gt;Inversion of Control&lt;/strong&gt;, one of the popular ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inversion of Control
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Inversion of Control&lt;/strong&gt; is a software engineering principle that discourages a Developer from creating the object and dependencies his program needs to run directly. Rather he outsources it to a framework or an external entity. Inversion of control (IoC) is where control is inverted, rather than the programmer controls the flow of the program, the framework takes control instead.&lt;/p&gt;

&lt;p&gt;In procedural programming, a program's custom code calls reusable libraries to take care of generic tasks, but with inversion of control, it is a framework that calls the custom code. The principle is popular with Java's Spring framework and Javascript's Angular. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Dependency Injection&lt;/strong&gt; is related to the Inversion of Control in the sense that it is the pattern through which Inversion of Control is achieved. In DI, instead of a &lt;code&gt;Class&lt;/code&gt; creating its dependencies, the dependencies are provided to the class from the outside. This helps to decouple &lt;strong&gt;classes&lt;/strong&gt; and make them more testable, maintainable, and flexible.&lt;/p&gt;

&lt;p&gt;There are three common types of dependency injection:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Constructor Injection&lt;/strong&gt;: Dependencies are provided to a class through its constructor. It is the most common form of DI and ensures a &lt;strong&gt;Class&lt;/strong&gt; has all its dependencies when created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;MyDependency&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;MyClass&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MyDependency&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dependency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Class methods using the dependency&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Setter Injection&lt;/strong&gt;: Dependencies are provided to a class through setter methods. This allows for more flexibility, as dependencies can be changed after the class is created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;MyDependency&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setDependency&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MyDependency&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dependency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Class methods using the dependency&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Method Injection&lt;/strong&gt;: Dependencies are provided to individual methods when called. This is less common than constructor or setter injection and is often used in specific cases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MyDependency&lt;/span&gt; &lt;span class="n"&gt;dependency&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Method logic using the dependency&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is also the case in Javascript's Angular, DI is a core concept used to provide services, components, and other objects to classes that need them. Angular's DI system is built into the framework and is used extensively throughout Angular applications. Below is a simple example to demonstrate how dependency injection works in Angular:&lt;/p&gt;

&lt;p&gt;First, we create a service that we'd like to inject into a component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// my.service.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Injectable&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Injectable&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;providedIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello from MyService!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we create a component that will consume the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// my.component.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MyService&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./my.service&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-my&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
    &amp;lt;h1&amp;gt;{{ message }}&amp;lt;/h1&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;myService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;MyService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, the &lt;code&gt;MyComponent&lt;/code&gt; class has a &lt;code&gt;constructor&lt;/code&gt; parameter of type &lt;code&gt;MyService&lt;/code&gt;. Angular's DI system will automatically inject an instance of &lt;code&gt;MyService&lt;/code&gt; into the &lt;code&gt;MyComponent&lt;/code&gt; class when created.&lt;/p&gt;

&lt;p&gt;Finally, we add &lt;code&gt;MyService&lt;/code&gt; and &lt;code&gt;MyComponent&lt;/code&gt; to the list of providers in the Angular module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.module.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NgModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BrowserModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/platform-browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./my.component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MyService&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./my.service&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BrowserModule&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;MyService&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;MyService&lt;/code&gt; is provided at the root level, meaning a single instance of &lt;code&gt;MyService&lt;/code&gt; is shared across the entire application. This allows flexibility in making future changes as the components are loosely coupled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Advantages
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;There is loose coupling between components &lt;/li&gt;
&lt;li&gt;You can easily change dependencies without compromising on quality.&lt;/li&gt;
&lt;li&gt;You can leverage code usability and achieve System stability.&lt;/li&gt;
&lt;li&gt;Minimal code to maintain.&lt;/li&gt;
&lt;li&gt;You can easily replace components without affecting others.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, we discussed &lt;strong&gt;SE&lt;/strong&gt; principles and why they are necessary. We focused on &lt;strong&gt;IoC&lt;/strong&gt; and &lt;strong&gt;DI&lt;/strong&gt;, a design pattern through which &lt;strong&gt;IoC&lt;/strong&gt; is achieved. We also mentioned the different types of DI using code samples where appropriate. We mentioned some advantages of IoC and DI. Finally, &lt;strong&gt;DI&lt;/strong&gt; is a powerful design pattern that makes managing complex dependencies in large applications easier.&lt;/p&gt;

&lt;p&gt;Thanks for reading, you can follow me on &lt;a href="https://www.linkedin.com/in/ridwan-abiola/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>angular</category>
      <category>software</category>
      <category>ai</category>
    </item>
    <item>
      <title>Java's own EJB and Spring Framework</title>
      <dc:creator>Ridwan Abiola</dc:creator>
      <pubDate>Sat, 13 Apr 2024 22:38:29 +0000</pubDate>
      <link>https://dev.to/abuhasib/javas-own-ejb-and-spring-framework-2gn9</link>
      <guid>https://dev.to/abuhasib/javas-own-ejb-and-spring-framework-2gn9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2ak5yzmj2zql1tu3bg7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2ak5yzmj2zql1tu3bg7.jpg" alt="A hat hanging on a pole" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
In the world of Java, there are a lot of possibilities. Those possibilities range from game development to cloud-based applications, server-side apps, Internet of Things, Machine learning, and more.&lt;/p&gt;

&lt;p&gt;Especially in the world of server-side enterprise application development, Java provides a lot of options. Enterprise Java Beans was an early technology designed to make server-side development easier in Java. It could handle transaction processing, persistence, security, and more. However, EJBs were somehow cumbersome due to the amount of configuration required.&lt;/p&gt;

&lt;p&gt;Around 2002 Spring was created as an alternative to EJBs and its heavy-weight containers, it also supports auto-configuration. It is a highly flexible framework used mainly for building Java web applications. In addition, Spring makes programming Java quicker, easier, and safer for everybody. Its focus on speed, simplicity, and productivity has made it the world's most popular Java framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  The issues on ground
&lt;/h2&gt;

&lt;p&gt;EJB had several issues that made it challenging to work with. Some of the key issues include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Complexity: EJBs were often criticized for their complexity, especially in earlier versions. Developing and deploying EJBs required dealing with a lot of configuration and boilerplate code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performance: EJBs were known to have performance issues, especially due to their remote method invocation (RMI) mechanism. This was due to the overhead of serialization/deserialization and network communication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transaction Management: EJB's container-managed transactions (CMT) could be restrictive and cumbersome to configure, leading to performance and maintenance issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: EJBs were seen as not very scalable, especially concerning their heavy use of server-side resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complex Deployment: Deploying EJBs required deploying them to an application server, which could be complex and time-consuming compared to simpler deployment mechanisms.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spring resolves these issues by making things simpler, quicker, and better. Spring is also open source with a large community backing making it easier to ask for help.&lt;/p&gt;

&lt;h2&gt;
  
  
  How popular is the Spring framework
&lt;/h2&gt;

&lt;p&gt;In 2024, it is to be noted that Spring is a top choice still among software developers. And one thing that has kept its appeal is the addition of the latest useful feature that improves the developer experience. According to &lt;a href="https://www.jetbrains.com/lp/devecosystem-2023/java/"&gt;Jet Brains' 2033 Developer Ecosystem survey&lt;/a&gt;, Spring Boot leads followed by Spring MVC. This is also the case with &lt;a href="https://www.continuum.be/en/blog/java-ecosystem-survey-2023/"&gt;Continuum's Java Ecosystem 2023 Survey Results&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Finally, Spring's simplicity, flexibility, testing support, lack of vendor lock-in, integration capabilities, and community support make it a preferred choice for many developers over EJB.&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>Using LESS in your Angular 9 Project</title>
      <dc:creator>Ridwan Abiola</dc:creator>
      <pubDate>Wed, 17 Jun 2020 22:37:32 +0000</pubDate>
      <link>https://dev.to/abuhasib/using-less-in-your-angular-9-project-5h0f</link>
      <guid>https://dev.to/abuhasib/using-less-in-your-angular-9-project-5h0f</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

ng new my-app


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

&lt;/div&gt;

&lt;p&gt;Running the above angular cli command will give you a shiny brand new workspace and app. Chances are you may mistakenly or hastily select the defaults when prompted for information about features to include in the initial app.&lt;/p&gt;

&lt;p&gt;It is all cool if you are a master CSS bender and manipulator but let's face it, down the road when your projects get larger you tend to get exhausted writing vanilla CSS (if that's a thing).&lt;/p&gt;

&lt;h2&gt;
  
  
  Re-introducing: CSS Preprocessors
&lt;/h2&gt;

&lt;p&gt;CSS preprocessor takes the work out of writing your styles (well almost). It gives you features like variables, nesting, escaping, imports, mixins and so much more. &lt;a href="http://lesscss.org/" rel="noopener noreferrer"&gt;Less&lt;/a&gt; is an example of this. It gives you a cleaner and efficient way of styling components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Now: Putting LESS in Angular
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;

ng config schematics.@schematics/angular:component.styleext less


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

&lt;/div&gt;

&lt;p&gt;Running the above instructs Angular to use less as the default stylesheet format. &lt;/p&gt;

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

"schematics": {
    "@schematics/angular:component": {
      "style": "less"
    }
  }


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

&lt;/div&gt;

&lt;p&gt;You should see the above changes to &lt;code&gt;angular.json&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next: Changing all occurrences
&lt;/h2&gt;

&lt;p&gt;VSCode has a neat feature to change all occurrences at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff5ktja0juiekv3n3f8gl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff5ktja0juiekv3n3f8gl.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Here we go again
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

ERROR &lt;span class="k"&gt;in&lt;/span&gt; ./src/app/app.component.ts
Module not found: Error: Can&lt;span class="s1"&gt;'t resolve '&lt;/span&gt;./app.component.less&lt;span class="s1"&gt;' in '&lt;/span&gt;/Users/tbo/my-app/src/app&lt;span class="s1"&gt;'
ERROR in ./src/app/dashboard/dashboard.component.ts
Module not found: Error: Can'&lt;/span&gt;t resolve &lt;span class="s1"&gt;'./dashboard.component.less'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s1"&gt;'/Users/tbo/my-app/src/app/dashboard'&lt;/span&gt;
ERROR &lt;span class="k"&gt;in&lt;/span&gt; ./src/app/home/home.component.ts
Module not found: Error: Can&lt;span class="s1"&gt;'t resolve '&lt;/span&gt;./home.component.less&lt;span class="s1"&gt;' in '&lt;/span&gt;/Users/tbo/my-app/src/app/home&lt;span class="s1"&gt;'
ERROR in ./src/app/landing/landing.component.ts
Module not found: Error: Can'&lt;/span&gt;t resolve &lt;span class="s1"&gt;'./landing.component.less'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s1"&gt;'/Users/tbo/my-app/src/app/landing'&lt;/span&gt;
ERROR &lt;span class="k"&gt;in&lt;/span&gt; ./src/app/profile/profile.component.ts
Module not found: Error: Can&lt;span class="s1"&gt;'t resolve '&lt;/span&gt;./profile.component.less&lt;span class="s1"&gt;' in '&lt;/span&gt;/Users/tbo/my-app/src/app/profile&lt;span class="s1"&gt;'


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

&lt;/div&gt;

&lt;p&gt;Angular complains of not finding the module which makes sense since we changed all references but the file name remain unchanged.&lt;/p&gt;

&lt;p&gt;This &lt;a href="https://stackoverflow.com/a/27285610/11074007" rel="noopener noreferrer"&gt;stack overflow answer&lt;/a&gt; shows you how to rename bunch of files extensions. Just so we are clear make sure you in the &lt;code&gt;src&lt;/code&gt; folder when running the command. You can thank me later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;Since all that is out of the way. Now you can do:&lt;/p&gt;

&lt;h3&gt;
  
  
  This:
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="k"&gt;@width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;#header&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  This:
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.bordered&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dotted&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



&lt;span class="nf"&gt;#menu&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;.bordered();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.post&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;.bordered();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  And that:
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nf"&gt;#header&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;.navigation&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.logo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Ha! Exciting times to be a developer.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Keeping up with Ruby</title>
      <dc:creator>Ridwan Abiola</dc:creator>
      <pubDate>Sun, 10 Nov 2019 00:33:16 +0000</pubDate>
      <link>https://dev.to/abuhasib/keeping-up-with-ruby-1lho</link>
      <guid>https://dev.to/abuhasib/keeping-up-with-ruby-1lho</guid>
      <description>&lt;p&gt;Ha Ruby! some real gem there, believe me. My first impressions checking through the docs, when first starting out was: "This looks like C (now I know better, it doesn't)". Little do I know am going to be writing a post about it some few odd months after.&lt;/p&gt;

&lt;p&gt;So what made me hooked enough to want to explore the language more? Well am not yet sure but i will tell you something along the lines of: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's syntax&lt;/li&gt;
&lt;li&gt;Visual Appearance (makes a case for clear code out of the box)&lt;/li&gt;
&lt;li&gt;Flexibility&lt;/li&gt;
&lt;li&gt;Modules&lt;/li&gt;
&lt;li&gt;Exception Handling&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Best parts for me so far
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hashes
&lt;/h3&gt;

&lt;p&gt;This will be equivalent of "Objects Literals" in JavaScript. Key/value pairs, two way binding, linked(you get the picture), they differ from Arrays in the sense that whereas Arrays are like lists, they are like dictionaries.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create 'em:
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="n"&gt;example_hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"one"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"okan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"two"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eeji"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"three"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"eeta"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Use 'em
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;example_hash&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"one"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; okan&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Love 'em
&lt;/h4&gt;

&lt;p&gt;Read more about &lt;a href="https://ruby-doc.org/core-2.6.5/Hash.html"&gt;Hashes&lt;/a&gt; from the docs&lt;/p&gt;

&lt;h3&gt;
  
  
  Modules
&lt;/h3&gt;

&lt;p&gt;Modules is a way of classifying methods and constants, watch the word "classify", even though similar (well kind of) to classes yet modules cannot be instantiated (objects cannot be created out of it) and the keyword "new" does not work on it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create 'em
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;Alifabeti&lt;/span&gt;
  &lt;span class="no"&gt;CONST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Use 'em
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;Alifabeti&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;oro?&lt;/span&gt;
    &lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Ede&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Alifabeti&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;ede_yooba&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Ede&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;
&lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;ede_yooba&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;oro?&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; true&lt;/span&gt;

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



&lt;h4&gt;
  
  
  Love 'em
&lt;/h4&gt;

&lt;p&gt;Read more about &lt;a href="https://ruby-doc.org/core-2.6.5/Module.html"&gt;Modules&lt;/a&gt; from the docs&lt;/p&gt;

&lt;h4&gt;
  
  
  Symbols
&lt;/h4&gt;

&lt;p&gt;Symbols represents code in your code (am confused as well) rather than string. It is a unique identifier for piece of data you need in your code. Even though it is like a string, it is not  a string (i think an example will do a better job than am trying to do right now).&lt;/p&gt;

&lt;h4&gt;
  
  
  Create 'em
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;apamo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;:faweli&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Use 'em
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="n"&gt;apamo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object_id&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; 1928988&lt;/span&gt;
  &lt;span class="n"&gt;apamo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object_id&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; 1928988&lt;/span&gt;
  &lt;span class="n"&gt;apamo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object_id&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; 1928988   &lt;/span&gt;

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



&lt;p&gt;Did you notice it returned the same "object_id" for the that same symbol, Ruby only uses one object to represent all those symbols. And perhaps that's one of the obvious difference between symbols and string, for each time you use the same string in your code, it will create a new object each time. &lt;/p&gt;

&lt;h4&gt;
  
  
  Love 'em
&lt;/h4&gt;

&lt;p&gt;Read more about &lt;a href="https://ruby-doc.org/core-2.6.5/Symbol.html"&gt;Symbols&lt;/a&gt; from the docs&lt;/p&gt;

&lt;p&gt;So there you have it, well am still exploring the language and hope to keep this going as a serial kinda thing, thanks for reading.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>code</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
