Question

(java) Explain the concept of benevolent side effects. Give an example that illustrates the concept. do...

(java)

  1. Explain the concept of benevolent side effects. Give an example that illustrates the concept. do not use the rat/rational example

Note: You are not required to provide a comprehensive example. It is good to use one that can just illustrate the concept clear enough.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Benevolent side effects:

Not every side effect needs to be documented with an effects clause. If a side effect does not affect the abstract value that a mutable representation maps to, the side effect will be invisible to the user of the abstraction. Therefore, it need not be mentioned in the specification. Side effects of this sort as known as benevolent side effects, because they are not destructive. Benevolent side effects can be useful for building caches internal to data structures, or for data structure reorganizations that improve performance without affecting their abstract value.

Examples of benevolent side effects:

For Example, consider computing a hash code for an instance of a class, since this can be computationally costly, an implementation may require to compute the hash code, the first time it is asked for and then cache the result in a private feild

of the object. When the hash code is requested in subsequent occasions, the cached result is returned without further computation. For example this is done in the hashCode method of java's String class. However in JML storing the computed hashcode into the cache is considered to be a side effect. so, String's hashCode method cannot be specified as pure.

Add a comment
Know the answer?
Add Answer to:
(java) Explain the concept of benevolent side effects. Give an example that illustrates the concept. do...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A bounded string list has an upper limit on its size, which is set when the...

    A bounded string list has an upper limit on its size, which is set when the list is created. The size limit specifies the maximum number of strings that can be stored in a bounded string list. String lists are mutable and allow random accesses to their elements using indexes. The list operations include BoundedStringList(int sizeLimit); void insert(String newString, int index); void delete(int index); String get(int index); The constructor creates an empty list with a maximum size of sizeLimit. The...

  • Cost Behavior Major Concept Assmt #1 Explain and give a unique example the following concepts of...

    Cost Behavior Major Concept Assmt #1 Explain and give a unique example the following concepts of cost behaviors: • Cost drivers Fixed cost and Variable Costs • CVP Analysis Write in complete sentences and pay close attention to grammar Please make sure to clearly explain the concepts as if you were teaching and explaining to another student, that has no background on these concepts. Also, make sure to use a unique example. Take this example from your own situation, either...

  • Cost Behavior Major Concept Assmt #1 Explain and give a unique example the following concepts of...

    Cost Behavior Major Concept Assmt #1 Explain and give a unique example the following concepts of cost behaviors: • Cost drivers • Fixed cost and Variable Costs • CVP Analysis Write in complete sentences and pay close attention to grammar Please make sure to clearly explain the concepts as if you were teaching and explaining to another student, that has no background on these concepts. Also, make sure to use a unique example. Take this example from your own situation,...

  • 1. Give an example to illustrate each of the two forms of due process. 2. Explain...

    1. Give an example to illustrate each of the two forms of due process. 2. Explain the doctrine of transferred intent with respect to criminal law (3 points), and give one example of the commission of a crime where transferred intent is involved (2 points). 3.The US Supreme Court interprets the US Constitution when reviewing cases in dispute. What are three "Modalities of Interpretation" that our justices utilize? (3 points) Take each of these modalities, and describe what they are....

  • 1. Give an example of a good or service that is commonly sold using second-degree price discrimination, and one that is commonly sold using third-degree price discrimination, besides the ones mentione...

    1. Give an example of a good or service that is commonly sold using second-degree price discrimination, and one that is commonly sold using third-degree price discrimination, besides the ones mentioned in the lecture and textbook. Be sure to provide enough information about how these goods are sold to make it clear that they are valid examples. 2. Using at least one graph, explain how it is possible that firms in a monopolistically competitive industry can have monopoly power, yet...

  • Java Homework Question: Explain how class (static) variables and methods differ from their instance counterparts. Give...

    Java Homework Question: Explain how class (static) variables and methods differ from their instance counterparts. Give an example of a class that contains at least one class variable and at least one class method. Don't forget to provide the code. Also, explain why using a class variable and method rather than an instance variable and method would be the correct choice in the example you select.

  • Matching: Give one example from the main-group chemistry that illustrates each of the following descriptors: ______________...

    Matching: Give one example from the main-group chemistry that illustrates each of the following descriptors: ______________ Covalent Network Solid                                      A. Chlorine gas ______________ Disproportionation reaction                                B. silicon ______________Paramagnetic oxide                                             C. nitric acid ______________Polar molecule that violates the octet rule           D. nitrogen dioxide ______________Lewis acid                                                             E. nitrogen monoxide _____________Amphoteric oxide                                                    F. diamond _____________Semiconductor                                                      G. graphite, fullerene _____________Strong oxidizing agent                                           H. Boron triblouride ____________Allotropes                                                                 I. water ____________Universal polar solvent                                           J. Aluminum oxide ***You can only use each answer one time.

  • please solve all the questions . i need them urgently 1. Explain the concept of an...

    please solve all the questions . i need them urgently 1. Explain the concept of an initial-value problem for a differential equation (You may use examples to support your answer). 2. Find an example of a boundary value problem for a partial differential equation (you can write this in the same formas described in the lecture notes) 3. Consider the following equation: som AS (a) Identify the equation (by name). (b) Identify the variables in the equation: f and t....

  • Explain how marginal costs, direct costs and opportunity costs are different. Use an example from your...

    Explain how marginal costs, direct costs and opportunity costs are different. Use an example from your personal life to illustrate each concept. Do you agree with Robert Moses’ ideas of wiping out cities that are an "impediment to new growth"? (see Scarcity and Eminent Domain) Why or why not? Using Table 1, create one graph that illustrates all three lawnmowers’ Marginal Costs (Beth, Jim and Susan). Using Table 1, for each mower, identify if the Marginal Cost and Total Cost...

  • SUBMIT YOUR ANSWERS TO THE FOLLOWING QUESTIONS: Explain your true or false answers in brief sentences....

    SUBMIT YOUR ANSWERS TO THE FOLLOWING QUESTIONS: Explain your true or false answers in brief sentences. What is the purpose of advertising? True or false: Advertising copy is only created for print advertisements. True or false: Copywriters only work for ad agencies. True or false: Copywriters can work alone or as a part of a team. In what context might a copywriter prefer to be called a content writer? Give one example of the “good” that a copywriter can do...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT