Author Topic: Attribute containment  (Read 7529 times)

Adam

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Attribute containment
« on: July 10, 2007, 12:29:22 am »
I suppose this is specific to C++, but can be applied to other languages as well.

With attribute containment (parameters too), there is only a global option to select between pointer and reference, in my design I would like to use a mixture of both, depending on the use of the attribute, ownership, memory management, initialisation order etc.

Currently I cant explicitly choose one or the other, I can only say by reference or by value. To get around this now I've been using * and & to specifically say which, and not specifying a containment. This works for code generation, and is clear to read, but this prevents the attribute (or parameter) updating if the type changes.

Since I set the element type to C++ I think I should be presented with 4 types of containment:
- Not Specified
- By Value
- By Reference
- By Address (or By Pointer?)

Maybe to make this more general we want to leave the 3 types:
- Not Specified
- By Value
- By Reference

and when By Reference is selected enable a secondary propery  called nullable, or is nullable or something similar which can determine the type of reference across more languages than just c++. It will also allow some extra constraints to be specified in other languages.

The c++ solution is easy, can people think of a better, language independent way to represent this?

glen_kidd

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Attribute containment
« Reply #1 on: July 10, 2007, 08:12:28 pm »
If this was extensible through UML Profile or MDG or whatever, then it would certainly suit more customers.

For example, just have the standard set of 3 by default (not specified, by value, by reference). However, if the language supports other types (pointers, handles, whatever) then if the Element's language is set, these additional containments are now available.

Taking it one step further, why not allow the User to define their own types of containment. eg. auto_ptr, boost smart pointers, whatever.