Newbie: Design Pattern

  • Thread starter Mustafa Ahmad Malik
  • Start date
M

Mustafa Ahmad Malik

Hi,
I am a newbie learning design patter techniques. A task is assigned to me to
implement a Communication class in C#, which will be a dll, using the most
suitable Design Pattern. The communication dll will contain implementation
of MSMQs, Pipes, Sockets etc. The purpose of it is to allow users to select
one of the communication methods present in dll and then use it for
sending/receiving data.

After studying a few pattern I came to conclusion that Factory Design
Pattern is most suitable. What you people experienced in DP, suggest?

Thanks,
Mustafa Ahmad.
 
F

Frans Bouma [C# MVP]

Mustafa said:
Hi,
I am a newbie learning design patter techniques. A task is assigned to me to
implement a Communication class in C#, which will be a dll, using the most
suitable Design Pattern. The communication dll will contain implementation
of MSMQs, Pipes, Sockets etc. The purpose of it is to allow users to select
one of the communication methods present in dll and then use it for
sending/receiving data.

After studying a few pattern I came to conclusion that Factory Design
Pattern is most suitable. What you people experienced in DP, suggest?

Patterns shouldn't be forced on you as: "use a pattern to implement it".
Patterns are defined solutions to common problems. So first you have to
clearly define your problem: what do you want to do? Then, you have to find a
solution to your problem. This is best done by first cooking up a solution
yourself. This forces you to investigate what kind of issues are involved in
your problem, how code can probably be structured etc. . THEN you pick a pile
of patterns and see if there is a pattern (or set of patterns) which solves
your problem as well. It can be that there isn't a pattern which solves your
problem. (this is common). If that's the case, use your own solution.

In short: anyone who forces you to implement a pattern, no matter what,
doesn't know anything about patterns and shouldn't be leading a team.

Frans.
 
A

ask josephsen

You should definately check out the book "Design Patterns" by Gamma, Helm,
Johnson and Vlissides from Addison Wesley. It is a description of a lot of
patterns and what they should be used for. It contains examples implemented
in C++.

../ask
 
A

ask josephsen

You should definately check out the book "Design Patterns" by Gamma, Helm,
Johnson and Vlissides from Addison Wesley. It is a description of a lot of
patterns and what they should be used for. It contains examples implemented
in C++.

../ask
 
M

Mustafa Ahmad Malik

Frans Bouma said:
Patterns shouldn't be forced on you as: "use a pattern to implement it".

No one has forced. Its a simple excercise to learn and think which pattern
suits, if any, which problem. The solution that i thought of is to give user
an abstraction and to allow the user to enumerate which communication
methods are available and then pass some value to get instance of that
method. For example, commdll.CreateInstance( "MSMQ" ). This way if next time
a new communication method is implemented in dll then the user would be able
to use it without disturbing others. Considering this I though of a Factory
Pattern.
 
W

wrda

ask said:
You should definately check out the book "Design Patterns" by Gamma, Helm,
Johnson and Vlissides from Addison Wesley. It is a description of a lot of
patterns and what they should be used for. It contains examples implemented
in C++.

Is there equivalent book for C#?

Thanx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top