<?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: Branch</title>
    <description>The latest articles on DEV Community by Branch (@branch).</description>
    <link>https://dev.to/branch</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%2F943114%2F34fb12dc-046e-43a1-9203-5173c8b1862e.png</url>
      <title>DEV Community: Branch</title>
      <link>https://dev.to/branch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/branch"/>
    <language>en</language>
    <item>
      <title>Dependency Injection for JavaScript Developers</title>
      <dc:creator>Branch</dc:creator>
      <pubDate>Mon, 16 Jan 2023 21:05:54 +0000</pubDate>
      <link>https://dev.to/branch/dependency-injection-for-javascript-developers-5e3l</link>
      <guid>https://dev.to/branch/dependency-injection-for-javascript-developers-5e3l</guid>
      <description>&lt;p&gt;Have you got any experience in Angular or Spring?&lt;br&gt;
Are you familiar with Angular or Spring?&lt;br&gt;
If not, don't worry.&lt;br&gt;
Here in this blog, I am here with you to let you feel more confident about DI.&lt;/p&gt;

&lt;p&gt;In this article, you’ll learn what dependency injection is, when you should use it, and what popular JavaScript frameworks it’s implemented in.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is dependency injection?
&lt;/h2&gt;

&lt;p&gt;First, you have to understand what the dependency is.&lt;br&gt;
It's not you can see in the dependency of package.json.&lt;/p&gt;

&lt;p&gt;I am sure you don't have any conflicts about that.&lt;br&gt;
It's just the case from my friend.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;p&gt;So before getting to dependency injections, first let’s understand what a dependency in programming means.&lt;/p&gt;

&lt;p&gt;When class A uses some functionality of class B, then its said that class A has a dependency of class B.&lt;/p&gt;

&lt;p&gt;In Java, before we can use methods of other classes, we first need to create the object of that class (i.e. class A needs to create an instance of class B).&lt;/p&gt;

&lt;p&gt;So, transferring the task of creating the object to someone else and directly using the dependency is called dependency injection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffx2tivtevcxci89r4fk3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffx2tivtevcxci89r4fk3.png" alt="Dependency Injection in humor" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why do we need dependency injection?
&lt;/h2&gt;

&lt;p&gt;Here, I prepared 2 examples to let you have clear understanding of DI.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 1
&lt;/h3&gt;

&lt;p&gt;Let’s say we have a car class which contains various objects such as wheels, engine, etc.&lt;/p&gt;

&lt;p&gt;Here the car class is responsible for creating all the dependency objects. Now, what if we decide to ditch MRFWheels in the future and want to use Yokohama Wheels?&lt;/p&gt;

&lt;p&gt;We will need to recreate the car object with a new Yokohama dependency. But when using dependency injection (DI), we can change the Wheels at runtime (because dependencies can be injected at runtime rather than at compile time).&lt;/p&gt;

&lt;p&gt;You can think of DI as the middleman in our code who does all the work of creating the preferred wheels object and providing it to the Car class.&lt;/p&gt;

&lt;p&gt;It makes our Car class independent from creating the objects of Wheels, Battery, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 2
&lt;/h3&gt;

&lt;p&gt;For instance, consider how video game consoles only need a compatible disc or cartridge to function. Different discs or cartridges usually contain information about different games. The gamer doesn’t need to know anything about the console’s internals and usually doesn’t do anything other than insert or replace game discs in order to play a game.&lt;/p&gt;

&lt;p&gt;Try to represent a console’s functionality with code. In this example, you’ll call your console the NoSleepStation, and you’ll work with the following assumptions:&lt;/p&gt;

&lt;p&gt;A NoSleepStation console can only play games designed for the NoSleepStation.&lt;br&gt;
The only valid input source for the console is a compact disc.&lt;br&gt;
With this information, one could implement the NoSleepStation console in the following way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The GameReader class
class GameReader {
  constructor(input) {
    this.input = input;
  }
  readDisc() {
    console.log("Now playing: ", this.input);
  }
}

// The NoSleepStation Console class
class NSSConsole {
  gameReader = new GameReader("TurboCars Racer");

  play() {
    this.gameReader.readDisc();
  }
}

