TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohammed Mostafa
NA
13
0
Strategy Pattern VS Static Class
Oct 7 2011 11:06 AM
need someone professional help me get the difference beteen
first :
static
class
SimpleMathOperations
{
public
static
double
add(
double
a,
double
b) {
return
a + b; }
public
static
double
subtract(
double
a,
double
b) {
return
a - b; }
public
static
double
multiply(
double
a,
double
b) {
return
a * b; }
public
static
double
divide(
double
a,
double
b) {
return
a / b; } }
second : Implementing the strategy pattern
public
interface
IMathOperation {
double
PerformOperation(
double
A,
double
B); }
//
ADD -----------------------------------------------
class
AddOperation: IMathOperation
{
#region
IMathOperation Members
public
double
PerformOperation(
double
A,
double
B)
{
return
A + B; }
#endregion
}
//
Subtract -----------------------------------------------
class
SubtractOperation: IMathOperation
{
#region
IMathOperation Members
public
double
PerformOperation(
double
A,
double
B)
{
return
A - B; }
#endregion
}
//
MULTILPY -----------------------------------------------
class
MultiplyOperation: IMathOperation
{
#region
IMathOperation Members
public
double
PerformOperation(
double
A,
double
B) {
return
A * B; }
#endregion
}
//
DIVIDE -----------------------------------------------
class
DivideOperation: IMathOperation
{
#region
IMathOperation Members
public
double
PerformOperation(
double
A,
double
B) {
return
A/B; }
#endregion
}
I quoted strategy pattern from this website
http://www.c-sharpcorner.com/UploadFile/rmcochran/strategyPattern08072006095804AM/strategyPattern.aspx
[
^
]
Reply
Answers (
3
)
ADO.Net
Threading Problem