Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organise class files in C#

I am working on a simple project and I have created several classes, interfaces, one static class and so on. What I am asking is, how to organise this files into namespaces. Is there any good practice for this or I should just follow the logic of my program. I am currently thinking that I should move the interfaces into one namespace and all the classes into another. So what can you advise me. I am really curious to find out the best way to separate my files.

Have a nice day :)

like image 252
Stoimen Avatar asked Feb 24 '23 14:02

Stoimen


1 Answers

You should group your code in namespace with other types which have the highest cohesion. That is, group types together when they perform common functionality. The type of cohesion you're suggesting is logical cohesion, and is really a rather weak form of cohesion.

like image 67
Mark H Avatar answered Mar 06 '23 21:03

Mark H