Answer the question
In order to leave comments, you need to log in
What is the name of the pattern that prepares the arguments?
There are two objects with public methods. Today, the first one returns a string, the second one takes it, and tomorrow the first one returns an array of strings, while the second one still takes a string.
What is the name of the design pattern that is designed to deal with changes like this?
Added:
var Test = function(){
//...
};
Test.prototype.input = function(message){
console.log(message);
};
var AdapterGreeting = function(){
//...
};
AdapterGreeting.prototype.adapt = function(args){
var str = 'Hello ';
return str + args + '!';
};
var AdapterListing = function(){
AdapterGreeting.call(this);
};
AdapterListing.prototype = Object.create(AdapterGreeting.prototype);
AdapterListing.prototype.constructor = AdapterListing;
AdapterListing.prototype.adapt = function(args){
var length = args.length;
var count = 0;
var row = '';
while(count < length){
row += 'Item - ' + args[count++] + ';' + '\n';
}
return row;
};
var test = new Test();
var adapterGreeting = new AdapterGreeting();
var adapterListing = new AdapterListing();
test.input(adapterGreeting.adapt('World'));
test.input(adapterListing.adapt(['1', '2', '3']));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question