<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Büşra Tanrıverdi on Medium]]></title>
        <description><![CDATA[Stories by Büşra Tanrıverdi on Medium]]></description>
        <link>https://medium.com/@busratanriverdi?source=rss-b4321869bbca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1skmUzvGnwe7yA99GokjAw.jpeg</url>
            <title>Stories by Büşra Tanrıverdi on Medium</title>
            <link>https://medium.com/@busratanriverdi?source=rss-b4321869bbca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:41:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@busratanriverdi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Embracing Complexity in Software Development: A Deep Dive into Domain-Driven Design]]></title>
            <link>https://medium.com/@busratanriverdi/embracing-complexity-in-software-development-a-deep-dive-into-domain-driven-design-aa38d338b7bb?source=rss-b4321869bbca------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa38d338b7bb</guid>
            <category><![CDATA[domain-services]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[ubiquitous-language]]></category>
            <category><![CDATA[domain-events]]></category>
            <dc:creator><![CDATA[Büşra Tanrıverdi]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 08:35:38 GMT</pubDate>
            <atom:updated>2024-02-03T09:38:11.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Here is an image representing the essence of Domain-Driven Design in this article. It depicts a group of professionals engaged in a collaborative discussion, including software developers and business domain experts. The surrounding digital screens display graphs, flowcharts, and code snippets, symbolizing the integration of software design with business needs. This scene captures the blend of technology and business essential to Domain-Driven Design." src="https://cdn-images-1.medium.com/max/1024/1*1PrPZh2XTmi1JujqsBCmMA.jpeg" /><figcaption>This picture depicts a group of professionals engaged in a collaborative discussion, including software developers and business domain experts.</figcaption></figure><p><strong>Introduction</strong></p><p>In the dynamic world of software development, building flexible and robust systems is a significant challenge. Eric Evans introduced the Domain-Driven Design (DDD) approach to address this challenge, which provides a comprehensive solution. DDD aligns software design with the business domain, ensuring the developed solutions are technically sound and deeply integrated with business needs and logic. This approach offers businesses a dependable framework to develop their systems while streamlining their processes. This article provides an in-depth exploration of DDD for software development, focusing on its core principles and methodologies. We will cover the fundamental concepts of DDD, including the importance of a ubiquitous language, entities, value objects, aggregates, domain events, and domain services. Additionally, we will delve into strategic design with bounded contexts and tactical design with implementation. By understanding DDD’s technical aspects, we can easily navigate the complexities of modern business software development. Through DDD, we can ensure technical robustness in software systems and closely align them with evolving business needs. This article presents a perspective on building adaptable and resilient software systems.</p><h4><strong>The Essence of Domain-Driven Design</strong></h4><p>Domain-driven design (DDD) is an approach that emphasizes the importance of comprehending and representing the business domain in software development. It involves a collaborative effort between domain experts and developers to create a shared model that accurately captures the intricacies and subtleties of the business context. The approach is designed to tackle the challenges of complex and demanding business environments, where the software system should be aligned with the business objectives.</p><h4>Ubiquitous Language: Bridging Business and Technology</h4><p>A project’s success heavily relies on effective communication between technical and non-technical stakeholders. However, this can be challenging when language barriers exist. This is where DDD comes in. DDD suggests using shared terminology, the ubiquitous language, to bridge the gap between technical jargon and business language. This language should be consistently used throughout the project in documentation and code, ensuring clarity and reducing misunderstandings. By aligning the domain model with the business, a better understanding of the problem can be achieved.</p><p>To ensure effective communication, the ubiquitous language should spread to all project team members rather than being limited to domain experts and developers. Despite extensive knowledge in their respective fields, domain experts and software developers may need a mutual understanding of professions. By adopting a common language, communication can be streamlined, and the project can benefit from a shared understanding of key concepts and objectives. In summary, using ubiquitous language is paramount in facilitating effective communication between technical and non-technical stakeholders, ensuring the success of any project.</p><blockquote>How can we effectively incorporate the DDD into our codebase to ensure an accurate structure?</blockquote><p><strong>1. Collaborate with Domain Experts and Ubiquitous Language: </strong>Use the same terminology in your code used in discussions with domain experts. Using the same terminology in your code used in discussions with domain experts is essential. For instance, if your domain experts use a specific term, such as “<strong>Customer</strong>,” make sure to use the same term in your code instead of using generic terms like “<strong>User</strong>” or “<strong>Client</strong>.” This practice ensures that the code complies with the business requirements and simplifies communication between technical and non-technical team members. Therefore, to ensure that everyone is on the same page, conduct collaborative sessions regularly to clarify domain concepts and terminology. In addition, software developers should avoid using unnecessary technical jargon to ensure clarity among non-technical team members. Collaborative sessions should be held regularly to clarify domain concepts and terminology. This emphasizes the importance of effective communication in a team-oriented setting, which can ultimately lead to the successful completion of a project.</p><p><strong>2. Ubiquitous Language in Method Names: </strong>When writing methods in your code, using names that reflect the Ubiquitous Language used in the business rules is crucial. For instance, if you have a business rule named “<strong>CalculateDiscount</strong>,” your code should have a method with a corresponding name that aligns with it. This practice makes the code more understandable and readable and helps maintain consistency and cohesion in the architecture.</p><p><strong>3. Create Rich Domain Models: </strong>Design your code to represent the business domain closely. This entails creating rich domain models that encapsulate both data and behavior. For instance, if your domain comprises intricate business rules for computing discounts, ensure that your code reflects this complexity within the relevant domain entities.</p><p><strong>4. Avoid Anemic Domain Models: <em>The Anemic Domain Model</em></strong> is a design approach that focuses on data entities without incorporating the business logic that operates on the data. This approach often results in a fragmented architecture where the business logic is spread across various layers or services. To avoid this, DDD proposes the concept of a “<strong>Rich Domain Model</strong>,” where data and behavior are encapsulated within domain entities and value objects. This approach ensures that the domain model is not just a data structure but an accurate representation of the business domain, embedding its rules, validations, and operations. Adopting a Rich Domain Model makes the application’s core more cohesive, maintainable, and aligned with the business domain, leading to a more robust and scalable system. The shift from an <strong>Anemic to a Rich Domain Model</strong> is pivotal in realizing the full benefits of DDD, as it empowers the domain model to serve as the authoritative source of business logic, thus fostering a deeper alignment between software design and business requirements.</p><p>When designing domain models, it is crucial to avoid creating entities that are passive data containers with no behavior. This kind of structure is commonly referred to as anemic domain model. It is essential to incorporate business logic into the domain entities to create a more robust representation of the domain. This will help capture the domain’s full richness and ensure that the domain models are better aligned with their business requirements.</p><p><strong>5. Ubiquitous Language in Comments and Documentation: </strong>Utilizing the Ubiquitous Language while documenting your code can significantly benefit future developers and yourself in quickly comprehending the domain context. Comments and documentation can serve as a helpful bridge to overcome any confusion between domain terminology and code. Establishing a glossary that defines domain-specific terms and their corresponding representations in the code is highly recommended, which can help ensure that all project collaborators are aligned and on the same page.</p><p><strong>6. Maintain Consistency: </strong>Ensure that the Ubiquitous Language is consistently used throughout the codebase.<br>Regularly review and update the language based on evolving domain understanding.</p><p><strong>7. Bounded Contexts: </strong>Identify and define bounded contexts within your project. Each bounded context may have its own Ubiquitous Language that aligns with its specific domain responsibilities.</p><p><strong>8. Aggregate Roots: </strong>Identify and model Aggregate Roots as the entry points to the domain. Aggregate Roots helps maintain consistency and encapsulate business rules. Ensure the code structure reflects the relationships and boundaries defined by Aggregate Roots in the domain.</p><p><strong>9. Value Objects: </strong>Consider using Value Objects to represent significant concepts in your domain that do not possess a unique identity. For example, you could model a currency value or a postal address as a Value Object. Ensure that you reflect these Value Objects in your code.</p><p><strong>10. Testing with Ubiquitous Language: </strong>Write tests using the same language that was used in the domain discussions. Make sure that the tests are easily readable and understandable by both developers and domain experts.</p><p>When you consistently utilize the DDD throughout your development process, this results in more precise and efficient software development.</p><h4><strong>Harmonizing Strategy and Tactics in DDD</strong></h4><p>DDD combines strategic and tactical approaches in software development to ensure a comprehensive solution. Strategic design focuses on the broader structure of the software, dividing the system into distinct Bounded Contexts that align with business domains. It also manages the relationships between these contexts to ensure coherent overall functionality. On the other hand, tactical design delves into the specifics within these contexts, meticulously creating a model that accurately reflects and handles complex business logic, using techniques such as Entities, Value Objects, Aggregate Roots, Domain Events, and Domain Services. Together, these two aspects of DDD ensure a well-structured and finely detailed software solution that harmonizes business needs with technical execution.</p><h3>Strategic Design with Bounded Contexts</h3><p>The notion of bounded contexts is a fundamental aspect of strategic design in DDD. It depicts the limits within which a specific domain model is defined and applicable.</p><h4>Implementing Bounded Contexts</h4><ul><li><strong>Identification:</strong> Begin by recognizing the natural boundaries within the business domain. This will necessitate extensive conversations with domain experts.</li><li><strong>Context Mapping:</strong> This involves comprehending the interactions and relationships between different bounded contexts. It is critical for handling dependencies and integrations.</li><li><strong>Explicit Boundaries:</strong> Every bounded context must have explicitly defined boundaries, which can be physical (like a microservice) or logical (like a module within a system).</li></ul><h4>Integration and Communication</h4><p>When integrating multiple bounded contexts, it is crucial to plan meticulously. Experts use various approaches, such as shared kernels, customer/supplier development teams, and anti-corruption layers, to manage these relationships effectively. These techniques ensure that the integration process is seamless and efficient.</p><blockquote>Let’s use an example from the aviation industry to illustrate Bounded Context in DDD:</blockquote><h4>Example: Airline Management System</h4><p>Different aspects of airline operations can be segmented into distinct Bounded Contexts in an airline management system. These include Flight Operations, Booking Systems, Crew Management, and Aircraft Maintenance.</p><p><strong>1. Flight Operations Context</strong></p><ul><li><strong>Domain Model</strong>: Includes Flight, Route, Air Traffic Control (ATC) Communications, etc.</li><li><strong>Ubiquitous Language</strong>: Terms like “Flight Plan,” “Takeoff Slot,” and “Cruising Altitude” are specific to this context.</li><li><strong>Responsibilities</strong>: Managing flight schedules, planning routes, tracking flights in real-time, and interacting with air traffic control.</li></ul><p><strong>2. Booking System Context</strong></p><ul><li><strong>Domain Model</strong>: This comprises the ticket, passenger, itinerary, fare class, etc.</li><li><strong>Ubiquitous Language</strong>: Terms such as “Reservation,” “E-Ticket,” and “Overbooking” hold specific meanings in this context.</li><li><strong>Responsibilities</strong>: Handling passenger reservations, ticketing, pricing, and seat assignments.</li></ul><p><strong>3. Crew Management Context</strong></p><ul><li><strong>Domain Model</strong>: Includes Crew Member, Roster, Duty Hours, Qualifications, etc.</li><li><strong>Ubiquitous language</strong>: “Crew Pairing,” “Layover,” and “Duty Time Limitations” have particular meanings.</li><li><strong>Responsibilities</strong>: Scheduling crew members, managing rosters, tracking crew qualifications and legal duty limits.</li></ul><p><strong>4. Aircraft Maintenance Context</strong></p><ul><li><strong>Domain Model</strong>: Comprises various aspects such as Maintenance Schedule, Aircraft Parts, Service Log, Certification, and so on.</li><li><strong>Ubiquitous Language</strong>: Terms like “Ground Time,” “Service Bulletin,” and “Airworthiness Directive” are specific to this context.</li><li><strong>Responsibilities</strong>: Managing regular maintenance checks, tracking aircraft part replacements, and ensuring regulatory compliance.</li></ul><h3>Interaction Between Contexts</h3><p>In this integrated system, the various contexts interact with one another in a defined manner. For instance, the context of Flight Operations depends on the context of Crew Management to ensure that suitably qualified crew members are assigned to each flight, as well as the context of Aircraft Maintenance to ensure that the aircraft is in a serviceable condition.</p><h3>Benefits</h3><ul><li><strong>Focused Domains</strong>: Each context deals with a specific segment of airline operations, simplifying the complexity inherent in each domain.</li><li><strong>Clear Boundaries</strong>: It is easier to define rules, workflows, and responsibilities when each context is delineated.</li><li><strong>Contextual Models</strong>: Models and languages are tailored to fit the specific needs and nuances of each aspect of airline operations.</li></ul><p>This example from the aviation industry demonstrates the implementation of Bounded Contexts in managing complex domains by dividing them into smaller, specialized areas, each with its focused model and language.</p><blockquote>Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.</blockquote><blockquote>-Sun Tzu</blockquote><h3>Tactical Design: Bringing the Domain Model to Life</h3><p>Tactical design pertains to the practical implementation of our ideas. It is the stage where we put our abstract concepts into practice, translating them into actual code to form a living model that evolves alongside the project. This is where we transform our ideas into a tangible outcome that develops with each step we take in the design process.</p><h4>Core Building Blocks</h4><ul><li><strong>Entities:</strong> These objects have a distinct identity and are easily recognizable throughout the system’s lifecycle. They represent essential business concepts and are usually identified by a unique ID.</li><li><strong>Value Objects:</strong> These objects describe various aspects of the domain but do not possess a specific identity. Instead, their attributes define them, and they are often immutable.</li><li><strong>Aggregates:</strong> Aggregates are clusters of domain objects that can be treated as a single unit. Each aggregate has a distinct boundary and a root that manages its data and consistency. Aggregates play a vital role in maintaining data consistency and ensuring that all changes to the data are made within the context of the transaction.</li><li><strong>Domain Events:</strong> Domain events are significant occurrences in the domain that trigger various side effects in different system parts. They are a powerful way to express intent and communicate between different domains.</li></ul><blockquote>Case Study: The Booking System Domain Model</blockquote><h4>Overview:</h4><ul><li><strong>Entities</strong> (<strong>Passenger</strong>, <strong>Itinerary</strong>, <strong>FlightSegment</strong>): These classes extend the <strong>Entity</strong> base class, emphasizing their nature as entities with unique identities.</li><li><strong>Value Object (FareClass)</strong>: This class extends the <strong>ValueObject </strong>base class. It should implement equality based on its attributes (<strong>Code</strong> and <strong>Description</strong>), though the actual implementation of equality checks and hash code generation is omitted here for brevity.</li><li><strong>Aggregate Root (Reservation)</strong>: As the Aggregate Root, <strong>Reservation</strong> controls access to and the lifecycle of the entities within its aggregate boundary. It ensures that all interactions with <strong>Passenger</strong>, <strong>Itinerary</strong>, and <strong>FareClass</strong> follow the business rules and logic defined within the aggregate.</li></ul><pre>namespace BookingSystem.Domain<br>{<br>    public class Passenger : Entity<br>    {<br>        public string FullName { get; private set; }<br>        public string Email { get; private set; }<br><br>        public Passenger(string fullName, string email)<br>        {<br>            Id = Guid.NewGuid();<br>            FullName = fullName;<br>            Email = email;<br>        }<br>    }<br><br>    public class Itinerary : Entity<br>    {<br>        public List&lt;FlightSegment&gt; Segments { get; private set; } = new List&lt;FlightSegment&gt;();<br><br>        public void AddSegment(FlightSegment segment)<br>        {<br>            Segments.Add(segment);<br>        }<br>    }<br><br>    public class FlightSegment : Entity<br>    {<br>        public DateTime DepartureTime { get; private set; }<br>        public DateTime ArrivalTime { get; private set; }<br>        public string Origin { get; private set; }<br>        public string Destination { get; private set; }<br><br>        public FlightSegment(DateTime departureTime, DateTime arrivalTime, string origin, string destination)<br>        {<br>            Id = Guid.NewGuid();<br>            DepartureTime = departureTime;<br>            ArrivalTime = arrivalTime;<br>            Origin = origin;<br>            Destination = destination;<br>        }<br>    }<br><br>    public class FareClass : ValueObject<br>    {<br>        public string Code { get; private set; }<br>        public string Description { get; private set; }<br><br>        public FareClass(string code, string description)<br>        {<br>            Code = code;<br>            Description = description;<br>        }<br>        // Override Equals method for equality comparison<br>    }<br><br>    public class Reservation : AggregateRoot<br>    {<br>        public Passenger Passenger { get; private set; }<br>        public Itinerary Itinerary { get; private set; }<br>        public FareClass FareClass { get; private set; }<br>        public string ETicketNumber { get; private set; }<br>        public bool IsOverbooked { get; private set; }<br><br>        public Reservation(Passenger passenger, Itinerary itinerary, FareClass fareClass)<br>        {<br>            Id = Guid.NewGuid();<br>            Passenger = passenger;<br>            Itinerary = itinerary;<br>            FareClass = fareClass;<br>        }<br><br>        public void IssueETicket(string ticketNumber)<br>        {<br>            ETicketNumber = ticketNumber;<br>        }<br><br>        public void MarkAsOverbooked()<br>        {<br>            IsOverbooked = true;<br>        }<br>    }<br>}</pre><p>“<strong>The Booking System</strong>” domain is an example of tactical design implementation. This domain model is constructed using multiple classes, each with a specific purpose that helps encapsulate the domain’s business logic. It also aligns with the principles of DDD. The model comprises classes like <strong>Passenger</strong>, <strong>Itinerary</strong>, and <strong>FlightSegment</strong>, which are used to represent different entities. A <strong>value object called</strong> <strong>FareClass</strong> is also included, and an <strong>aggregate root</strong>, <strong>Reservation</strong>, is used to manage the relationships between the various entities.</p><p>This structure supports the principles of DDD by clearly separating concerns and encapsulating business logic within the domain model.</p><h3>Domain Events</h3><p><strong>Domain Events</strong> are a crucial concept in DDD that represent a change in the domain state and are relevant to the business. These events result from executing domain logic and are used to model the event-driven aspects of the business process. They communicate between different parts of the domain, ensuring that changes in one part can be reflected or responded to in another. Domain Events encapsulate the memory of something significant that impacted the domain, enabling systems to react to these changes asynchronously while maintaining a clear separation of concerns within the architecture. DDD’s use of Domain Events facilitates a more reactive, robust, and maintainable system design closely aligned with the business’s needs and processes.</p><h4>Implementing a Domain Event</h4><blockquote>Case Study: The “<strong>Reservation Confirmed</strong>” Event</blockquote><p>The “<strong>Reservation Confirmed</strong>” event is a practical instance of a Domain Event. This particular event is activated when a reservation is processed successfully. Once triggered, a chain of consequential actions is initiated, such as sending a confirmation email to the passenger, updating the flight’s availability status, and logging the reservation details for analytical and tracking purposes. This sequence illustrates how one event can trigger numerous related processes, enhancing the system’s efficiency and responsiveness.</p><p>Here’s a basic example of how you might implement and publish a domain event for a “<strong>ReservationConfirmed”</strong> scenario in C#:</p><pre>public class ReservationConfirmed : IDomainEvent<br>{<br>    public Guid ReservationId { get; private set; }<br>    public DateTime Timestamp { get; private set; }<br><br>    public ReservationConfirmed(Guid reservationId)<br>    {<br>        ReservationId = reservationId;<br>        Timestamp = DateTime.UtcNow;<br>    }<br>}<br><br>public class Reservation : AggregateRoot<br>{<br>    // Existing properties and methods<br><br>    public void ConfirmReservation()<br>    {<br>        // Reservation confirmation logic<br><br>        // Publish the ReservationConfirmed event<br>        DomainEvents.Publish(new ReservationConfirmed(this.Id));<br>    }<br>}</pre><p>The “<strong>ReservationConfirmed” </strong>class implements the “<strong>IDomainEvent”</strong> interface, encapsulating the reservation ID and timestamp details. Essentially, it represents the data structure of the event. On the other hand, the <strong>Reservation class acts as an Aggregate Root</strong>, containing the necessary logic to confirm reservations and publish events. The “<strong>DomainEvents” </strong>static class serves as a conduit for the event to reach subscribed handlers responsible for executing various side effects or integrations triggered by the event.</p><h4>When to Utilize Domain Events</h4><p>It is generally considered a good practice to incorporate Domain Events where actions within your domain may require side effects or integrations that are more effectively handled outside the core domain logic. This approach is instrumental in maintaining a clear separation of concerns and reducing coupling within the system. Domain Events prove to be especially advantageous in operations that involve asynchronous processing or interactions with external systems or other parts of the system. By utilizing Domain Events, developers can create systems that are more modular, scalable, and easier to maintain.</p><h3>Domain Services</h3><p><strong>Domain Services</strong> play a crucial role in systems designed using DDD. Unlike Domain Events that indicate changes in the system’s state, Domain Services encapsulate business logic that cannot be naturally fitted within a single entity or value object. These services are indispensable for operations that involve multiple domain objects and require a cohesive process to execute the business rules and logic central to the domain’s core functionality. In brief, Domain Services are the glue that holds complex operations together and ensures that business rules are enforced.</p><h4>Implementing a Domain Service</h4><blockquote>Case Study: The “<strong>Flight Booking</strong>” Service</blockquote><p>The “<strong>Flight Booking</strong>” Service is an example of a Domain Service that coordinates flight bookings. This service manages the complex booking process, which includes checking flight availability, applying pricing rules, processing payments, and confirming reservations. It acts as a conductor, ensuring that each step is executed correctly and that the overall business rule — successfully booking a flight — is followed.</p><p>To implement the “<strong>Flight Booking</strong>” service in C#, a service that interacts with various domain entities and other services needs to be defined to fulfill its responsibilities. Here’s how such a service might be structured:</p><pre>public class FlightBookingService : IFlightBookingService<br>{<br>    private readonly IFlightRepository flightRepository;<br>    private readonly IPaymentService paymentService;<br><br>    public FlightBookingService(IFlightRepository flightRepository, IPaymentService paymentService)<br>    {<br>        this.flightRepository = flightRepository;<br>        this.paymentService = paymentService;<br>    }<br><br>    public BookingResult BookFlight(FlightBookingRequest request)<br>    {<br>        // Validate the request<br>        // Check flight availability<br>        var flight = flightRepository.FindById(request.FlightId);<br>        if (flight == null || !flight.IsAvailableOn(request.Date))<br>        {<br>            return BookingResult.Failed(&quot;Flight is not available.&quot;);<br>        }<br><br>        // Process payment<br>        var paymentResult = paymentService.ProcessPayment(request.PaymentDetails);<br>        if (!paymentResult.IsSuccess)<br>        {<br>            return BookingResult.Failed(&quot;Payment processing failed.&quot;);<br>        }<br><br>        // Confirm reservation<br>        var reservation = flight.ConfirmReservation(request.PassengerDetails);<br>        flightRepository.Update(flight);<br><br>        return BookingResult.Success(reservation);<br>    }<br>}</pre><p>This example demonstrates how the <strong>FlightBookingService</strong> operates by encapsulating the flight booking logic. The service employs other essential components, such as <strong>IFlightRepository</strong>, to access flight data and <strong>IPaymentService</strong> to process payments. The service coordinates these interactions, ensuring the business operation is completed successfully and cohesively.</p><h4>When to Utilize Domain Services</h4><p>Domain Services come into play when a business operation or logic cannot naturally be assigned to a single domain entity or value object. Such scenarios often involve intricate processes or business rules that span multiple domain concepts. Using Domain Services allows for maintaining a clear separation of concerns within the domain model, ensuring that entities and value objects stay focused on their core responsibilities. <br>Moreover, incorporating Domain Services can help develop a modular and enduring architecture by enabling the business logic crucial for encapsulating the domain, but not limited to any particular domain object.</p><p><strong>Conclusion</strong></p><p>Domain-driven design presents a comprehensive approach to addressing the intricacies of developing modern business software. By prioritizing the core domain, promoting a ubiquitous language, and implementing strategic and tactical patterns, DDD facilitates the creation of software that is not only technically sound but also closely aligned with business objectives and flexible enough to accommodate evolving demands. As businesses are constantly changing, the principles of DDD provide a dependable framework for constructing software systems capable of adapting and expanding in tandem with the evolving needs of the enterprise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa38d338b7bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Copilot as Prominent AI-powered Technology]]></title>
            <link>https://medium.com/adessoturkey/copilot-as-prominent-ai-powered-technology-db8162e9e810?source=rss-b4321869bbca------2</link>
            <guid isPermaLink="false">https://medium.com/p/db8162e9e810</guid>
            <category><![CDATA[windows-copilot]]></category>
            <category><![CDATA[microsoft-build-2023]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ai-powered-technology]]></category>
            <category><![CDATA[microsoft-365-copilot]]></category>
            <dc:creator><![CDATA[Büşra Tanrıverdi]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 11:09:54 GMT</pubDate>
            <atom:updated>2023-07-17T07:53:38.215Z</atom:updated>
            <content:encoded><![CDATA[<p>Microsoft Build is an annual workshop where Microsoft unveils its latest technologies, product updates, development tools, and platforms. As a beneficial platform, Microsoft Build brings people together worldwide to create new possibilities for developers, share valuable insights, and establish a community. This year, “Copilot” is one of the standout announcements of Microsoft Build. Hence, this article will scrutinize <em>Copilot</em>, <em>Windows Copilot</em>, <em>Microsoft 365 Copilot</em>, and <em>GitHub Copilot</em> concepts and discuss their potential benefits.</p><h3><strong>Copilot</strong></h3><p>To begin, it may be helpful to provide a brief overview of the term “C<em>opilot</em>.” Copilot is an application that utilizes modern AI to assist users with complex cognitive tasks. It is an AI-powered application with a conversational interface that helps you with cognitive tasks.</p><p>One key message conveyed at this event was, “This is what Microsoft needs — leaving them all in a common area.” Therefore, we can infer from this sentence that the purpose is to facilitate handling complex cognitive tasks typically encountered by users, all from one common place. Another message came from Kevin Scott, the CTO and EVP of AI Microsoft, who emphasized the importance of platforms in his message. Platforms enable us to build things more confidently than we would typically be able to.</p><p>The prominent aspects of the “copilot” mentioned during the event are as follows:</p><p><strong>- It employs a fresh development approach</strong></p><p><strong>- It boasts a unique architecture</strong></p><p><strong>- It will be everywhere</strong></p><h3><strong>Windows Copilot</strong></h3><blockquote><strong>What is Windows Copilot, and what does it bring?</strong></blockquote><p><em>Windows Copilot</em>, an AI tool recently announced on May 23rd, can significantly increase PC productivity while enhancing the overall computing experience for users. Microsoft has announced that they plan to incorporate this impressive AI technology into Windows 11. One of the phrases emphasized regarding Windows Copilot at the Microsoft Build event is “<strong><em>Centralized AI Assistance</em></strong>.” Therefore, it can be said that Windows Copilot is a centralized assistant that harnesses the power of artificial intelligence to provide unparalleled service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpTfG4FQqYnPHeb0sR5f-w.jpeg" /><figcaption><strong>Windows Copilot</strong></figcaption></figure><p>Another phrase that depicted the Windows Copilot during this event was, <strong><em>“It is going to change how you use your pc forever.”</em></strong></p><h4><strong>Windows Copilot as an AI-powered assistant</strong></h4><p><strong>-Designed to integrate into your workflow</strong></p><p><strong>- Advanced capabilities to cater to your needs</strong></p><p><strong>- Boosts productivity and improves work efficiency</strong></p><p>Imagine the possibilities of configuring our PC to help us unleash our creativity and boost productivity! That is where Windows Copilot comes in to save the day.</p><p>During this event, the remarkable capabilities of Windows Copilot were showcased. Based on the demo presented, users can promptly configure their PC with the assistance of artificial intelligence by simply clicking a button in a chat environment.</p><blockquote><strong>How can Windows Copilot help with creativity and productivity?</strong></blockquote><p>To address this question, I will furnish examples from the demonstration conducted during the event. The four striking examples shown during the demo at the Microsoft Build event, which I clarified as a question-and-answer format, are as follows:</p><p><strong>1.</strong> <strong>Personalizing and Navigating your PC</strong></p><p><strong>+</strong> How can Windows Copilot help personalize and navigate a PC?</p><p><strong>-</strong> An instance of this is when switching from one theme to another. As developers, we generally prefer using dark mode while working. With Windows Copilot, changing white to dark mode can be done with just one click.</p><p><strong>2.</strong> <strong>Documentation</strong></p><p><strong>+</strong> How can Windows Copilot summarize a document?</p><p><strong>-</strong> Windows Copilot is highly efficient when it comes to handling PDFs. Users can attach any file, request a summary, rewrite the content, or ask questions about it.</p><p><strong>3.</strong> <strong>Opening a Song</strong></p><p><strong>+ </strong>How can Windows Copilot open a song on a platform like Spotify?</p><p><strong>-</strong> Asking questions like that, “Could you do me a favor? I’m looking for a great coding playlist on Spotify. Could you help me out with that?” Therefore, the Spotify plugin allows developers to write code while enjoying their favorite music.</p><p><strong>4.</strong> <strong>Workflow with Plugins</strong></p><p><strong>+</strong> How can Windows Copilot support workflow with plugins?</p><p><strong>-</strong>It can create a logo or shape a picture.</p><p><strong>-</strong>It can suggest applications upon user demand.</p><p><strong>-</strong>It can also launch the recommended application.</p><p><strong>-</strong>It is qualified to share the logo on Microsoft Teams.</p><p>As seen from the samples above, with the assistance of Windows Copilot, users can receive superb suggestions for their questions. By only clicking the recommendation button, they can effortlessly switch to a new environment and make the most of their experience. In a nutshell, Windows Copilot offers a wide range of features that can be customized to fit different needs.</p><blockquote><strong>What are the available plugins that integrate Windows Copilot?</strong></blockquote><p>You can find a comprehensive list of available plugins for Windows Copilot in the image below. Additionally, during the Microsoft Build event, Yusuf Mehdi, CVP, Consumer CMO Microsoft, announced that are currently 50 plugins available, with more to come.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Cxysu1RX4_cV-0I1qtuGA.jpeg" /><figcaption><strong>Deep integration into the PC</strong></figcaption></figure><h3><strong>Microsoft 365 Copilot</strong></h3><blockquote><strong>Microsoft 365 Copilot — your copilot for work.</strong></blockquote><p>Within various fundamental Microsoft applications like Word, Excel, PowerPoint, Outlook, and Teams, Microsoft 365 Copilot is an effective tool for increasing productivity and optimizing work processes. Its features facilitate workflow and help achieve users’ goals more efficiently.</p><blockquote><strong>What are the possible uses of Microsoft 365 Copilot?</strong></blockquote><p>This section will explain this question with examples based on <em>Word</em>, <em>PowerPoint</em>, and <em>Teams</em>, some Microsoft 365 applications.</p><p><strong>Copilot in Microsoft Word</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JyLZtRa6VJIYE4lrMCC_jg.jpeg" /></figure><p>The Copilot within Word allows users to efficiently compose a comprehensive outline and incorporate pertinent, organization-specific details as needed. Copilot can also effectively modify pre-existing documents by rewriting entire sections or the entire document. Furthermore, Copilot provides helpful suggestions to enhance the quality of your writing by bolstering your arguments and addressing any inconsistencies. During the Microsoft Build event, a demonstration was provided to showcase the capabilities of Copilot in assisting with editing legal contracts. When information on California law is required, the Practical Law plugin can be utilized. Copilot effectively reviews the contract, conducts a legal analysis, and assists in locating the specific area that requires editing. Additionally, it can compile a comprehensive summary of all the proposed changes.</p><p><strong>Copilot in Microsoft PowerPoint</strong></p><p>Copilot can generate a new PowerPoint presentation using existing written documents upon request or from a draft. Furthermore, it can provide concise summaries of lengthy presentations and reformat the texts.</p><p><strong>Copilot in Microsoft Teams</strong></p><p>An example is using Copilot in Microsoft Teams to access the Atlassian plugin and utilize Atlassian Jira for project management expertise. An additional feature for productivity is the incorporation of Copilot into meetings and discussions. This feature enables the creation of meeting agendas by analyzing chat history. Participants may request a summary of any missed points from the meeting and inquire about decisions that were reached.</p><h3><strong>GitHub Copilot</strong></h3><p>GitHub Copilot is a tool that can significantly enhance the productivity and efficiency of developers by offering them helpful code suggestions and completions for their projects. It can save time and effort, conducting a more efficient development process.</p><p>During the event, Thomas Dohmke, CEO of GitHub, stressed that GitHub Copilot Chat is a significant innovation for GitHub. Mike Krieger, Co-Founder of Instagram, expressed his thoughts regarding GitHub Copilot:</p><blockquote>“This is the single most mind-blowing application of machine learning I have ever seen.”</blockquote><blockquote><strong>What are the statistics on GitHub Copilot?</strong></blockquote><p><strong>During Microsoft Build 2023, several statistics about GitHub Copilot were shared for examination.</strong></p><ul><li>46% of new code is now written by AI.</li><li>75% of developers feel more concentrated on satisfying work.</li><li>96% of developers are faster with duplicative tasks.</li></ul><p><strong>What are the possible uses of GitHub Copilot?</strong></p><p>To answer this question, in this section, I will describe six uses of the GitHub Copilot, which is supported by many programming languages (C++, C#, Go, Ruby, JavaScript, TypeScript, Python, and so on) and compilers (currently VS Code(mostly), JetBrains, and Neovim ideas) and which we can add as a plugin.</p><p><strong>1. Communication with GitHub Copilot Chat</strong></p><p>Developers can chat with GitHub Copilot Chat for diverse duties in the Visual Studio Code’s interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jw5iMiu4aW6rKUbEyoviWg.gif" /></figure><p><strong>2. Learning and Building</strong></p><p>For instance, we can select three lines of code and request an explanation of what this code snippet does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*PxNjH4tIIU_VPttjJ_bWAA.gif" /><figcaption><strong>Sample of the explanation of the selected code snippet</strong></figcaption></figure><p><strong>3. Requesting Unit Tests from GitHub Copilot Chat</strong></p><p>For instance, to request a unit test, say, “Generate unit tests for my code.” Remarkably, this ability can be accomplished in only seven lines.</p><p><strong>4. Bug Fixing with GitHub Copilot</strong></p><p>To get assistance with fixing bugs in your code, ask GitHub Copilot to suggest a fix by saying, “Can you propose a fix for the bugs in my code?”</p><p><strong>5. Separation of Functions</strong></p><p>For instance, it can be beneficial to have separated validation methods. By asking the relevant question about our specific needs, GitHub Copilot will exhibit changes incorporating separated validation methods and adding new lines of code.</p><p><strong>6. Making Code More Readable</strong></p><p>To enhance the readability of the code, simply state, “Make this code more readable by refactoring it.” At this point, GitHub Copilot analyzes code snippets and recommends more readable and clean code. Therefore, developers can streamline their development process and produce high-quality code.</p><p>More examples can be added, such as adding additional comments for code snippets, and new features may come to GitHub Copilot over time.</p><p>To sum up, with its high integration level, Windows Copilot can transform our computer usage significantly — even its interactive and notable features in PC settings prompt users to reevaluate their choice of the operating system. As for Microsoft 365 Copilot, it has been seamlessly integrated into productivity applications that are widely used by millions of individuals for their professional and personal pursuits. It operates within several essential Microsoft applications, such as Word, Excel, PowerPoint, Outlook, Teams, and others, to enhance productivity and streamline work processes. As for GitHub Copilot, it is an innovative tool that helps developers improve their coding skills. It provides a chat-based environment for learning and development.</p><h3>References</h3><p>Jha, R. (2023, May 23). Empowering every developer with plugins for Microsoft 365 Copilot | Microsoft 365 Blog. Retrieved June 25, 2023, from <a href="https://www.microsoft.com/en-us/microsoft-365/blog/2023/05/23/empowering-every-developer-with-plugins-for-microsoft-365-copilot/">https://www.microsoft.com/en-us/microsoft-365/blog/2023/05/23/empowering-every-developer-with-plugins-for-microsoft-365-copilot/</a></p><p>Microsoft. (2023, May 23–25). Microsoft Build 2023. Retrieved June 25, 2023, from <a href="https://news.microsoft.com/build-2023/">https://news.microsoft.com/build-2023/</a></p><p>Panay, P., Chief Product Officer, Windows and Devices. (2023, May 23). Bringing the power of AI to Windows 11 — unlocking a new era of productivity for customers and developers with Windows Copilot and Dev Home. Windows Developer Blog. Retrieved June 28, 2023, from <a href="https://blogs.windows.com/windowsdeveloper/2023/05/23/bringing-the-power-of-ai-to-windows-11-unlocking-a-new-era-of-productivity-for-customers-and-developers-with-windows-copilot-and-dev-home/">https://blogs.windows.com/windowsdeveloper/2023/05/23/bringing-the-power-of-ai-to-windows-11-unlocking-a-new-era-of-productivity-for-customers-and-developers-with-windows-copilot-and-dev-home/</a></p><p><strong>If you are interested in the subject, you can find more information through the links below.</strong></p><ul><li><a href="https://news.microsoft.com/build-2023/">Microsoft Build 2023</a></li><li><a href="https://www.microsoft.com/en-us/microsoft-365/blog/2023/03/16/introducing-microsoft-365-copilot-a-whole-new-way-to-work/">Introducing Microsoft 365 Copilot | Microsoft 365 Blog</a></li><li><a href="https://learn.microsoft.com/en-us/shows/introduction-to-github-copilot/">Introduction to GitHub CoPilot</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db8162e9e810" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adessoturkey/copilot-as-prominent-ai-powered-technology-db8162e9e810">Copilot as Prominent AI-powered Technology</a> was originally published in <a href="https://medium.com/adessoturkey">adessoTurkey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The IoC Container Lifecycle]]></title>
            <link>https://medium.com/adessoturkey/the-ioc-container-lifecycle-f6c38d9c9139?source=rss-b4321869bbca------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6c38d9c9139</guid>
            <category><![CDATA[software-design-patterns]]></category>
            <category><![CDATA[ioc-container]]></category>
            <category><![CDATA[dependency-inversion]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Büşra Tanrıverdi]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 13:19:17 GMT</pubDate>
            <atom:updated>2023-01-13T14:02:13.077Z</atom:updated>
            <content:encoded><![CDATA[<p>Inversion of Control (IoC) is a software design principle responsible for the lifecycle of objects throughout the application. The mission of IoC is to manage the instances used in the application and to reduce dependency. Therefore, the Inversion of Control principle enables the design of loosely coupled classes that make them maintainable, testable, and extensible.</p><p>There are diverse libraries to implement IoC. The most widespread ones are:</p><blockquote><strong><em>Castle Windsor, Ninject, Structure Map, Autofac, LightInject, DryIoc</em></strong></blockquote><p>Each library mentioned above is a third-party framework that equips IoC structuring in .NET applications. Especially, Autofac and Ninject are two of the most habituated and used containers for .NET that Microsoft does not develop. However, ASP.NET Core architecture comprises an IoC container module as built-in (Microsoft’s IoC Container in .NET Core) for automatic dependency injection. One of the ways to apply IoC is to implement dependency injection based on the dependency inversion principle. Therefore, discussing these concepts and their brings for this article, which aims to scrutinize IoC and its lifecycles in detail, is essential.</p><h4><strong>Dependency Inversion</strong></h4><p>Dependency inversion (DI), a software design principle, is significant for better comprehending the IoC container. The DI design principle advocates that high-level modules should be independent of low-level modules. For instance, domain logic should not depend on how the code that ties to our database works. This section will describe the significance of the relevant design principle based on the scenario where the Dependency Inversion design principle is applied and not applied.</p><blockquote><strong><em>Scenario 1</em></strong></blockquote><p>This drawing illustrates the scenario where the dependency inversion design principle does not apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*z9zb_9fUPMWksavRa4KQog.png" /></figure><p>According to the DI design principle, class A is the high-level module, class B is a lower-level module, and class C is an even lower-level module. All these classes directly depend on the class or classes they need. As can be noticed from this image, in such a case, class A is dependent on class B, and class B is dependent on class C. When class B changes, class A also has to change. The same goes for a change to class C, which might affect class B and class A. The typical approach to stemming this case in an object-oriented application is utilizing interfaces.</p><blockquote><strong><em>Scenario 2</em></strong></blockquote><p>This drawing narrates a scenario in which embodies the dependency inversion design principle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ITX5mqYUnLqBPsMacPs67g.png" /></figure><p>We have class A, whereas this time, it leans on interface B instead of directly on class B. Class B then implements this interface. The same goes for the outgoing dependency of class B. And then interface C, which is implemented in class C. In the case of Scenario 2, the arrows do not consist of continuous lines as in Scenario 1. Because in Scenario 2, the relationship established with interfaces comes into play.</p><p>To give a more concrete example of this case, we will need to modify many sections in our code to work with “Dapper” instead of “Entity Framework Core (EF Core)” when the project we are developing requires it. Because if we do not operate dependency injection in the business layer, we should alter all the service classes that created the EF Core class with the “new” operator. This case conflicts with the Open-Closed Principle (OCP), the second SOLID principle. However, when we utilize DI, we will only be able to revise the implementation type of the relevant interface from EF Core to Dapper ORM in the configuration section since we will perform operations over interfaces. This kind of work brings loose coupling relationships.</p><p>As a result, establishing a loose coupling (decoupling from concrete types) rather than direct dependency or tight coupling prevents radical changes and makes classes more testable.</p><h4><strong>Dependency Injection</strong></h4><p>One of the methods to practically implement dependency inversion, which is the last of the SOLI(D) principles and corresponds to the letter D, is “Dependency Injection (DI).”</p><p>· <strong>What is Dependency Injection?</strong></p><p>Dependency injection (DI) is an understanding that argues that if we require an object of another class at any point in any class, we should avoid creating the object of that class with the “new” operator. For instance, we need class B inside class A. When we create the B object with the “new” operator inside class A, in this case, considering the dependency injection design principle, we should underline that class A has a dependency on class B. We need to inject the relevant object outside to eliminate a class’s dependency on another class. Dependency injection endorses that if we need another class inside a class, we should resolve it from the constructor rather than creating this class by renewing it.</p><h4><strong>How Does Inversion of Control Work?</strong></h4><h4><strong>Built-in IoC Container</strong></h4><p>Built-in IoC Container can take objects to be placed in three different behaviors/lifecycles. These lifecycles or lifetimes are <strong>singleton</strong>, <strong>scoped</strong>, and <strong>transient</strong>. This section of the article will examine these three IoC lifecycles and the issue of determining an appropriate lifecycle.</p><h4><strong>Singleton</strong></h4><p>A new instance is created once and reused from then onward. <strong><em>Singleton</em></strong> <strong><em>lifecycle</em></strong> is utilized when we always want to return the same instance whenever a type is requested. In a nutshell, the container will instantiate the type the first time it is requested and keep returning the same instance as long as the application is up and running. For instance, there are 500 requests, and IoC Container instantiates the same instance for these 500 requests.</p><h4><strong>Scoped</strong></h4><p>A new instance is formed once per request scope and then reused in the scope. The container will create one instance per the request scope. <strong><em>Scoped lifecycle</em></strong> is utilized for generating an object per request and gives that object to all requests during that request scope. For example, if there are 500 requests, the IoC Container will instantiate 500 instances to these 500 requests.</p><h4><strong>Transient</strong></h4><p>In the <strong><em>Transient lifecycle</em></strong>, resolving the same type multiple times, a new instance will be returned every time. A new instance is created every time a type is requested. The container will invariably instantiate a new class whenever a type is requested. For example, IoC Container instantiates 500*n instances in response to 500 requests, and the value of “n” depends on how often the class is resolved by the dependency injection.</p><h4><strong>Determining the Optimum IoC Lifecycle</strong></h4><p>As can be comprehended from the explanations and samples above, the lifecycle determines whether the IoC Container will generate a new instance. Considering these three lifecycles, the question of which one to use may come to mind. However, giving a precise answer to this challenging question takes work. Because whatever lifecycle can handle the current situation, we should utilize that lifecycle. Thus, it ultimately depends on the necessity and the current case.</p><blockquote><strong><em>Example</em></strong><em>:</em> <em>Entity Framework Core DbContext vs. CosmosClient</em></blockquote><p>When considering Entity Framework Core DbContext, the lifecycle should correspond to the unit of work (transaction), in practice, the <strong>Scope</strong>.</p><p>CosmosDb does not endorse traditional transactions; it provides a single thread-safe client and comes with recommendations. It is thread-safe and intended for reuse. A single instance is recommended; hence, <strong>Singleton</strong>.</p><h4><strong>Working with an IoC Container</strong></h4><p>We can divide working with an IoC container into phases. We can classify these phases as <strong><em>registration</em> </strong>and <strong><em>resolution</em></strong><em>. </em>In this piece of the article, with sample images from my project, how to implement the IoC Container and its two crucial phases will be scrutinized in depth.</p><blockquote><strong><em>The Registration Phase</em></strong></blockquote><p>· We register specific types in the container. Thus, it knows their presence and when to construct them. This stage is called the registration phase.</p><p>· Choosing a lifecycle: We can determine an IoC lifecycle during the registration. Thus, choosing a lifecycle is another step to take at this phase.</p><p><strong><em>Registering Types</em></strong></p><p>When registering types, we should determine <strong>the</strong> <strong>lifetime</strong>, <strong>the requested service type</strong>, and <strong>the implementing type</strong>. Here, I will explain the registering types with a sample from the project I developed with ASP.NET Core 6.0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*4gfq2zlkWIaFAbpot1Bsng.png" /></figure><p>Second, we call the method, which begins with “Add.” Also, we need to choose one of the <strong>Transient</strong>, <strong>Singleton</strong>, and <strong>Scoped lifecycles</strong>. As seen from the image below, in my project, I preferred “Scoped” as the IoC lifecycle for this registration. Thus, we need to call one of the AddSingleton, AddTransient, and AddScoped methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*YCgVR3V0XjNYPVMP8bDZfA.png" /></figure><p>Third, once we have determined the lifecycle, we need to add generic parameters (interface and implementation type), because registering a type should include the <strong>interface</strong> and <strong>implementing type.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*wUObIfM9Ci_2Ws7w-Tsakg.png" /></figure><p>This line narrates the container: whenever somebody asks for an “<strong>IProductReadRepository</strong>,” give them a “<strong>ProductReadRepository</strong>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*UMbht0IEOtr6hvPD8x-5hA.png" /></figure><blockquote><strong><em>The Resolution Phase</em></strong></blockquote><p>· The container is liable for instantiating types and providing them when requested. We do not need to create objects manually when utilizing the IoC Container. The container does it for us. In a nutshell, when resolving a type, we demand an instance of a service type. The container will find the implementing type, instantiate it as needed, and yield it to us. This stage is called the resolution phase.</p><p>· This part of the article examines two different resolution approaches with illustrations from my project to understand the resolution phase better. One is to inject from the constructor, and the other is to resolve with the “GetService” method using the “IServiceProvider” interface.</p><p>As seen in the code snippet below, I injected the interfaces from the constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sxtNbzMwV3n1PLsEvTqx-Q.png" /></figure><p>The IServiceProvider interface is implemented by a class or value type that ensures service to other objects. The IServiceProvider is responsible for resolving instances of types at runtime, as required by the application. The implementation of IServiceProvider is designed to act very efficiently so that the resolution of services is fast.</p><p>As seen in the code snippet below, we can see that the “GetService” method of IServiceProvider is used to get the service instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q88tfGV4bOOKX6cwErcHvw.png" /></figure><p>In conclusion, based on the dependency inversion principle, this article clarifies the IoC Container and lifecycles based on the dependency injection design pattern, which is how to implement the dependency inversion principle in practice. The IoC container provides instances when needed and manages the service lifecycle. When we need the related instances in the container, we can request the instances inside the container. Combining dependency injection and IoC Container, we can build classes decoupled from other classes used through interfaces and hand over control to a framework for connecting interfaces to classes. Thus, the control is inverted. However, when inverting control, we permit a framework to determine which piece of code runs next.</p><p>You can visit my GitHub if you want to check out my code snippets.</p><p>Link: <a href="https://github.com/busratgl">https://github.com/busratgl</a></p><h4><strong>References</strong></h4><p>Chauhan, S. (2022, August 22). What is IOC container or di container. Live Training, Prepare for Interviews, and Get Hired. Retrieved November 5, 2022, from <a href="https://www.dotnettricks.com/learn/dependencyinjection/what-is-ioc-container-or-di-container">https://www.dotnettricks.com/learn/dependencyinjection/what-is-ioc-container-or-di-container</a></p><p>Janssen, T. (2020, April 28). Solid design principles explained: Dependency inversion principle with code examples. Stackify. Retrieved November 10, 2022, from <a href="https://stackify.com/dependency-inversion-principle/">https://stackify.com/dependency-inversion-principle/</a></p><p>Rick-Anderson. (n.d.). <em>Dependency injection in ASP.NET Core</em>. Microsoft Learn. Retrieved November 5, 2022, from <a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-7.0">https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-7.0</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6c38d9c9139" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adessoturkey/the-ioc-container-lifecycle-f6c38d9c9139">The IoC Container Lifecycle</a> was originally published in <a href="https://medium.com/adessoturkey">adessoTurkey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>