Should I avoid 'chained' references in Visual Studio with class libraries?

.net, architecture, c#, reference, visual-studio

Solution

It's not wrong per se, the compiler will do The Right Thing®.

But it could be an indication of a not-so-great design.

Try to design the three layers in such a way that 2 only depends on 3, and that 1 only depends on 2.

Edit: the last sentence wasn't clear. What I meant was: "design the three layers so that your business objects only need to reference the data access code, and that the UI only deals with business objects".

Ultimately, the right way to do it really depends on your architecture (use of ORM vs issuing queries manually, Active Record vs Mapper and the like).

Problem

I have something like the following setup in a Visual Studio C# .NET solution: Project 1 - TrainDisplay - a WinForms application to display train arrivals. Project 2 - TrainFetcher - is a re-usable class library to fetch data about trains. Project 3 - TrainsDataModel is a data model, containing classes common to all other projects, e.g. Train.cs, TrainRoute.cs and so on. Each has the following references: Project 1 : References 2 and 3 Project 2 : References 3 Is it bad to use references in this way; i.e. does project 1 end up with two references to project 3; one direct, and one via project 2?

Original source