scarface7
asked on
Delegates and Events as component technology for GoF Observer pattern ?
I am a college student trying to build a small Windows Application in Visual Studio 2005.
Business Context:
Simulation of Computer science department that contains faculty, students, courses, programs, registration process etc.
My Question:
One aspect of the project requires me to simulate students enrolling/dropping classes, and the automatic notification to a faculty member when an enrollment is reached. Is delegates and events the best way to implement this in C# ? Does this involve a lot of code? Any good implementation strategies on this with respect to C# ?
Is there any good component technology that can be readily used to capture the Gang of Four Observer design pattern that can be applied to the above problem ?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So if you wanted to use events then you could raise an event when a student is enrolled. Then another class can handle that event and do what it needs to do. Since this is homework I don't want to give away too much, but you could definitely use events in your situation (which really is pretty much the observer pattern).
CORRECTION:
The line that reads:
the observer notifies all of the "subjects" when something interesting happens
should read:
the "subject" notifies all of the "observers" when something interesting happens.
Sorry about the confusion.
The line that reads:
the observer notifies all of the "subjects" when something interesting happens
should read:
the "subject" notifies all of the "observers" when something interesting happens.
Sorry about the confusion.
ASKER
Nice explanation !
private void button_Click(object sender, System.EventArgs e)
{
numberCounter.CountToTen()
}