<?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: Azna Aroos</title>
    <description>The latest articles on DEV Community by Azna Aroos (@aznaxdev).</description>
    <link>https://dev.to/aznaxdev</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%2F3305880%2Fd202618c-3190-4b54-9380-50b49d5b739d.png</url>
      <title>DEV Community: Azna Aroos</title>
      <link>https://dev.to/aznaxdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aznaxdev"/>
    <language>en</language>
    <item>
      <title>Stop Writing Try-Catch Everywhere: Use Global Exception Handling Instead</title>
      <dc:creator>Azna Aroos</dc:creator>
      <pubDate>Thu, 02 Apr 2026 14:27:30 +0000</pubDate>
      <link>https://dev.to/aznaxdev/stop-writing-try-catch-everywhere-use-global-exception-handling-instead-jm4</link>
      <guid>https://dev.to/aznaxdev/stop-writing-try-catch-everywhere-use-global-exception-handling-instead-jm4</guid>
      <description>&lt;p&gt;Ever found yourself wrapping almost every method with a try-catch block, only to end up with messy, repetitive code? You’re not alone. Handling errors is one of those things every developer does, but not everyone does it well.&lt;/p&gt;

&lt;p&gt;As applications grow, scattered exception handling quickly turns into a maintenance nightmare. Inconsistent error responses, duplicated logic, and hard-to-track bugs start creeping in. That’s where a smarter approach comes in. In this article, we’ll move from basic exception handling to a cleaner, more scalable solution, Global Exception Handling, and see how it can transform the way your application deals with errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Exception Handling&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Exception Handling is a mechanism used in programming to manage runtime errors (exceptions) in a controlled way, so that the program does not crash unexpectedly. An exception is an abnormal event that occurs during the execution of a program, such as:&lt;/p&gt;

&lt;p&gt;⦁ Dividing by zero&lt;br&gt;
⦁ Accessing a null object&lt;br&gt;
⦁ Invalid user input&lt;br&gt;
⦁ File not found&lt;/p&gt;

&lt;p&gt;Instead of stopping the program, exception handling allows developers to catch and handle these errors gracefully.&lt;/p&gt;

&lt;p&gt;In languages like Java, this is done using blocks such as:&lt;/p&gt;

&lt;p&gt;⦁ try – &amp;gt; contains code that may cause an exception&lt;br&gt;
⦁ catch –&amp;gt; handles the exception&lt;br&gt;
⦁ finally -&amp;gt; executes regardless of exception occurrence&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example (Conceptual)&lt;/strong&gt;&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="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ArithmeticException&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Cannot divide by zero"&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;Here, instead of crashing, the program handles the error and continues execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitations of Traditional Exception Handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While basic exception handling is useful, it has some drawbacks:&lt;/p&gt;

&lt;p&gt;⦁ Repeated code across multiple classes&lt;br&gt;
⦁ Hard to maintain in large applications&lt;br&gt;
⦁ Inconsistent error responses&lt;br&gt;
⦁ Difficult to manage all errors centrally&lt;br&gt;
This is where Global Exception Handling becomes important.&lt;/p&gt;
&lt;h2&gt;
  
  
  Global Exception Handling
&lt;/h2&gt;

&lt;p&gt;Global Exception Handling is an advanced approach where all exceptions in an application are handled in one centralized location, rather than handling them individually in each class or method.&lt;/p&gt;

&lt;p&gt;In frameworks like Spring Boot, this is typically implemented using:&lt;br&gt;
⦁ @ControllerAdvice&lt;br&gt;
⦁ @ExceptionHandler&lt;br&gt;
These allow the system to intercept exceptions globally and return a structured, consistent response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
Instead of writing try-catch everywhere, you define a global handler:&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="nd"&gt;@ControllerAdvice&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;GlobalExceptionHandler&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@ExceptionHandler&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;handleException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"Something went wrong: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&lt;/span&gt;&lt;span class="o"&gt;();&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;Now, any exception thrown in the application will be handled here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Global Exception Handling&lt;/strong&gt;&lt;br&gt;
⦁ Centralized error handling&lt;br&gt;
⦁ Cleaner and more readable code&lt;br&gt;
⦁ Consistent error responses&lt;br&gt;
⦁ Easier maintenance and debugging&lt;br&gt;
⦁ Better user experience&lt;br&gt;
⦁ Improved security (no exposure of internal errors)&lt;/p&gt;

