This has turned into a bit of a ramble I am sorry but I am not sure of your level of knowledge so trying to keep this simple!
When designing your system you need to think about how you want to structure it. Just like in the real world it is nice to organise things in logical places rather than just pile them up in the middle of the room! In theory you could put everything inside the MAIN method of your application but that would be hard to read and maintain. So, instead we break things out into methods so that you can see what is happening more easily.
This then scales up into breaking methods out into classes. If you have lots of methods that all relate to a User then it would make sense to create a class called User
and put all of the methods in that class. That way should you, or another developer, want to do anything that involves users you know that it is probably located in the User
class.
Following on from there you may find that some classes make sense to be grouped together. For example you might have the classes User
, Books
, Location
, Animal
and think that these are all models of things so then you would create a Class Library containing them. This is compiled into a DLL. You might then think I want all of my Data Access code to be in another Class Library because it makes sense to group all of that together.
So, you can see it really comes down to how you think it is best to group things. The most common approach is to have your User Interface (whether that is MVC, Web Forms, Win Forms, WPF etc), then your Business Logic and then your Data Access as the three main layers. Of course, within each layer you may have multiple DLLs but it is just a way of organising things to make it easier for you to maintain and others to understand. It has never been a good idea to just dump everything in one big CS file!