This quiz contains a few questions about design patterns. I think the best intro book to design patterns is Head First Design Patterns. (the examples are in Java but it is an excellent resource/intro). After that its worth checking out GOF
Number of Questions : 7
Difficulty : If you know patterns this will be easy, if not, it will make very little sense to you.
Topic : Design Patterns
5 Comments
Ok, hrrrm, so I guess I’ve got to read up on design patterns…
if you develop any medium to large size apps… design patterns will save you lots of pain and frustration… they’re worth reading up on.
for the question: Which of the following is true about the Adapter pattern?
the naswers
“It is used to map one objects method signatures to another.” & “It is used to change the interface of an object” do sound the same to me
They’re not the same, and even if they were… Adapter is more than just a class that wraps methods. Often, in an Adapter you’ll wrap method calls of the adaptee and some logic into one function of the interface. Say there is an Interface IDrawingObject that contains the method drawRect(x, y, width, height, color) - You might adapt some class capable of drawing colored rectangles to the IDrawingObject interface in the following way
(psuedo-code inside the Adapter)
function drawRect(x, y, with, height, color){
adaptee.fill(color);
adaptee.translate(x, y);
adaptee.beginShape();
adaptee.vertex(0,0);
adaptee.vertex(width, 0);
adaptee.vertex(width, height);
adaptee.vertex(0, height);
adaptee.endShape();
}
Does that make sense? I hope that clears it up.
terrible. 3/7