Many solutions to this problem can be found; the one below
may not be the best, but it suits me well. Some developers may instantiate the
Combos class in each Remote Object. I find this
solution to be resource consuming.
What I would do is to create a single instance of Combos shared by all remote objects created on the
Application Server. The way to do so is to apply the Singleton Design Pattern
to this class. Here is a sample showing how this can be done.
In the Business Tier you will be defining the Combos class as listed in Listing 1.
Public Class Combos
Private Shared _Instance As Combos
Public Shared ReadOnly Property Instance() As Combos
'Using lazy instantiation
If _Instance Is Nothing Then _Instance = New Combos
'Note that the constructor method is Protected (it can be Private)
Protected Sub New()
'Write some code here
As you can see, if it exists, an instance of Combos is accessed by all Remote Objects through the Instance property. If it does not exist, a new (and
unique) instance of Combos will be created and
returned through the same Instance property.
In the Presentation Tier all you need to do is to call the Instance property and assign its return value to a variable
of type Combos as shown in Listing 2.
Private Sub GetCountries()
Dim Cbo As Combos = Combos.Instance
ddlCountries.DataSource = Cbo.GetCountries()
ddlCoutries.DataTextField = "CountryName"
ddlCountries.DataValueField = "CountryId"