&lt;p&gt;Exception Handling helps prevent application crashes by managing runtime errors locally using try-catch. However, in large applications, this approach becomes difficult to manage. &lt;br&gt;
Global Exception Handling solves this by providing a centralized way to handle all exceptions, making the system more organized, maintainable, and user-friendly.&lt;/p&gt;

&lt;h1&gt;
  
  
  java#springboot#backend#exceptionhandling#webdev #programming#softwareengineering #api
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
      <category>java</category>
    </item>
    <item>
      <title>Entity vs DTO vs Model — Stop Using These Terms Interchangeably</title>
      <dc:creator>Azna Aroos</dc:creator>
      <pubDate>Sun, 29 Mar 2026 11:39:23 +0000</pubDate>
      <link>https://dev.to/aznaxdev/entity-vs-dto-vs-model-stop-using-these-terms-interchangeably-bej</link>
      <guid>https://dev.to/aznaxdev/entity-vs-dto-vs-model-stop-using-these-terms-interchangeably-bej</guid>
      <description>&lt;p&gt;Do you ever confuse yourself with the terms Entity, Model, and DTO? Sometimes you might hear your lecturer say that you can call an Entity a Model, but is that really true?&lt;br&gt;
They may sound similar, but they are actually quite different. Let's understand what they really are and what they actually do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Entity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An Entity represents a database table using annotations like &lt;a class="mentioned-user" href="https://dev.to/entity"&gt;@entity&lt;/a&gt;. Think of it as a real table in your database.&lt;br&gt;
Example: Student Table&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="nd"&gt;@Entity&lt;/span&gt;
&lt;span class="nd"&gt;@Table&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"students"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StudentEntity&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Id&lt;/span&gt;
    &lt;span class="nd"&gt;@GeneratedValue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;GenerationType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;IDENTITY&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;Long&lt;/span&gt; &lt;span class="n"&gt;id&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;String&lt;/span&gt; &lt;span class="n"&gt;name&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;String&lt;/span&gt; &lt;span class="n"&gt;email&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;String&lt;/span&gt; &lt;span class="n"&gt;password&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;An Entity is used by JPA/Hibernate. It is tightly coupled to the database and typically contains all fields, including sensitive ones such as passwords.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DTO (Data Transfer Object)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A DTO is used to transfer data between layers.&lt;br&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%2F81irzto8521sok5q7oju.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%2F81irzto8521sok5q7oju.png" alt=" " width="800" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not directly connected to the database. It is a safer, filtered version of your data that you send to the frontend.&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;StudentDTO&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;Integer&lt;/span&gt; &lt;span class="n"&gt;id&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;String&lt;/span&gt; &lt;span class="n"&gt;name&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;&lt;strong&gt;Model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where many people get confused. In Spring Boot, Model is often used as a general term for business objects. In MVC architecture, a Model is specifically used to pass data to views. Sometimes developers use "Model" in place of "Entity," so its meaning depends on the context.&lt;br&gt;
In Spring MVC, a Model is simply used to pass data to a view template like Thymeleaf.&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="nd"&gt;@GetMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/student"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getStudent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Model&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;addAttribute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Aqueel"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"StudentPage"&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;&lt;strong&gt;A Simple Analogy — The Toy Shop&lt;/strong&gt;&lt;br&gt;
Imagine you own a toy shop.&lt;br&gt;
Think of the Entity as your back storage room. It contains everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All toys&lt;/li&gt;
&lt;li&gt;Their cost price&lt;/li&gt;
&lt;li&gt;Supplier details&lt;/li&gt;
&lt;li&gt;Secret discount rules&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's your Entity — directly connected to the database.&lt;br&gt;
When customers walk in, you don't take them to the storage room. You only show them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Toy name&lt;/li&gt;
&lt;li&gt;Selling price&lt;/li&gt;
&lt;li&gt;Color&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You hide the supplier info and purchase price from them. That filtered view is your DTO — a safe version of the data.&lt;br&gt;
The Model is like the receipt at the counter. When someone buys a toy, it shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Toy name&lt;/li&gt;
&lt;li&gt;Quantity&lt;/li&gt;
&lt;li&gt;Total price&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Not Just Use Entity Everywhere?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Security risk — sensitive fields like passwords get exposed.&lt;/li&gt;
&lt;li&gt;- Over-fetching — you return more data than the client actually needs.&lt;/li&gt;
&lt;li&gt;- Tight coupling — your database structure becomes directly tied to your API.&lt;/li&gt;
&lt;li&gt;- Hard to scale — changes to the database will break your API responses.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Golden Rule:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Entity to talk to your database, DTO to talk to the outside world, and Model to talk to your views.&lt;/p&gt;

