Question

In: Computer Science

1) Compare and contrast the decorator and the strategy patterns. How are they similar? How are...

1) Compare and contrast the decorator and the strategy patterns. How are they similar? How are they different?

2)  Why are referential equality and the instance of operators a problem for decorators?

Solutions

Expert Solution

The answer for this is as follows:

1) The stratergy pattern allows you to change the implementation of something used at runtime. The decorator pattern allows you augment(or add to) existing functionality with additional functionality at run time.The key difference is in the change vs augment. Decorator pattern can be used in a scenario where particular property is manipulated on existing objects.For Stratergy pattern, let us say you have some workflow design in visual studio.Suppose you want to open that design in 2 view. In this case, viewing is the only one activity that user going to perform,but based on user's choice the"stratergy" of viewing will get differ.

2) Referential equality means that pointers for two objects are same. Objects are contained in same memory loation which leads us to the fact that pointers reference to same object. Instance of operator is used to test whether the object is an instance of specified type(class or subclass or interface). Whereas the decorator returns a modified function or class.Therefore referential equality and instance equality are problems for decorators.


Related Solutions

Compare and contrast an acid to an ionic compound. How are they similar? How are they...
Compare and contrast an acid to an ionic compound. How are they similar? How are they different? Give examples to justify your response.
1. Compare and contrast the correlation and the chi-square test of independence. How are they similar...
1. Compare and contrast the correlation and the chi-square test of independence. How are they similar and how are they different (i.e. when to use each) 2. Come up with two hypothetical examples demonstrating both strategies or come up with "real-world" applications of these strategies in your professional life (i.e. how could you apply these in your work).
1. Compare and contrast the independent t-test and the analysis of variance. How are they similar...
1. Compare and contrast the independent t-test and the analysis of variance. How are they similar and how are they different. 2. Come up with two hypothetical examples demonstrating this strategy or come up with "real-world" application using your professional life (i.e. how could you apply this in your work).
7) Compare and contrast (that means tell me how they are similar AND how they are...
7) Compare and contrast (that means tell me how they are similar AND how they are different) gene regulation mechanisms in prokaryotes and eukaryotes. Explain why regulation is more complex in multicellular eukaryotic organisms as compared to prokaryotic organisms by providing examples of eukaryotic gene regulation mechanisms (you don’t have to give me all the steps, just the concepts).
compare and contrast the ANOVA with the t-test, how are similar? how are they different
compare and contrast the ANOVA with the t-test, how are similar? how are they different
Compare and contrast (that means tell me how they are similar AND how they are different)...
Compare and contrast (that means tell me how they are similar AND how they are different) gene regulation mechanisms in prokaryotes and eukaryotes. explain why regulation is more complex in multicellular eukaryotic organisms as compared to prokaryotic organisms by providing examples of eukaryotic gene regulation mechanisms (you don’t have to give me all the steps, just the concepts) please answer with fine detail, will rate high :-)
1. Compare and contrast the patterns of organization for the body of a speech. (worth 6...
1. Compare and contrast the patterns of organization for the body of a speech. (worth 6 points) 2. What role does outlining play in composing a good speech? What are the best techniques to use? (worth 4 points)
Compare and contrast Life Course Theory and Social Cognitive Theory. How are they similar? How are...
Compare and contrast Life Course Theory and Social Cognitive Theory. How are they similar? How are they different?
Compare and contrast the three foreign policy decision-making models. How are they similar? How are they...
Compare and contrast the three foreign policy decision-making models. How are they similar? How are they different? What are the consequences of these differences and similarities for policy decisions and outcomes? Which model do you think is most effective and why? (Rational model, organizational process model, and government bargaining model)
Compare and contrast Cotton Mather’s economic advice with that of Benjamin Franklin. How are they similar?...
Compare and contrast Cotton Mather’s economic advice with that of Benjamin Franklin. How are they similar? How are they different?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT