Reference no: EM13963499
Protocol Conformance
We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the selector name includes the colons but not the spaces. More speci?cally, if dict is an updatable collection object, such as a dictionary, then we could send dict a message by writing dict at:‘cross' put:‘angry'. (This makes our dictionary de?nition of "cross" the single word "angry.") The protocol for updatable collections will there- fore contain the seven-character selector name at:put: . Here are some example protocols:
stack : {isEmpty, push:, pop }
queue : {isEmpty, insert:, remove }
priority queue : {isEmpty, insert:, remove }
dequeue : {isEmpty, insert:,insertFront:, remove, removeLast }
simple collection : {isEmpty }
Brie?y, a stack can be sent the message isEmpty, returning true if empty, false oth- erwise; push: requires an argument (the object to be pushed onto the stack), pop removes the top element from the stack and returns it. Queues work similarly, ex- cept they are ?rst-in, ?rst-out instead of ?rst-in, last-out. Priority queues are ?rst-in, minimum-out and dequeues are doubly ended queues with the possibility of adding and removing from either end. The simple collection class just collects methods that are common to all the other classes. We say that the protocol for A conforms to the protocol for B if the set of A selector names contains the set of B selector names.
(a) Draw a diagram of these classes, ordered by protocol conformance. You should end up with a graph that looks like William Cook's drawing shown in Figure 11.6.
(b) Describe brie?y, in words, a way of implementing each class so that you make B asubclass of A only if the protocol for B conforms to the protocol set for A.
(c) For some classes A and B that are unrelated in the graph, describe a strategy for implementing A as a subclass of B in a way that keeps them unrelated.
(d) Describe implementation strategies for two classes A and B (from the preceding set of classes) so that B is a subclass of A, but A conforms to B, not the other way around.
Relationship between inheritance and subtyping
: With this declaration of m in subclass B, any invocation of m on a B object will result in a special error indicating that the method should not be used. (a) What effect does this feature of Smalltalk have on the relationship between inherit..
|
What is the standard deviation of the annual salary
: What is Bob's average annual earnings. In the previous question, what is the standard deviation of the annual salary? What is the probability that John will get 2 tickets during the week (Monday-Friday)?
|
Perceptions of acl rehabilitation
: The purpose of this study is obtaining undiscovered perceptions of strength and conditioning coaches (S&C) and physiotherapists', on what defines a successful return to sport following an anterior cruciate ligament (ACL) injury.
|
Verify the normalization of the ground state of sho
: Examine the normalization condition as applied to the second-state wave function. Can you see a way to apply the results of (a) and (b) to evaluate the integral? [Hint: What happens if you regard the SHO parameter a as a variable and differentiate..
|
Problem regarding the protocol conformance
: We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the selector name includes the colons but not the spaces.
|
Franchise arrangement between mcdonald''s and its franchisees
: The franchise arrangement between McDonald's and its franchisees is summarized
|
Advantages and disadvantages of optimization
: In Smalltalk, each class contains a pointer to the class template. This template stores the names of all the instance variables that belong to objects created by the class.
|
Specific heat of superheated steam at 150kpa is 2kj/deg
: What diameters of inlet and outlet pipes would be required for a flow of 2270kg per hour with a velocity of 15m/s both before and after the reducing valve?
|
Objects-type case
: With object-oriented programming, classes and objects can be used to avoid "type- case" statements. Here is a program in which a form of case statement is used that inspects a user-de?ned type tag to distinguish between different classes of shape ..
|