Reputation: 5131
My immediate issue is that currently I have a 3 tier solution (Presentation.aspx.vb calls BusinessLayer.vb which calls DataAccessLayer.vb). However, I want to make BusinessLayer and DataAccessLayer.vb abstract classes because several Webforms will use have the same functionality.
So I currently am doing this (no abstract classes):
'Presentation Layer (pseudocode)
public sub checkUser(byval userName as string, byval dept as string)
dim isGood as boolean = BL.checkUserAccess(userName, dept)
'some more code
'change properties of webcontrols, etc
end sub
'Business Layer (pseudocode)
public function checkUserAccess(byval name as string, byval group as string) as boolean
dim accessObject as dataObject = DAL.checkPermissions(name, group)
if accessObject.isHighAccess then
'some code
else
'some other code
end if
end function
'Data Access Layer (pseudocode)
public function checkPermissions(byval userid as string, byval section as string) as dataObject
'some code
end function
However can I still have this structure if I add abstract classes?
For instance:
'Presentation Layer (pseudocode)
public sub checkUser(byval userName as string, byval dept as string)
dim isGood as boolean = instOne_BL.checkUserAccess(userName, dept)
'some more code
'change properties of webcontrols, etc
end sub
'Business Layer (pseudocode)
public class instOne_BL inhertis BL
public function checkUserAccess(byval name as string, byval group as string) as boolean
base.checkUserAccess(name, group)
instOne_DAL.checkPermissions(name, group)
end function
end class
'Data Access Layer (pseudocode)
public class instOne_DAL inherits DAL
public function checkPermissions(byval userid as string, byval section as string) as dataObject
base.checkPermissions(userid, section)
end function
end class
Upvotes: 0
Views: 797
Reputation: 44941
If you use .Net remoting as the communication layer between the layers, then this is no problem at all (it's just like calling a method in another class within the current layer).
If you use WCF, then this will also work, buy you need to do a little more work. The base/abstract class must be decorated with KnownType attributes of all inheriting classes that you expect to pass.
If you use web services, then this is not possible without playing some games. For example, you would need to serialize the object into a string using the binary serializer and then deserialize it on the other end.
Upvotes: 1