Re: Optional attributes



Date view Thread view Subject view Author view Attachment view

From: robert france (france@CS.ColoState.EDU)
Date: Mon 17 May 2004 - 21:32:32 BST


Hmmm, I thought that optional attributes were considered bad
OO practice (from an object cohesion perspective). Can someone give
a good example of where an optional attribute is a good design choice
(i.e, justify the need to provide support for such attributes in the UML)?

Here's my take: 
An attribute (from the pUML submission) is a "slot". If an attribute
has a multiplicity 0..1 I would interpret this as "there is
no slot or there is exactly one slot for the attribute". If
there is no slot then we cannot store values for the attribute.
If there is a slot we can store a value in it. For requirements
and design modeling I assume that the slots always contain values 
(i.e., I consider a class diagram to be a 
characterization of valid stable "states" where a state is an
object configuration); and thus I cheat (i.e., ignore the
slot concept) and treat (mandatory) attributes as logical variables. 
Is this view is no longer supported by the UML semantics?

If we want a finer-grained model that allows one to describe situations
in which slots have not been assigned values then we probably
need to treat attributes in much the same way way we treat program 
variables in formal semantics.

Robert

====================================================================
Robert B. France, Assoc Professor | Tel: 970-491-6356
Computer Science Department       | Fax: 970-491-2466
Colorado State University         | Email: france@cs.colostate.edu
Fort Collins, CO 80523            | www.cs.colostate.edu/~france/

Date view Thread view Subject view Author view Attachment view