How to break apart layers in a strict-layered architecture and promote modularity without causing unnecessary redundancy?

I would disagree with this standard layered architecture in favor of a onion architecture.

enter image description here

According to that, I can give a try at your questions:

1. Are my naming conventions for each module and its respective assembly following standard conventions, or is there a different way I should be going about this?

Yes, I would agree that it is not a bad convention, and pretty much standard.

2. Is it beneficial to break apart the business and data layers into multiple assemblies?

Yes, but I rather have one assembly called Domain (usually Core.Domain) and other one called Data (Core.Data). Domain assembly contains all the entities (as per domain-driven-design) along with repository interfaces, services, factories etc... Data assembly references the Domain and implements concrete repositories, with an ORM.

3. Is it beneficial to have the interfaces and abstract classes for each layer in their own assemblies?

Depending on various reasons. In the answer to the previous question, I've mentioned separating interfaces for repositories into the Domain, and concrete repositories in Data assembly. This gives you clean Domain without any "pollution" from any specific data or any other technology. Generally, I base my code by thinking on a TDD-oriented level, extracting all dependencies from classes making them more usable, following the SRP principle, and thinking what can go wrong when other people on the team use the architecture :) For example, one big advantage of separating into assemblies is that you control your references and clearly state "no data-access code in domain!".

4. Is it beneficial to have an "Entities" assembly for both the business and data layers?

I would disagree, and say no. You should have your core entities, and map them to the database through an ORM. If you have complex presentation logic, you can have something like ViewModel objects, which are basically entities dumbed down just with data suited for representation in the UI. If you have something like a network in-between, you can have special DTO objects as well, to minimize network calls. But, I think having data and separate business entities just complicates the matter.

One thing as well to add here, if you are starting a new architecture, and you are talking about an application that already exists for 10 years, you should consider better ORM tools from LINQ-to-SQL, either Entity Framework or NHibernate (I opt for NHibernate in my opinion).

I would also add that answering to as many question as there are in one application architecture is hard, so try posting your questions separately and more specifically. For each of the parts of architecture (UI, service layers, domain, security and other cross-concerns) you could have multiple-page discussions. Also, remember not to over-architecture your solutions, and with that complicating things even more then needed!


I actually just started the same thing, so hopefully this will help or at least generate more comments and even help for myself :)

1. Are my naming conventions for each module and its respective assembly following standard conventions, or is there a different way I should be going about this?

According to MSDN Names of Namespaces, this seems to be ok. They lay it out as:

<Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>]
For example, Microsoft.WindowsMobile.DirectX.

2.Is it beneficial to break apart the business and data layers into multiple assemblies?

I definitely think its beneficial to break apart the business and data layers into multiple assemblies. However, in my solution, I've create just two assemblies (DataLayer and BusinessLayer). The other details like Interfaces, Workflows, etc I would create directories for under each assembly. I dont think you need to split them up at that level.

3.Is it beneficial to have the interfaces and abstract classes for each layer in their own assemblies?

Kind of goes along with the above comments.

4.Is it beneficial to have an "Entities" assembly for both the business and data layers?

Yes. I would say that your data entities might not map directly to what your business model will be. When storing the data to a database or other medium, you might need to change things around to have it play nice. The entities that you expose to your service layer should be useable for the UI. The entities you use for you Data Access Layer should be useable for you storage medium. AutoMapper is definitely your friend and can help with mapping as you mentioned. So this is how it shapes up:

Service Layer Details
(source: microsoft.com)


1) The naming is absolutely fine, just as SwDevMan81 stated.

2) Absolutely, If WCF gets outdated in a few years, you'll only have to change your DAL.

3) The rule of thumb is to ask yourself this simple question: "Can I think of a case where I will make smart use of this?".
When talking about your WCF contracts, yes, definitely put those in a separate assembly: it is key to a good WCF design (I'll go into more details).
When talking about an interface defined in AssemblyA, and is implemented in AssemblyB, then the properties/methods described in those interfaces are used in AssemblyC, you are fine as long as every class defined in AssemblyB is used in C through an interface. Otherwise, you'll have to reference both A, and B: you lose.

4) The only reason I can think of to actually move around 3 times the same looking object, is bad design: the database relations were poorly crafted, and thus you have to tweak the objects that come out to have something you can work with.
If you redo the architecture, you can have another assembly, used in pretty much every project, called "Entities" that holds the data objects. By every project i meant WCF as well.

On a side note, I would add that the WCF service should be split into 3 assemblies: the ServiceContracts, the Service itself, and the Entities we talked about. I had a good video on that last point, but it's at work, i'll link it tomorow!

HTH,

bab.

EDIT: here is the video.