// use the classes above to play 
const nssConsole = new NSSConsole();
nssConsole.play();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the core console logic is in the &lt;code&gt;GameReader&lt;/code&gt; class, and it has a dependent, the &lt;code&gt;NSSConsole&lt;/code&gt;. The console’s &lt;code&gt;play&lt;/code&gt; method launches a game using a &lt;code&gt;GameReader&lt;/code&gt; instance. However, a few problems are evident here, including flexibility and testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flexibility
&lt;/h2&gt;

&lt;p&gt;The previously mentioned code is inflexible. If a user wanted to play a different game, they would have to modify the &lt;code&gt;NSSConsole&lt;/code&gt; class, which is similar to taking apart the console in real life. This is because a core dependency, the &lt;code&gt;GameReader&lt;/code&gt; class, is hard coded into the &lt;code&gt;NSSConsole&lt;/code&gt; implementation.&lt;/p&gt;

&lt;p&gt;Dependency injection addresses this problem by decoupling classes from their dependencies, only providing these dependencies when they are needed. In the previous code sample, all that the &lt;code&gt;NSSConsole&lt;/code&gt; class really needs is the &lt;code&gt;readDisc()&lt;/code&gt; method from a &lt;code&gt;GameReader&lt;/code&gt; instance.&lt;/p&gt;

&lt;p&gt;With dependency injection, the previous code can be rewritten like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class GameReader {
  constructor(input) {
    this.input = input;
  }

  readDisc() {
    console.log("Now playing: ", this.input);
  }

  changeDisc(input) {
    this.input = input;
    this.readDisc();
  }
}

class NSSConsole {
  constructor(gameReader) {
    this.gameReader = gameReader;
  }

  play() {
    this.gameReader.readDisc();
  }

  playAnotherTitle(input) {
    this.gameReader.changeDisc(input);
  }
}

const gameReader = new GameReader("TurboCars Racer");
const nssConsole = new NSSConsole(gameReader);

nssConsole.play();
nssConsole.playAnotherTitle("TurboCars Racer 2");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most important change in this code is that the &lt;code&gt;NSSConsole&lt;/code&gt; and &lt;code&gt;GameReader&lt;/code&gt; classes have been decoupled. While an &lt;code&gt;NSSConsole&lt;/code&gt; still needs a &lt;code&gt;GameReader&lt;/code&gt; instance to function, it doesn’t have to explicitly create one. The task of creating the &lt;code&gt;GameReader&lt;/code&gt; instance and passing it to the &lt;code&gt;NSSConsole&lt;/code&gt; is left to the dependency injection provider.&lt;/p&gt;

&lt;p&gt;In a large codebase, this can significantly help to reduce code boilerplate since the work of creating and wiring up dependencies is handled by a dependency injection provider. This means you don’t need to worry about creating instances of the classes that a certain class needs, especially if those dependencies have their own dependencies.&lt;/p&gt;

&lt;p&gt;So I hope you get a little understanding why dependency injection is important.&lt;/p&gt;

&lt;p&gt;But there is nothing perfect.&lt;/p&gt;

&lt;p&gt;Let's see what could be cons of DI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons of Dependency Injection.
&lt;/h2&gt;

&lt;p&gt;It’s important to note that using dependency injection is not without its disadvantages, which are usually related to how dependency injection attempts to solve the problem of reducing code boilerplate.&lt;/p&gt;

&lt;p&gt;In order to get the most from dependency injection, especially in a large codebase, a dependency injection provider has to be set up. Setting up this provider can be a lot of work and is sometimes unnecessary overhead in a simple project.&lt;/p&gt;

&lt;p&gt;This problem can be solved by using a dependency injection library or framework. However, using a dependency injection framework requires a total buy-in in most cases, as there aren’t many API similarities between different dependency injection frameworks during configuration.&lt;/p&gt;

&lt;p&gt;So here, I will finish the first part of my blog about DI.&lt;br&gt;
Thank you all and wait for my next blog which will cover about dependency injection in popular Javascript frameworks and Javascript dependency injection frameworks.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Effective &amp; Productive Management Way = Agile (Part 1 - Basics of Agile)</title>
      <dc:creator>Branch</dc:creator>
      <pubDate>Thu, 01 Dec 2022 20:11:06 +0000</pubDate>
      <link>https://dev.to/branch/effective-productive-management-way-agile-part-1-basics-of-agile-12ok</link>
      <guid>https://dev.to/branch/effective-productive-management-way-agile-part-1-basics-of-agile-12ok</guid>
      <description>&lt;p&gt;Nowadays, more and more companies are starting to use Agile.&lt;br&gt;
