Author Topic: Reusing Activity in multiple use case scenario  (Read 15230 times)

rnv

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Reusing Activity in multiple use case scenario
« on: December 07, 2012, 12:46:37 am »
Hi,

I have several use case. All use cases have scenario steps they share. for example, users must login to the system.

So far each use case scenarios contain separate activity step for 'login'.

Is it a good idea to have one activity defined that is used in all use cases?
Or I should continue as it is: each use case scenarios contain separate activity step for 'login'.

regards,
rnv

salayande

  • EA User
  • **
  • Posts: 224
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #1 on: December 07, 2012, 12:55:53 am »
What you may do is to create a package where you define common activities or model elements that you know are commonly re-used in different contexts (diagrams).

I would define the login once and re-use many times but then please, check that this design decision does not impact other things you may want to do later. ;)

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #2 on: December 07, 2012, 02:18:48 am »
I found that using -actions- based on activities instead of activities themselvess works very nicely (effectively an activity becomes a 'blueprint' for actions).

Just define your general Login step as an activity and drag-and-drop that as an element, not a link, on a diagram. This wil create an action that links to the implementiation of the activity (when doubleclicking).

Possibly a MAJOR drawback when you want to use your model for dependency analysis as wel as visualisation: dependencies between activities become indirect since a relation between any two actions implies a relation between the activities behind the actions. Can be resolved using classifiers but it involves some work, and eg something like a relationship matrix can't be used anymore.

Another reason to use ation iso activities: EA does not allow you to drop the same activity more then once on a diagram. I don't know why that is but it quickly becomes annoying.

regards,

Paulus
« Last Edit: December 07, 2012, 02:21:37 am by pmaessen »

rnv

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #3 on: December 07, 2012, 03:07:21 am »
Quote
I would define the login once and re-use many times but then please, check that this design decision does not impact other things you may want to do later. ;)

Thanks,

I am planning to put such Activities in separate package and use it wherever needed.
What kind of negative impact that it might have?
regads,

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13296
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Reusing Activity in multiple use case scenario
« Reply #4 on: December 07, 2012, 06:27:47 pm »
Yes, I think you should either
- re-use the same activity
- Model a "sub-use case" for Login and include that use case from your main use case.

In any case, I think you should never put activities directly on an activity diagram.
The Activity is only good to be used as a parent for activity diagram, not to be used on the diagram itself.

You can compare an Activity to a Statemachine for this aspect. We also never put Statemachines on Statemachine diagrams, only States.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #5 on: December 07, 2012, 07:51:54 pm »
Quote
- Model a "sub-use case" for Login and include that use case from your main use case.
I had this discussion so often, but login is no use case but a pre-requisite. You can argue with tech/business UC but from business perspective: it's none. (Refer to Writing Effective Use Cases by Cockburn)

q.

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #6 on: December 07, 2012, 08:18:18 pm »
My 2 cts:

- if stakeholders want to have a say in how login should look/work (above and beyond the high-level reuirements for it) i think it's worth to create a separate UC for it (regardless)
- if that's not the case then create a composite activity in a 'components package' and re-use that in the respective places (as an action)

... and although like Geert i would not put an activity on an activity diagram, keep in mind the drawback of doing that.
« Last Edit: December 07, 2012, 08:21:25 pm by pmaessen »

rnv

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #7 on: December 11, 2012, 12:32:40 am »
thank you all for your responses. but since i am relatively new here i do not understand all. hope you can help me.

@Paulus: what are the drawbacks of having activity in activity diagram? When I create activity automatically from use case scenarios there are activities in activity diagram. or you mean something different?

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #8 on: December 11, 2012, 08:37:45 am »
OK, activities vs actions: when you drag an activity from the projectbrowser on to an activity diagram -and hold the CTRL down when dropping- you are presented with two options:

1) paste activity as simple link - the activity is included on the diagram. This is what one usually would do and apparently the scenario generator does (didn't know that, i prefer to work the other way around  ;))

2) create an action that 'links to' the activity. This is analogous to dropping a class on a diagram and selecting 'instance of element'. Think of it as saying 'the step that this action represents is executed by this activity (take a look at the action properties dialog, tab 'Call' property 'Behavior' and you will see what i mean)

Now try to drag the same activity on the diagram a second time (option 1): EA will protest.
But dragging a second -instance- (option 2) is allowed.

Now to answer your question, there are 2 drawbacks i can think of when using -activities- on flow diagrams:

1) an activity can be used only once on the same diagram  (as demonstrated above)
2) EA will automatically draw all current -and future- relations between the dropped activity and any other elements on the diagram it knows of (try adding a number of activities on one diagram, and then on another diagram as well, and change some relations and you will see what i mean). You can hide relations if you want but this way you will have to keep checking and updating previous work. Even worse: if you are not carefull you end up creating the same relation a second time at some future moment.

When using activity instances (actions) the above drawbacks don't occur since the action is a separate model element with its own relations.

The drawback of using -actions- is that the extra level of indirection creates problems when you want to answer questions like e.g. 'which activities are involved in this process?'. The relationship matrix for instance visualises only direct relations, e.g. action-action, but not activity->action-action<-activity. So you will have to write some (SQL) queries or script to get the answer you need, or use the available tools like the 'traceability' window to do it manually.

So it really depends on your background and how you intend to use you model what is best.

On the whole i prefer using -actions-, because it creates a clean distinction between structural relations, and dynamic relations between activities like control/object flow. In other words: use classes & activities/use cases to visualize structural relations, and objects (= class instances) and actions (=activity instances) to visualise dynamic relations. Write script/SQL to resolve relations between the underlying classes & activities.

hope this helps,

Paulus
« Last Edit: December 11, 2012, 08:46:01 am by pmaessen »

rnv

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #9 on: December 11, 2012, 06:53:54 pm »
thanks a lot Paulus for the explanation!

rnv

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #10 on: December 13, 2012, 11:03:17 pm »
one question more:  ;)

I created actions and created an activity diagram. Now, i would lke to create scenario based on the activity diagram.

but seems like i cannot create scenario structure from manually created diagram.

I tried using the 'Create Structure from Generated Activity Diagram': it does something if the diagram was generated from scenario structure.

is there a way?

regards,
rnv


Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Reusing Activity in multiple use case scenario
« Reply #11 on: December 16, 2012, 04:29:36 am »
I haven't used this feature of EA before.

As far as I can see there is no easy way to convert a manually created  diagram using actions into scenario's  :(...