Book a Demo

Author Topic: Showing Persistence on class diagrams  (Read 6153 times)

mhyde

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • EA Convert
    • View Profile
Showing Persistence on class diagrams
« on: February 05, 2007, 06:07:58 am »
Hi,
Is there an easy way to visually show in class diagrams whether a class is marked as persistent or transient? Currently we've resorted to using different colours, but I'm sure there must be a more automated way!

Any suggestions would be gratefully received.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Showing Persistence on class diagrams
« Reply #1 on: February 05, 2007, 01:47:04 pm »
Isn't a persistent class usually denoted by the <<table>> stereotype? If that isn't suitable, how about inventing your own stereotype, e.g. <<persistent>>.
The Sparx Team
[email protected]

mhyde

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • EA Convert
    • View Profile
Re: Showing Persistence on class diagrams
« Reply #2 on: February 06, 2007, 01:37:34 am »
Thanks for the advise. We've created a new stereotype and this works well. It does beg the question of why have a "persistence" field for a class though. I would of thought that, having provided it, we should be able to use it and have the differentiation shown on a diagram. Oddly enough, when I press the Help button on the Class properties window, the screenshot omits the Persistence item. Is this a fairly new addition that perhaps isn't fully developed yet?
« Last Edit: February 06, 2007, 01:38:12 am by mhyde »

thomaskilian

  • Guest
Re: Showing Persistence on class diagrams
« Reply #3 on: February 06, 2007, 06:41:57 am »
The persistence field can be evaluated for example during model transformation (generate table only for persistent classes). OTOH it is a legal question why these properties do not appear. Might be that a more flexible compartment approach would be a benefit here.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Showing Persistence on class diagrams
« Reply #4 on: February 06, 2007, 01:35:35 pm »
Quote
It does beg the question of why have a "persistence" field for a class though.

Is there? I didn't even think of looking for it :-[

Well, you can use that property in shape scripts. Give this a go:
Code: [Select]
decoration persistence
{
 print("{#persistence#}");
}

or how about this one...
Code: [Select]
decoration persistence
{
 if(HasProperty("persistence","persistent"))
 {
   setfillcolor(0,255,255);
   rectangle(0,0,100,100);
 }
}

UML doesn't have any suggestions on a notation, so feel free to invent your own.
The Sparx Team
[email protected]

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
As a side note
« Reply #5 on: February 12, 2007, 11:42:18 pm »
Object persistence has nothing (little?) to do with databases and tables.  It is used to indicate that the state of the object is rendered stable between, possibly asynchronous, invocations of the object reference.  The mechanism of persistence may be anything - as an example, consider a cookie.  UML persistence says nothing about the mechanism or the location of the persistence.

I have of late been getting somewhat dismayed that lower forms of UML life consider that there is a one-to-one relationship between an instance of a class and a "record" (tuple) in a database.  This is patently not so and reeks at least of bad practice but probably moreso bad data design.

regards
bruce

"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Showing Persistence on class diagrams
« Reply #6 on: February 13, 2007, 12:53:05 am »
"...lower forms of UML life..."

Would that be pondlife, or just higher invertebrates ?

Me, I'm a slug.

;-)

Mike

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Showing Persistence on class diagrams
« Reply #7 on: February 13, 2007, 03:51:58 am »
 ;D ;D ;) If the suit fits ...


btw Mike, I didn't consider you at the shallow end at all ...
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.