Is a base class with shared fields and functions good design
Posted
by eych
on Stack Overflow
See other posts from Stack Overflow
or by eych
Published on 2010-04-22T20:56:51Z
Indexed on
2010/06/05
13:02 UTC
Read the original article
Hit count: 290
I've got a BaseDataClass with shared fields and functions
Protected Shared dbase as SqlDatabase
Protected Shared dbCommand as DBCommand
...
//also have a sync object used by the derived classes for Synclock'ing
Protected Shared ReadOnly syncObj As Object = New Object()
Protected Shared Sub Init() //initializes fields, sets connections
Protected Shared Sub CleanAll() //closes connections, disposes, etc.
I have several classes that derive from this base class. The derived classes have all Shared
functions that can be called directly from the BLL with no instantiation.
The functions in these derived classes call the base Init(), call their specific stored procs, call the base CleanAll() and then return the results.
So if I have 5 derived classes with 10 functions each, totaling 50 possible function calls, since they are all Shared
, the CLR only calls one at a time, right? All calls are queued to wait until each Shared
function completes.
Is there a better design with having Shared
functions in your DAL and still have base class functions? Or since I have a base class, is it better to move towards instance methods within the DAL?
© Stack Overflow or respective owner