View Full Version : Command Pattern vs. Adapter Pattern
08-24-2007, 09:46 PM
This these patterns seems quite similar to me.
The Command Pattern lets the clients to talk to the receiver through the use of a interpreter that knows how to speak with them both
The Adapter Patterns defines an interface for the client to use and that interface calls the appropriate methods methods on the receiver.
These 2 Patterns seem so similar. What am I missing?
08-25-2007, 04:02 AM
There are a lot of patterns that have subtle differences, but one big differentiator is the problem that they aim to solve.
A command is specifically used to consolidate an execution of a specific action.
An adapter is used in situations where pre-existing code needs to support a newer abstraction.
08-25-2007, 06:21 AM
Thanks for the reply :)
That's about what I got from my readings, too. So the main determining factor here (and with all OOP, maybe?) is the aim of what they are trying to do?
08-25-2007, 06:51 AM
Pretty much. The point is to get an idea of the conventional solutions to common problems. This way you're not reinventing the wheel, and also you can communicate your solutions to other people.
In reality, a project won't just be a collection of patterns. A project should just be a collection of classes that are built with the mentality of solving in patterns....if that makes any sense.
08-25-2007, 08:39 AM
I'm glad to hear you say "In reality, a project won't just be a collection of patterns". I like that a lot and it make sense....in a which came first the chicken or the egg way.
vBulletin® v3.8.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.