Why is java.util.Observable not an abstract class? -
I have just seen that java.util.Observable is a solid square. Since inspection is to be expanded, so it seems strange to me. Is there any reason to apply it like this?
I found that which is called
This is a visible square, so the section receiving it should be determined in advance, as Java is only a single succession Allows
But it does not really convince me, in fact, if there was insightful essence, then the user would be compelled to determine the class from it.
As the first approach, it may think that the user is allowed to use the structure instead It is a heritage, which is very convenient If your class has already been from another class , and you can not even inherit from the observation class.
But if we look at the source code of the observation, then we see that there is an internal flag
the private boolean changed = false;
Each time the notification oscillator is implemented:
notify the public zodiac (object arg) {object [] arrLocal; Synchronize (this) {if (changed!) Return; ArrLocal = obs.toArray (); ClearChanged (); } For (int i = arrLocal.length-1; i> = 0; i--) ((inspector) arrLocal [i]). Update (this, arg); }
But , we can not change this flag from the square created by this supervisor, because it is private, and given methods to change it Are preserved.
This means that the user is forced to sub-class the observation class, and I would say that the lack of "abstract" keyword is just a "mistake".
I would say that this class is a complete screw.
Comments
Post a Comment