Changeable class and pattern to provide selective mutability in computer programming environments
First Claim
1. In a computing environment, a method comprising:
- maintaining a base class, the base class comprising two properties, isChangeable and statusOfNextUse;
receiving a request for a type, the type deriving from the base class and inheriting the properties of the base class;
causing the type to be created, and upon being created, the type'"'"'s isChangeable property set to allow a change, and the type'"'"'s statusOfNextUse property set not to allow a change upon a next qualified use; and
upon a next qualified use, causing the type to be cloned, the cloned type having an isChangable property set not to allow a change.
2 Assignments
0 Petitions
Accused Products
Abstract
A changeable pattern and implementation is presented in which types (used in programming environments and virtual machines) may be mutable as controlled by a programmer, and share many of the benefits of value types, without the drawbacks of value types. The changeable pattern provides flexibility for restricting the modifiability of the resultant uses of the values, as well as providing a means for providing notifications upon changes. In one implementation, a single set of changeable types is provided that derive from a common Changeable base class, and any type for which mutability is desired may derive from the Changeable class. Properties associated with the changeable define state that determines cloning and/or changeability characteristics on subsequent uses of the type. True mutability is provided via a status property of next use being set to a changeable reference state such that subsequent uses of the type do not cause a state change.
29 Citations
38 Claims
-
1. In a computing environment, a method comprising:
-
maintaining a base class, the base class comprising two properties, isChangeable and statusOfNextUse; receiving a request for a type, the type deriving from the base class and inheriting the properties of the base class; causing the type to be created, and upon being created, the type'"'"'s isChangeable property set to allow a change, and the type'"'"'s statusOfNextUse property set not to allow a change upon a next qualified use; and upon a next qualified use, causing the type to be cloned, the cloned type having an isChangable property set not to allow a change. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
-
-
14. In a computing environment, a method comprising:
-
providing a type, the type comprising properties isChangeable and statusOfNextUse, the isChangeable property set to allow a change and the statusOfNextUse property set to changeableReference; and upon receiving a request to change data of the type in a qualified use, and based on the isChangeable property and statusOfNextUse property, allowing the data to change in the type and leaving the type in the changeableReference state. - View Dependent Claims (15, 16, 17, 18, 19, 20)
-
-
21. A computer-readable medium having stored thereon a data structure, the data structure comprising:
-
a data field representing a first property having data corresponding to whether a type is changeable or unchangeable; a data field representing a second property having data corresponding to a state of the type upon a subsequent use; and wherein when the first property corresponds to a changeable state; 1) when the second property has a setting corresponding to unchangeable, a qualified use of the type causes a clone to be created, the clone having a first property that is set to unchangeable; 2) when the second property has a setting corresponding to changeable copy, a qualified use of the type causes a clone to be created having a first property that is set to make the clone changeable and a second property set to unchangeable such that a subsequent use of the clone will create another clone, the other clone having a first property that corresponds to unchangeable; and 3) when the second property has a setting corresponding to changeable reference, a qualified use of the type remains in a state in which the first property corresponds to a changeable state and the a second property setting corresponds to changeable reference. - View Dependent Claims (22, 23, 24, 25, 26, 27, 28, 29, 30)
-
-
31. In a computing environment, a system comprising:
-
means for maintaining a parent class from which a type subclass may derive, the parent class comprising properties isChangeable and statusOtNextUse; means for providing a type corresponding to a subclass of the parent class, the subclass further comprising contained data; means for setting the type into one of a plurality of states defined by settings of the properties of the parent class associated with the type; means for receiving a request to change the contained data of the type in a qualified use; and means for determining how to process the request based on the property settings. - View Dependent Claims (32, 33, 34, 35)
-
-
36. In a computing environment, a method comprising:
-
receiving a request to copy a type, the type being derived from a parent class, the type containing hierarchically deep data; in response to the request, causing a shallow copy of the type to be created, the shallow copy not containing the hierarchically deep data upon being created; and upon access to at least some of the hierarchically deep data being requested, copying the at least some of the hierarchically deep data to the shallow copy to enable the shallow copy to act as a deep copy.
-
-
37. In a computing environment, a method comprising:
-
receiving a request related to a type, the type having a first property corresponding to whether that type is changeable or unchangeable and having a second property corresponding to a state of the type upon a subsequent use; determining whether the request corresponds to a qualified use; and when the request corresponds to a qualified use and the first property corresponds to a changeable state; 1) when the second property has a setting corresponding to unchangeable, causing a clone of the type to be created, the clone having a first property that is set to unchangeable; 2) when the second property has a setting corresponding to changeable copy, causing a clone of the type to be created having a first property that is set to changeable and a second property set to unchangeable such that a subsequent qualified use of the clone will create a clone of the clone, the clone of the clone having a first property that is set to make the clone of the clone changeable and a second property set such that a subsequent use of the clone of the clone will make the clone of the clone unchangeable; and 3) when the second property has a setting corresponding to changeable reference, remaining in a state in which the first property corresponds to a changeable state and the a second property setting corresponds to changeable reference.
-
-
38. In a computing environment, a method comprising:
-
providing a reference object, the reference object having a first property corresponding to whether the reference object is changeable or unchangeable and a second property corresponding to a state of the reference object upon a subsequent use; and using the property values to determine a state of the reference object following a qualified use such that the reference object includes characteristics of a value type wherein a shallow copy is created of the reference object on cloning and a deep copy is created on demand when hierarchically deep data within the reference object is accessed.
-
Specification