Design pattern for choice types in object oriented languages
First Claim
1. A computer readable medium having computer-executable instructions for performing steps comprising:
- receiving a plurality of type inputs defining a plurality of object types;
receiving a choice type input defining a choice type, the choice type input designating the plurality of object types as a plurality of branch types; and
associating the plurality of branch types with the choice type such that the choice type is a type-indexed sum of the plurality of branch types, whereby, at any particular time, any particular instance of the first choice type is defined by exactly one of the first plurality of branch types.
2 Assignments
0 Petitions
Accused Products
Abstract
A design pattern for choice types in object oriented programming languages is described herein. The design pattern enables discrimination among branch types in a type-safe and discoverable manner. Additionally, the design pattern enables object types that will eventually serve as branch types to be initially defined without placing them in a fixed class hierarchy. Hence, these object types can be initially defined without the need to anticipate that they will later be used as branch types. Furthermore, these object types can serve as branch types for multiple choice types, without the need to anticipate the names or compositions of the choice types when the branch object types are initially defined.
-
Citations
20 Claims
-
1. A computer readable medium having computer-executable instructions for performing steps comprising:
-
receiving a plurality of type inputs defining a plurality of object types; receiving a choice type input defining a choice type, the choice type input designating the plurality of object types as a plurality of branch types; and associating the plurality of branch types with the choice type such that the choice type is a type-indexed sum of the plurality of branch types, whereby, at any particular time, any particular instance of the first choice type is defined by exactly one of the first plurality of branch types. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A method for performing case discrimination on an instance of a choice type, the method comprising:
-
(a) setting a current branch type to be a next unexamined branch type designated to the choice type; (b) attempting to project the instance of the choice type onto the current branch type; (c) determining whether the projection is successful; (d) if so, then committing the instance of the choice type to the current branch type; (e) if not, then determining whether there is a remaining unexamined branch type designated to the choice type; (f) if so, then returning to step (a); and (g) if not, then determining that the instance of the choice type is invalid. - View Dependent Claims (12, 13)
-
-
14. A method for defining a choice type, the method comprising:
-
receiving a plurality of type inputs defining a plurality of object types; receiving a choice type input defining the choice type, the choice type input designating the plurality of object types as a plurality of branch types; and associating the plurality of branch types with the choice type such that the choice type is a type-indexed sum of the plurality of branch types, whereby, at any particular time, any particular instance of the first choice type is defined by exactly one of the first plurality of branch types. - View Dependent Claims (15, 16, 17, 18, 19, 20)
-
Specification