👋 Hello, I'm Hlex! Passionate about coding, viewing it as an art form that demands patience and creativity. Always learning and expanding my tech skills. 💻🚀
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Currently building Litlyx, the simplest way to track website analytics without cookies. AI, FOSS & and Privacy-first. Find out more at Litlyx.com/philosophy. I build for many, not just one.
MVVM, Clean architeture is a standard for very large and complex code bases that need a structure. I used when i was a enloyee in a big company. I rember that the barrier was really big for a person who is not a "at his prime" so sometimes scares the people. But is the optimal solution for large scale codebases.
Good work.
Antonio, CEO at Litlyx
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Thanks for this great article but I have some questions that need to clarify.
1- Entities: Represent the core business objects of the application. They encapsulate the most general and high-level rules. They are typically rich domain objects containing business rules and logic.
I believe entities shouldn't have any business logic and if you need to have some validation rules we can keep it in use cases or in a helper class to validate data before saving, is that right ?
2- User interface: Include the UI, database, web frameworks, and any other external tools or delivery mechanisms. These are the outermost layer and have the least amount of code.
the user interface layer is just part of the framework & drivers layer and this layer includes (DB - Devices - Web - UI - External Interfaces).
Comment hidden by post author - thread only accessible via permalink
Your diagram looks more like rectangles instead of circles 😀. I've always wondered, is there an actual difference in what the circlular clean architecture diagrams depict vs the non-circular diagrams?
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
Let's say we have an entity called order and i want make sure when set quantity it must >0 we will do the following
public class Order
{
public int Quantity { get; private set; }
public void SetQuantity(int quantity)
{
if (quantity <= 0)
{
throw new ArgumentException("Quantity must be greater than zero.");
}
Quantity = quantity;
}
}
as you see the i make private set and create method for validate the quantity
This encapsulates the business rule within the entity, making it easier to maintain and understand
Technical Project Lead at SURE Egypt with 20+ years in software development. Specializes in .Net, and SQL Server. Passionate about delivering quality solutions
sorry, I misunderstood your question. To clarify, we can add business rule in APP core
public interface IOrderService
{
void SetOrderQuantity(Order order, int quantity);
}
// Application Core - Service Implementation
public class OrderService : IOrderService
{
public void SetOrderQuantity(Order order, int quantity)
{
if (quantity <= 0)
{
throw new ArgumentException("Quantity must be greater than zero.");
}
order.SetQuantity(quantity);
}
}
Some comments have been hidden by the post's author - find out more
We're a place where coders share, stay up-to-date and grow their careers.
Can you next time provide an example of project with clean architecture? Thanks.
soon
example using .net core API
github.com/mohamedtayel1980/clean-...
MVVM, Clean architeture is a standard for very large and complex code bases that need a structure. I used when i was a enloyee in a big company. I rember that the barrier was really big for a person who is not a "at his prime" so sometimes scares the people. But is the optimal solution for large scale codebases.
Good work.
Antonio, CEO at Litlyx
thanks
There is also hexagon architecture. Maybe you can compere.
I can add one article for reference (sorry for medium)
"Hexagonal Architecture, there are always two sides to every story"
medium.com/ssense-tech/hexagonal-a...
jmgarridopaz.github.io/content/art...
ok
This is rich
thanks
منور يا هندسة💕
For mobile and large codebase I have switched to a Vertical architecture + clean design approach nowadays just easier to manage the base.
Great article
thanks
Thanks for this great article but I have some questions that need to clarify.
Your diagram looks more like rectangles instead of circles 😀. I've always wondered, is there an actual difference in what the circlular clean architecture diagrams depict vs the non-circular diagrams?
FYI, if your article was assisted by AI, you should disclose that or tag it appropriately.
dev.to/devteam/guidelines-for-ai-a...
How would a business rule be applied on an entity-field (if the only way is in)?
Let's say we have an entity called order and i want make sure when set quantity it must >0 we will do the following
public class Order
{
public int Quantity { get; private set; }
}
as you see the i make private set and create method for validate the quantity
This encapsulates the business rule within the entity, making it easier to maintain and understand
In that case, the business rule is "hidden" in the entity, which is not in the Application Core.
sorry, I misunderstood your question. To clarify, we can add business rule in APP core
public interface IOrderService
{
void SetOrderQuantity(Order order, int quantity);
}
// Application Core - Service Implementation
public class OrderService : IOrderService
{
public void SetOrderQuantity(Order order, int quantity)
{
if (quantity <= 0)
{
throw new ArgumentException("Quantity must be greater than zero.");
}
order.SetQuantity(quantity);
}
}