I am sure, there are no Senior Engineers who are not familiar with Agile methodologies.&lt;br&gt;
So I am going to explain the basics of Agile and why we use Agile over traditional methodologies.&lt;/p&gt;

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

&lt;p&gt;Agile is an iterative approach to project management and software development that helps teams deliver value to their customers faster and with fewer headaches. Instead of betting everything on a "big bang" launch, an agile team delivers work in small, but consumable, increments. Requirements, plans, and results are evaluated continuously so teams have a natural mechanism for responding to change quickly.&lt;/p&gt;

&lt;p&gt;Aren't you familiar with definitions?&lt;br&gt;
Let's take this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vz9in31g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7obcd0tnb07c6sa310w6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vz9in31g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7obcd0tnb07c6sa310w6.png" alt="Image description" width="500" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Funny?&lt;/p&gt;

&lt;p&gt;If you build and launch the new type of car named "WaterFall" with lots of money, but customers really don't like that.&lt;br&gt;
You lost money and will be fired.&lt;/p&gt;

&lt;p&gt;Let's change the name of the car from "WaterFall" to "Agile".&lt;br&gt;
You started to build from something small and basics, added features to the basics.&lt;br&gt;
With this approach, you can avoid unnecessary money lost and great failure!.&lt;/p&gt;

&lt;p&gt;It is more likely to idiot story but I hope you get some understanding of Agile now.&lt;br&gt;
Let's dive into the next part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we use Agile?
&lt;/h2&gt;

&lt;p&gt;If you understand the main purpose of figure correctly, you can get the main point why we use Agile.&lt;br&gt;
Let's get in a more professional way.&lt;/p&gt;

&lt;p&gt;Why do we use Agile?&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Revenue
&lt;/h3&gt;

&lt;p&gt;The iterative nature of agile development means features are delivered incrementally, enabling some benefits to be realized early as the product continues to develop.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Quality
&lt;/h3&gt;

&lt;p&gt;A key principle of agile development is that testing is integrated throughout the lifecycle, enabling regular inspection of the working product as it develops. This allows the product owner to make adjustments if necessary and gives the product team early sight of any quality issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Risk Management
&lt;/h3&gt;

&lt;p&gt;Small incremental releases made visible to the product owner and product team through its development help to identify any issues early and make it easier to respond to change. The clear visibility in agile development helps to ensure that any necessary decisions can be taken at the earliest possible opportunity, while there’s still time to make a material difference to the outcome.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Agility
&lt;/h3&gt;

&lt;p&gt;In traditional development projects, we write a big spec up-front and then tell business owners how expensive it is to change anything, particularly as the project goes on. In fear of scope creep and a never-ending project, we resist changes and put people through a change control committee to keep them to the essential minimum. Agile development principles are different. In agile development, change is accepted. In fact, it’s expected. Because the one thing that’s certain in life is change. Instead the timescale is fixed and requirements emerge and evolve as the product is developed. Of course for this to work, it’s imperative to have an actively involved stakeholder who understands this concept and makes the necessary trade-off decisions, trading existing scope for new.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Business Engagement/Customer Satisfaction
&lt;/h3&gt;

&lt;p&gt;The active involvement of a user representative and/or product owner, the high visibility of the product and progress, and the flexibility to change when change is needed, create much better business engagement and customer satisfaction. This is an important benefit that can create much more positive and enduring working relationships.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is Agile good in the real world?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;86% of software development teams have fully adopted the Agile approach. &lt;/li&gt;
&lt;li&gt;At least 71% of U.S. companies are now using Agile.&lt;/li&gt;
&lt;li&gt;Agile projects have a 65% success rate, whereas projects under the competing methodology known as waterfall only have a 50% success rate.&lt;/li&gt;
&lt;li&gt;After adopting Agile, companies have experienced an average 60% growth in revenue and profit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will cover how to use Agile in software development in more detail in the next part.&lt;/p&gt;

</description>
      <category>agile</category>
    </item>
  </channel>
</rss>