&lt;p&gt;Think of it this way,&lt;/p&gt;

&lt;p&gt;Entity = what lives in your database 🗄️&lt;br&gt;
DTO = what you show to the world 🌐&lt;br&gt;
Model = what you pass to your UI 🖥️&lt;/p&gt;

&lt;p&gt;Never expose your Entity directly to the frontend. Always filter your data through a DTO. The extra effort keeps your application secure, clean, and scalable.&lt;/p&gt;

&lt;p&gt;Found this helpful? ♻️ Repost to help other developers.&lt;br&gt;
Follow for more tips! 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  SpringBoot #Java #Backend #WebDevelopment #Programming #DTO #JPA #SoftwareEngineering #Developer
&lt;/h1&gt;

</description>
      <category>webdev</category>
      <category>cleancode</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Layered Architecture A Beginner's Guide to Structuring Software Systems</title>
      <dc:creator>Azna Aroos</dc:creator>
      <pubDate>Sun, 08 Mar 2026 16:48:43 +0000</pubDate>
      <link>https://dev.to/aznaxdev/layered-architecture-a-beginners-guide-to-structuring-software-systems-4omm</link>
      <guid>https://dev.to/aznaxdev/layered-architecture-a-beginners-guide-to-structuring-software-systems-4omm</guid>
      <description>&lt;p&gt;Building software is not something you decide to do one minute and start building the next. High-quality software is not just about writing code — it is equally about how efficiently data flows across components, independently and without interruption.&lt;/p&gt;

&lt;p&gt;Software architecture defines how the different parts of an application fit together and interact to enable better data flow. It helps engineers understand how to build a system and, ultimately, helps achieve customer satisfaction by keeping the software focused on real user needs.&lt;/p&gt;

&lt;p&gt;There are many ways to organize software components. Today, we will explore one of the most popular and practical approaches: &lt;strong&gt;Layered Architecture.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🍔 Think of a Burger
&lt;/h2&gt;

&lt;p&gt;Imagine you are making a burger. A burger is built in layers, and each layer has a specific job:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Top Bun&lt;/strong&gt; — holds everything together&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheese&lt;/strong&gt; — adds flavor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vegetables&lt;/strong&gt; — provide freshness and fullness&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beef Patty&lt;/strong&gt; — the heart of the taste&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bottom Bun&lt;/strong&gt; — the foundation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If something goes wrong with the vegetables, you do not throw the whole burger away — you fix the vegetable layer. &lt;strong&gt;Layered Architecture in software works exactly the same way.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A system is divided into layers. Each layer has a specific responsibility. Each layer communicates only with the layer directly adjacent to it. That's it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ The Three Core Layers
&lt;/h2&gt;

&lt;p&gt;In real-world software development, a layered architecture typically consists of three main layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Presentation Layer (UI Layer)&lt;/li&gt;
&lt;li&gt;Business Logic Layer (Service Layer)&lt;/li&gt;
&lt;li&gt;Data Access Layer (Database Layer)&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  01 · Presentation Layer (UI Layer)
&lt;/h3&gt;

&lt;p&gt;This is what users see and interact with. It includes elements such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login page&lt;/li&gt;
&lt;li&gt;Sign-up form&lt;/li&gt;
&lt;li&gt;Buttons and navigation&lt;/li&gt;
&lt;li&gt;Dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Presentation Layer only collects input from the user and displays output back to them. It performs no heavy calculations and does not communicate directly with the database.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Think of it as the waiter in a restaurant.&lt;/strong&gt; The waiter serves the food that the chef prepares in the kitchen — what happens in the kitchen is none of the waiter's business. Each person does only the job they are assigned.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  02 · Business Logic Layer (Service Layer)
&lt;/h3&gt;

