I have the following class which loads a set of tasks, the problem is I now need a LoadScheduled Tasks, is it recommended that I provide an optional parameter to GetInstance so that instead of calling Load it calls Load Tasks, the tasks cannot be filtered so I have to go this way they call a completely different area

 Private Shared _taskMgr As TaskMgr

    Public Shared Function GetInstance() As TaskMgr
        If _taskMgr Is Nothing Then
            _taskMgr = New TaskMgr
        End If
        Return _taskMgr
    End Function

    Protected Sub New()
    End Sub
    Public Sub Add(ByVal task As Task)
        Dictionary.Add(task.TaskID, task)
    End Sub

    Public Function Item(ByVal Key As Object) As Task
        Return CType(Dictionary.Item(Key), Task)
    End Function

    Public Sub Remove(ByVal Key As Object)
    End Sub

    Private Sub Load()
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>is it recommended that I provide an optional parameter to GetInstance so that instead of calling Load it calls Load Tasks

GetInstance is not calling Load, your constructor is calling Load. And you can have multiple constructors with different parameters.
rocky050371Author Commented:
Get instance does call load, as it create a new instance which in turn calls load. I refer in code to get instance to save creating a new object each time
GetInstance is implementing what is known as a Singleton pattern.  That is, you will only ever have a SINGLE instance of TaskMgr.  If, when GwetInstance is call, there is no instance of TaskMgr already created, a new one will be created.  However, when GetInstance is called and a instance of TaskMgr already exists, having been created previously, then that instance will be return, and in that case, Load is NOT called.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

rocky050371Author Commented:
I know it is a singleton pattern, that is what I intended, my issues is whether it is acceptable to initiate GetInstance with an optional parameter which loads a different set of tasks
I don't see any problem. But I think you should overload the GetInstance instead of using optional parameter.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rocky050371Author Commented:
Yeah I think you are right
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.