US2008040360A1PendingUtilityA1

Design pattern for choice types in object oriented languages

Assignee: MICROSOFT CORPPriority: Aug 14, 2006Filed: Aug 14, 2006Published: Feb 14, 2008
Est. expiryAug 14, 2026(~0 yrs left)· nominal 20-yr term from priority
G06F 8/24G06F 8/36G06F 9/449
44
PatentIndex Score
0
Cited by
0
References
0
Claims

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.

Claims

exact text as granted — not AI-modified
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 . The computer readable medium of  claim 1 , wherein at least one of the plurality of object types is also designated as a branch type corresponding to another choice type. 
   
   
       3 . The computer readable medium of  claim 1 , having further computer-executable instructions for performing the step of:
 receiving a reusable generic choice definition input that defines a generic choice type that is a type-indexed sum of a plurality of generic branch types, whereby, at any particular time, any particular instance of the generic choice type is defined by exactly one the plurality of generic branch types.   
   
   
       4 . The computer readable medium of  claim 1 , wherein the choice type input designates the choice type as an instance of the generic choice type, and wherein the choice type input designates the plurality of object types as a corresponding instance of the generic branch types. 
   
   
       5 . The computer readable medium of  claim 1 , having further computer-executable instructions for performing the step of:
 committing an instance of the choice type to a first one of the plurality branch types such that the instance of the choice type is defined by the first branch type.   
   
   
       6 . The computer readable medium of  claim 5 , having further computer-executable instructions for performing the step of:
 committing the instance of the choice type to a second one of the first plurality of branch types such that the instance of the choice type is defined by the second branch type.   
   
   
       7 . The computer readable medium of  claim 1 , having further computer-executable instructions for performing the step of:
 receiving a nominal choice type input defining a nominal choice type that inherits its state and behavior from the choice type.   
   
   
       8 . The computer readable medium of  claim 1 , wherein the plurality of object types comprise reference types and value types. 
   
   
       9 . The computer readable medium of  claim 1 , having further computer-executable instructions for performing the step of:
 performing a completeness checking operation that guarantees attempted casts to every one of the plurality of branch types when attempting to commit an instance of the choice type to a particular branch type.   
   
   
       10 . The computer readable medium of  claim 1 , having further computer-executable instructions for performing the steps of:
 receiving a product type input defining a product type, the product type input designating the plurality of object types as a plurality of product branch types; and   associating the plurality of product branch types with the product type such that the product type is a type-indexed product of the plurality of product branch types, whereby any particular instance of the product type is defined by every one of the plurality of product branch types.   
   
   
       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. 
 
   
   
   
       12 . The method of  claim 11 , further comprising re-committing the instance of the choice type to a different branch type at a subsequent time. 
   
   
       13 . The method of  claim 11 , wherein attempting to project the instance of the choice type onto the current branch type comprises employing a Boolean expression to express success or failure of an attempted projection. 
   
   
       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.   
   
   
       15 . The method of  claim 14 , further comprising:
 receiving a reusable generic choice definition input that defines a generic choice type that is a type-indexed sum of a plurality of generic branch types, whereby, at any particular time, any particular instance of the generic choice type is defined by exactly one the plurality of generic branch types.   
   
   
       16 . The method of  claim 14 , further comprising:
 committing an instance of the choice type to a first one of the plurality branch types such that the instance of the choice type is defined by the first branch type.   
   
   
       17 . The method of  claim 16 , further comprising:
 committing the instance of the choice type to a second one of the first plurality of branch types such that the instance of the choice type is defined by the second branch type.   
   
   
       18 . The method of  claim 14 , further comprising:
 receiving a nominal choice type input defining a nominal choice type that inherits its state and behavior from the choice type.   
   
   
       19 . The method of  claim 14 , further comprising:
 performing a completeness checking operation that guarantees attempted casts to every one of the plurality of branch types when attempting to commit an instance of the choice type to a particular branch type.   
   
   
       20 . The method of  claim 14 , further comprising:
 receiving a product type input defining a product type, the product type input designating the plurality of object types as a plurality of product branch types; and   associating the plurality of product branch types with the product type such that the product type is a type-indexed product of the plurality of product branch types, whereby any particular instance of the product type is defined by every one of the plurality of product branch types.

Join the waitlist — get patent alerts

Track US2008040360A1 — get alerts on status changes and closely related new filings.

We store only your email — no account needed. See our privacy policy.