Reason to create a project in .NET

This is a follow up to my previous article. Tends to be a recurring issue. Developers seem to follow existing patterns well and sometimes we tend start patterns inadvertently that are not ideal. One thing I see is creating a new .NET project just for organizing code. Multiple projects in .NET are best for how you plan to deploy your code. Namespaces and solution folders are a better choice for organizing code. For example, here are some good reasons for a project in .NET.

Reason to create a project in .NET

  1. You want to deploy it to a different server than other code. Breaking your web site code from you web service code is an example.
  2. You want to share your code with different client app code. Breaking your business layer out to be reused in multiple web services is an example.
  3. You want to version your code separately from other code. Or you have code that rarely changes.
  4. You want to load and unload your code dynamically.
  5. You don’t always want the code deployed with other code.
  6. It may be that your libraries are too large, and you want to have a few smaller libraries instead.
  7. You want to limit what is referenced in your library, reducing the total output to the bin.
  8. You want to encapsulate the implementation. For example, maybe you don’t want your business layer project to reference the data access such as SQL Server.
  9. For securing code. This is useful if you want to secure code from just anyone accessing it.

Organizing code

When designing projects, be sure to weight the benefits of breaking your code up into projects by layers and types and even further by domain. Ideally, you want things to be decoupled and plug-and-play like so that it is easy to move them around. Putting your business layer, data access layer and types into the same library is not a bad option for most scenarios. There really isn’t a lot of gain with sharing types across business domains. Breaking your data access out into separate libraries doesn’t really benefit you much (unless you are doing microservices or something similar).

Leave a comment