CosmicCharlie
Programmer
I have a problem making inheritance work the way I would expect it. Here is the scenario:
I have three projects that work together in a standard desktop solution. The first project is called DAL, which compiles to a DLL that works as a generic data layer that can talk to any database in my company’s system. It includes an abstract class called dalDataEntity, which defines an interface for data objects representing tables in my company’s databases. dalDataEntity defines a public, readonly property of ColumnCount. ColumnCount is not overridable. ColumnCount represents the number of columns in the table or resultset represented by a class derived from dalDataEntity.
The second project is called SalesData, which contains a bunch of classes that inherit from dalDataEntity. Each class corresponds to a table in our Sales database. Currently, SalesData has a project reference to DAL. ColumnCount is not referenced anywhere in the code for the classes in this project.
The third project is SalesUI, which is the presentation tier of our sales application. This project contains a project reference to SalesData and uses SalesData objects to do its work. However, it does NOT contain a reference to DAL.
Here is the problem: When I am writing code in SalesUI for a data object from SalesData, ColumnCount appears in Intellisense just like any accessible member of the data object. However, I get a design time error in my task list saying
Public Overridable Readonly Property ColumnCount() as Long is declared in project DAL.exe, which is not referenced by project SalesUI.exe
The only way I can use ColumnCount, apparently, is if I set a reference to DAL in SalesUI. Indeed, if I do set the reference, the property works just fine. But it seems to me that if VB.Net allowed true object oriented design, that SalesUI should not need a reference to DAL, since SalesData should take care of that relationship.
Can anyone shed light on this for me? What is the best approach to this situation? Do I have to set the reference to DAL, or is there a way to keep the UI and data layers truly separate?
Thank you.
Cosmic Charlie
I have three projects that work together in a standard desktop solution. The first project is called DAL, which compiles to a DLL that works as a generic data layer that can talk to any database in my company’s system. It includes an abstract class called dalDataEntity, which defines an interface for data objects representing tables in my company’s databases. dalDataEntity defines a public, readonly property of ColumnCount. ColumnCount is not overridable. ColumnCount represents the number of columns in the table or resultset represented by a class derived from dalDataEntity.
The second project is called SalesData, which contains a bunch of classes that inherit from dalDataEntity. Each class corresponds to a table in our Sales database. Currently, SalesData has a project reference to DAL. ColumnCount is not referenced anywhere in the code for the classes in this project.
The third project is SalesUI, which is the presentation tier of our sales application. This project contains a project reference to SalesData and uses SalesData objects to do its work. However, it does NOT contain a reference to DAL.
Here is the problem: When I am writing code in SalesUI for a data object from SalesData, ColumnCount appears in Intellisense just like any accessible member of the data object. However, I get a design time error in my task list saying
Public Overridable Readonly Property ColumnCount() as Long is declared in project DAL.exe, which is not referenced by project SalesUI.exe
The only way I can use ColumnCount, apparently, is if I set a reference to DAL in SalesUI. Indeed, if I do set the reference, the property works just fine. But it seems to me that if VB.Net allowed true object oriented design, that SalesUI should not need a reference to DAL, since SalesData should take care of that relationship.
Can anyone shed light on this for me? What is the best approach to this situation? Do I have to set the reference to DAL, or is there a way to keep the UI and data layers truly separate?
Thank you.
Cosmic Charlie