&lt;p&gt;This is the &lt;strong&gt;brain&lt;/strong&gt; of the software. It is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validating incoming data&lt;/li&gt;
&lt;li&gt;Applying business rules and logic&lt;/li&gt;
&lt;li&gt;Making decisions based on processed information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples of business logic include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verifying whether the entered password is correct&lt;/li&gt;
&lt;li&gt;Calculating the total bill amount&lt;/li&gt;
&lt;li&gt;Checking whether a user is authorized to access a resource&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This layer does not render any UI and does not store data directly. It simply &lt;strong&gt;thinks and processes.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  03 · Data Access Layer (Database Layer)
&lt;/h3&gt;

&lt;p&gt;This layer handles all communication with the database. Its core operations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Saving data&lt;/li&gt;
&lt;li&gt;Retrieving data&lt;/li&gt;
&lt;li&gt;Updating data&lt;/li&gt;
&lt;li&gt;Deleting data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inserting a new user record into the database&lt;/li&gt;
&lt;li&gt;Fetching user profile details&lt;/li&gt;
&lt;li&gt;Updating an existing profile&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔄 How the Layers Work Together
&lt;/h2&gt;

&lt;p&gt;Consider a user logging into an application. Here is how the request flows through each layer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User enters their username and password → &lt;strong&gt;Presentation Layer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Presentation Layer sends the data to → &lt;strong&gt;Business Logic Layer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Business Logic Layer asks → &lt;strong&gt;Data Access Layer&lt;/strong&gt; to query the database&lt;/li&gt;
&lt;li&gt;Data Access Layer returns the result to → &lt;strong&gt;Business Logic Layer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Business Logic Layer evaluates the result and makes a decision&lt;/li&gt;
&lt;li&gt;Presentation Layer displays &lt;strong&gt;"Login Successful"&lt;/strong&gt; or &lt;strong&gt;"Incorrect Password"&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Each layer performs only its own responsibility — and nothing more.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Why Use Layered Architecture?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Modularity&lt;/strong&gt; — Each layer is independent, making the codebase easier to understand, maintain, and extend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt; — The layered structure enables targeted security measures at each level, protecting the system from a wide variety of threats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy to Modify&lt;/strong&gt; — Changes in one layer, like switching databases, don't affect the others. Each layer is self-contained.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy to Test&lt;/strong&gt; — Each layer can be debugged and tested in isolation, leading to more reliable and faster testing cycles.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Layered Architecture is one of the most foundational patterns in software design. Understanding it is the first step toward building systems that are clean, scalable, and maintainable.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>programming</category>
      <category>webdev</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>SOLID Principles: Writing Code That Survives the Real World</title>
      <dc:creator>Azna Aroos</dc:creator>
      <pubDate>Fri, 27 Feb 2026 07:49:10 +0000</pubDate>
      <link>https://dev.to/aznaxdev/solid-principles-writing-code-that-survives-the-real-world-1k29</link>
      <guid>https://dev.to/aznaxdev/solid-principles-writing-code-that-survives-the-real-world-1k29</guid>
      <description>&lt;p&gt;Writing software is not just about making things work.&lt;br&gt;
It’s about making things work today, tomorrow, and one year from now.&lt;/p&gt;

&lt;p&gt;Last week, we explored Event-Driven Architecture — how systems communicate and scale.&lt;br&gt;
This week, we’re stepping into something even more foundational:&lt;/p&gt;

&lt;p&gt;SOLID Principles&lt;/p&gt;

&lt;p&gt;SOLID is not a framework.&lt;br&gt;
It’s not a library.&lt;br&gt;
It’s a way of thinking.&lt;/p&gt;

&lt;p&gt;Each letter in SOLID represents a principle that helps us design clean, flexible, and maintainable software.&lt;/p&gt;

&lt;p&gt;Before we go technical, imagine yourself as a kid with a lot of toys:&lt;/p&gt;

&lt;p&gt;One toy should do one thing.&lt;/p&gt;

&lt;p&gt;A spoon is for eating.&lt;/p&gt;

&lt;p&gt;A toothbrush is for brushing teeth.&lt;/p&gt;

