C
C#15mo ago
Ben

❔ Naming Conventions N-Tier architecture, conflicts?

Hey! Would like to hear additional feedbacks regarding this naming approach and a suggestion to solve conflicts. The general naming idea is explained in details here - https://softwareengineering.stackexchange.com/a/259840/429884 The summarize example would be (Taking User entity as example) -
ProjectName ->

ProjectName.API ->
Controllers ->
User ->
UserController.cs
UserStatisticsReport.cs

ProjectName.Model ->
User ->
User.cs

ProjectName.Business ->
User ->
UserLogic.cs

ProjectName.Data ->
DataLayer.cs
IRepository.cs
User ->
UserRepository.cs
ProjectName ->

ProjectName.API ->
Controllers ->
User ->
UserController.cs
UserStatisticsReport.cs

ProjectName.Model ->
User ->
User.cs

ProjectName.Business ->
User ->
UserLogic.cs

ProjectName.Data ->
DataLayer.cs
IRepository.cs
User ->
UserRepository.cs
*If the logic class gets too big we break it down to CQRS classes. Following the convention above how would you avoid explicitly writing namespaces between the Model layer and the Business layer? For example, you have this namespace in your Model layer - ProjectName.Models.User With a class called - User.cs. And this namespace in your Logic layer - ProjectName.Logic.User with a class called - UserLogic.cs. You can't use User.cs in UserLogic.cs without specifying its entire namespace as User is part of the Logic namespace What do you think? thx!
3 Replies
JakenVeina
JakenVeina15mo ago
there is nothing wrong with writing out namespaces when referencing types that's what namespaces are FOR if it were me, this would be the structure
ProjectName ->

ProjectName.API ->
Controllers ->
Users ->
Controller.cs
StatisticsReport.cs

ProjectName.Business ->
Users ->
Logic.cs

ProjectName.Data ->
DataLayer.cs
IRepository.cs
Users ->
Model.cs
Repository.cs
ProjectName ->

ProjectName.API ->
Controllers ->
Users ->
Controller.cs
StatisticsReport.cs

ProjectName.Business ->
Users ->
Logic.cs

ProjectName.Data ->
DataLayer.cs
IRepository.cs
Users ->
Model.cs
Repository.cs
alternatvely, Entity.cs instead of Model.cs
Ben
Ben15mo ago
If thats an a-ok practice I'll keep it as is and write the namespaces explcity when needed. In regards to your structure, I don't feel comfortable enough to put all my trust on the namespace 😅 Thanks!
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.