I'm new to CSLA, and am "kicking tires". Simplest way to ask my basic question:
Does every CSLA business object need to directly inherit from BusinessBase(Of T), for example?
I have a very simple test application working with this hierarchy:
BusinessBase(Of T)
UsrGrp (inherits BusinessBase(Of UsrGrp)
An add-to-database operation is working OK.
What I WANT to do is this:
BusinessBase(Of T)
MyLocalBase(inherits BusinessBase(Of MyLocalBase)
UsrGrp(inherits MyLocalBase)
MyLocalBase would exist only to contain common private variables with getters and setters as needed. My "want-to" version of UsrGrp would be the same except for the diversion of the common private variables to MyLocalBase.
I have built my "want-to" version of the application, but I get a compile error on the Save() method in UsrGrp:
Public Overrides Function Save() As UsrGrp' cannot override 'Public Overridable Function Save() As Base.MyLocalBase' because they differ by their return types....
I get a compile to work (and successful add-to-database operation) by this code change:
From - Public Overrides Function Save() As UsrGrp
To - Public Shadows Function Save() As UsrGrp
I've played the software game long enough to suspect that Shadows keyword may be a tool for kludge workarounds, and, sure enough, I found the following advice:
"Avoid Shadows (Visual Basic) or new (C#) keywords in favor of Overridable and virtual keywords, respectively, to redefine methods and properties in derived types."
from "Practical Guidelines and Best Practices For Microsoft Visual Basic and Visual C# Developers" by Balena and Dimauro, page 54
Am I OK with the Shadows thing? If I someday want to then extend UsrGrp, does Shadows cause a problem?
Is there something in my approach that is questionable? A better way?
I looked in the forum for a bit, but didn't find this topic covered.
Thank you in advance!
Your base class that inherits from CSLA is recommended.
But maybe you shouldn't have the Save method in it.
Joe
Thank you both, Brian and Joe, for responding.
Generics are a new beast to me, and they "dumbed me down" momentarily.
GEM
Copyright (c) Marimer LLC