&lt;p&gt;If your spoon also tried to brush your teeth, that would be weird, right?&lt;br&gt;
That’s where the first principle comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;S – Single Responsibility Principle (SRP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One thing = One job&lt;/p&gt;

&lt;p&gt;A class should have only one responsibility.&lt;br&gt;
It should have only one reason to change.&lt;/p&gt;

&lt;p&gt;If a class handles:&lt;/p&gt;

&lt;p&gt;user registration&lt;/p&gt;

&lt;p&gt;sending emails&lt;/p&gt;

&lt;p&gt;saving data to the database&lt;/p&gt;

&lt;p&gt;…that’s too much responsibility.&lt;/p&gt;

&lt;p&gt;Just like a spoon shouldn’t brush your teeth, a class shouldn’t try to do everything.&lt;/p&gt;

&lt;p&gt;In the real world:&lt;/p&gt;

&lt;p&gt;A chef cooks.&lt;/p&gt;

&lt;p&gt;A driver drives.&lt;/p&gt;

&lt;p&gt;A teacher teaches.&lt;/p&gt;

&lt;p&gt;Clear roles. Clear responsibilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classDiagram
    class UserService {
        +registerUser()
    }
    class EmailService {
        +sendEmail()
    }
    UserService --&amp;gt; EmailService
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Figure 1:&lt;/em&gt; &lt;strong&gt;Single Responsibility Principle (SRP)&lt;/strong&gt; – Each class has only one responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O – Open/Closed Principle (OCP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can add new toys to your toy box without breaking your old ones.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;p&gt;You can extend behavior without modifying existing code.&lt;/p&gt;

&lt;p&gt;Instead of changing old code every time you need something new, you extend it.&lt;br&gt;
Extend. Don’t modify.&lt;/p&gt;

&lt;p&gt;In the real world:&lt;/p&gt;

&lt;p&gt;You don’t break your house walls to add a new device.&lt;/p&gt;

&lt;p&gt;You plug something into an existing socket.&lt;/p&gt;

&lt;p&gt;Good software design allows growth without destruction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classDiagram
    class Payment {
        &amp;lt;&amp;lt;interface&amp;gt;&amp;gt;
        +pay(amount)
    }
    class CreditCardPayment {
        +pay(amount)
    }
    class PayPalPayment {
        +pay(amount)
    }
    class PaymentProcessor {
        +process(payment)
    }
    Payment &amp;lt;|.. CreditCardPayment
    Payment &amp;lt;|.. PayPalPayment
    PaymentProcessor --&amp;gt; Payment

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Figure 2:&lt;/em&gt; &lt;strong&gt;Open–Closed Principle (OCP)&lt;/strong&gt; – Extend functionality without modifying existing code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L – Liskov Substitution Principle (LSP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you replace your chocolate milk with strawberry milk, it should still behave like milk.&lt;/p&gt;

&lt;p&gt;If something is a “type of” something else, it should behave properly as that type.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;We say:&lt;/p&gt;

&lt;p&gt;“A penguin is a bird.”&lt;/p&gt;

&lt;p&gt;But we also say:&lt;/p&gt;

&lt;p&gt;“All birds can fly.”&lt;/p&gt;

&lt;p&gt;Now something feels wrong — penguins can’t fly.&lt;/p&gt;

&lt;p&gt;The problem is not the penguin, it’s our design assumption.&lt;/p&gt;

&lt;p&gt;Rule: Don’t force subclasses to break expectations.&lt;br&gt;
If a subclass cannot fully behave like its parent, your inheritance design is wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classDiagram
    classDiagram
    class Bird
    class FlyingBird {
        &amp;lt;&amp;lt;interface&amp;gt;&amp;gt;
        +fly()
    }
    class Sparrow
    class Penguin
    FlyingBird &amp;lt;|.. Sparrow
    Bird &amp;lt;|-- Sparrow
    Bird &amp;lt;|-- Penguin


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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Figure 3:&lt;/em&gt; &lt;strong&gt;Liskov Substitution Principle (LSP)&lt;/strong&gt; – Subtypes must behave like their parent types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I – Interface Segregation Principle (ISP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In simple words: Don’t force someone to do things they don’t need to do.&lt;/p&gt;

&lt;p&gt;If you give a kid responsibilities like:&lt;/p&gt;

&lt;p&gt;Cook&lt;/p&gt;

&lt;p&gt;Drive&lt;/p&gt;

&lt;p&gt;…that’s too much. Give only what they actually need.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;A TV remote has only TV buttons.&lt;/p&gt;

&lt;p&gt;An AC remote has only AC buttons.&lt;/p&gt;

&lt;p&gt;You don’t mix everything into one giant remote.&lt;/p&gt;

&lt;p&gt;In software, large interfaces are like giant remotes.&lt;br&gt;
Small, specific interfaces are clean and focused.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classDiagram
    class Workable {
        &amp;lt;&amp;lt;interface&amp;gt;&amp;gt;
        +work()
    }
    class Eatable {
        &amp;lt;&amp;lt;interface&amp;gt;&amp;gt;
        +eat()
    }
    class Human
    class Robot
    Workable &amp;lt;|.. Human
    Workable &amp;lt;|.. Robot
    Eatable &amp;lt;|.. Human



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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Figure 4:&lt;/em&gt; &lt;strong&gt;Interface Segregation Principle (ISP)&lt;/strong&gt;– Don’t force classes to implement methods they don’t need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D – Dependency Inversion Principle (DIP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you love only red cars, when that car breaks, your heart breaks too.&lt;/p&gt;

&lt;p&gt;But if you love cars in general, you can easily replace one with another.&lt;/p&gt;

&lt;p&gt;In software: Depend on abstractions, not concrete implementations.&lt;/p&gt;

&lt;p&gt;You plug devices into a wall socket, not directly into a specific power plant.&lt;br&gt;
The socket is the abstraction; the power plant can change.&lt;/p&gt;

&lt;p&gt;When high-level modules depend on abstractions:&lt;/p&gt;

&lt;p&gt;Systems become flexible&lt;/p&gt;

&lt;p&gt;Components become replaceable&lt;/p&gt;

&lt;p&gt;Code becomes easier to maintain&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;classDiagram
    class Database {
        &amp;lt;&amp;lt;interface&amp;gt;&amp;gt;
        +save()
    }
    class MySQLDatabase
    class MongoDatabase
    class OrderService {
        +processOrder()
    }
    Database &amp;lt;|.. MySQLDatabase
    Database &amp;lt;|.. MongoDatabase
    OrderService --&amp;gt; Database




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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Figure 5:&lt;/em&gt; &lt;strong&gt;Dependency Inversion Principle (DIP)&lt;/strong&gt; – Depend on abstractions, not concrete implementations.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;SOLID principles are not just theory.&lt;br&gt;
They help you write code that:&lt;/p&gt;

&lt;p&gt;Is easier to understand&lt;/p&gt;

&lt;p&gt;Is easier to extend&lt;/p&gt;

&lt;p&gt;Is easier to maintain&lt;/p&gt;

&lt;p&gt;Doesn’t break easily&lt;/p&gt;

&lt;p&gt;Good design today saves you from pain tomorrow.&lt;br&gt;
When you follow SOLID, your software grows cleanly — just like a well-organized toy box.&lt;/p&gt;

&lt;p&gt;💬 What About You?&lt;/p&gt;

&lt;p&gt;Have you ever worked on a project where poor design caused problems later?&lt;br&gt;
Which SOLID principle do you struggle with the most?&lt;br&gt;
Let’s discuss in the comments 👇&lt;/p&gt;

</description>
      <category>programming</category>
      <category>learning</category>
      <category>backend</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Understanding Event-Driven Architecture (With a Simple Example)</title>
      <dc:creator>Azna Aroos</dc:creator>
      <pubDate>Wed, 18 Feb 2026 14:06:25 +0000</pubDate>
      <link>https://dev.to/aznaxdev/understanding-event-driven-architecture-with-a-simple-example-1gfj</link>
      <guid>https://dev.to/aznaxdev/understanding-event-driven-architecture-with-a-simple-example-1gfj</guid>
      <description>&lt;p&gt;Imagine you're at your best friend’s birthday party.&lt;/p&gt;

&lt;p&gt;When she blows out the candles, people clap.&lt;br&gt;
When the music starts, people dance.&lt;/p&gt;

&lt;p&gt;No one gives instructions like:&lt;br&gt;
“Everyone, clap now!” or “Everyone must dance!”&lt;/p&gt;

&lt;p&gt;People simply react to what happens.&lt;/p&gt;

&lt;p&gt;This is exactly how Event-Driven Architecture (EDA) works in software systems.&lt;/p&gt;

&lt;p&gt;What Is Event-Driven Architecture?&lt;/p&gt;

&lt;p&gt;Event-Driven Architecture is a design pattern where:&lt;/p&gt;

&lt;p&gt;A system produces an event (something that happened).&lt;/p&gt;

&lt;p&gt;Other parts of the system listen for that event.&lt;/p&gt;

&lt;p&gt;They react independently.&lt;/p&gt;

&lt;p&gt;No component directly tells another component what to do.&lt;br&gt;
They communicate through events, not direct calls.&lt;/p&gt;

&lt;p&gt;This makes the system loosely coupled, scalable, and flexible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traditional Approach vs Event-Driven&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traditional (Tightly Coupled)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`public void placeOrder(Order order) {
    inventoryService.updateStock(order);
    emailService.sendConfirmation(order);
    billingService.createInvoice(order);
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;p&gt;The order service directly controls everything.&lt;/p&gt;

&lt;p&gt;If we add a new feature, we must modify this method.&lt;/p&gt;

&lt;p&gt;The system becomes tightly coupled.&lt;/p&gt;

&lt;p&gt;Event-Driven Approach (Loosely Coupled)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`public void placeOrder(Order order) {
    eventPublisher.publish(new OrderPlacedEvent(order));
}`

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

&lt;/div&gt;



&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inventory listens to OrderPlacedEvent&lt;/li&gt;
&lt;li&gt;Email listens to OrderPlacedEvent&lt;/li&gt;
&lt;li&gt;Billing listens to OrderPlacedEvent&lt;/li&gt;
&lt;li&gt;Each module reacts independently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Real Backend Example&lt;/p&gt;

&lt;p&gt;When a user places an order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inventory service updates stock.&lt;/li&gt;
&lt;li&gt;Email service sends confirmation.&lt;/li&gt;
&lt;li&gt;Billing service creates an invoice.&lt;/li&gt;
&lt;li&gt;Analytics service records the transaction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If tomorrow you want to add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Notification service&lt;/li&gt;
&lt;li&gt; Fraud detection service &lt;/li&gt;
&lt;li&gt; Loyalty points service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t modify existing code.&lt;br&gt;
You simply add a new listener.&lt;/p&gt;

&lt;p&gt;That’s powerful.&lt;/p&gt;

&lt;p&gt;Benefits of Event-Driven Architecture&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loose Coupling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Services don’t depend directly on each other.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can scale consumers independently.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Flexibility&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;New features can be added without touching existing logic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cleaner Architecture&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Clear separation of responsibilities.&lt;/p&gt;

&lt;p&gt;Where Is It Used?&lt;/p&gt;

&lt;p&gt;Microservices architectures&lt;/p&gt;

&lt;p&gt;E-commerce systems&lt;/p&gt;

&lt;p&gt;Payment systems&lt;/p&gt;

&lt;p&gt;Real-time applications&lt;/p&gt;

&lt;p&gt;Distributed systems&lt;/p&gt;

&lt;p&gt;Tools commonly used:&lt;/p&gt;

&lt;p&gt;Kafka&lt;/p&gt;

&lt;p&gt;RabbitMQ&lt;/p&gt;

&lt;p&gt;AWS SNS/SQS&lt;/p&gt;

&lt;p&gt;Spring Events&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;Event-Driven Architecture is not just a technical concept.&lt;br&gt;
It’s a mindset shift — from commanding components to letting them react.&lt;/p&gt;

&lt;p&gt;Just like people reacting at a birthday party.&lt;/p&gt;

&lt;p&gt;If you're interested in exploring backend architecture in code, feel free to check my project here:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/AznaX97/RoleBasedVisitorManagementAPI" rel="noopener noreferrer"&gt;https://github.com/AznaX97/RoleBasedVisitorManagementAPI&lt;/a&gt;&lt;/p&gt;

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