Book a Demo

Author Topic: Moving classes from one view to another  (Read 4928 times)

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Moving classes from one view to another
« on: June 17, 2011, 03:30:40 am »
Using EA version 7.5.850.

Our project uses what someone else on this forum called a "kitchen sink" approach whereby there is one diagram that contains all classes that are in use for the project, and other diagrams that use links to those classes to depict all the different functions and capabilities.

All new classes that get added to the project are added to the kitchen-sink diagram, then links are used wherever the class is needed.

We ended up with a lot of classes that didn't get used and I want to move all of these off of the kitchen-sink diagram and save them somewhere else (some of them will be used in a planned enhancement to the product).  I'd just like to make sure I'm doing it right.

I have established a new "view" in the Project Browser and added a diagram titled "Unused Classes" to that view.  I then select each unused class in the kitchen-sink diagram and do an Edit->Copy.  Then I go to the Unused Classes diagram in the Obsolete view and say Edit->Paste element(s)->as New.  Then I go back to the kitchen-sink diagram and do a Project Browser-><right click on class>->Delete <classname>.

Sound about right?
« Last Edit: June 17, 2011, 03:31:34 am by rkt-med »

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Moving classes from one view to another
« Reply #1 on: June 17, 2011, 11:35:19 am »
No no no no no!  You will lose all your unused Class elements that way, because you are deleting them from the model. Don't delete elements from the Project Browser unless you never want to see them again.

Using the 'Kitchen Sink' diagram as a reference, drag all the unused Classes IN THE PROJECT BROWSER from their current package into your Obsolete View package(s). Now delete all the unused Classes FROM THE KITCHEN SINK DIAGRAM, and finally, drag-and-drop the Classes from the Obsolete packages into your Unused Classes diagram.

It might be better to leave the unused Classes in their original parent packages, but I'm not sure how you could easily recognise them and drag them onto the Unused Classes diagram; you can open several diagrams at once, but you can only display one at a time, so you would be doing a hop from diagram to project browser to diagram for each element, which could get tedious.
Best Regards, Roy

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Moving classes from one view to another
« Reply #2 on: June 17, 2011, 07:03:38 pm »
Quote
No no no no no!  You will lose all your unused Class elements that way, because you are deleting them from the model. Don't delete elements from the Project Browser unless you never want to see them again.

Good morning, Roy.

But if I make a copy of the class in the "Unused" diagram in a newly created "Obsolete" view, so that it shows up there in the Project Browser, before I delete it from the "Logical" view in the Project Browser, won't that preserve the class?  I tried that in a throwaway copy of my model and it seemed to work fine.

Quote
Using the 'Kitchen Sink' diagram as a reference, drag all the unused Classes IN THE PROJECT BROWSER from their current package into your Obsolete View package(s). Now delete all the unused Classes FROM THE KITCHEN SINK DIAGRAM, and finally, drag-and-drop the Classes from the Obsolete packages into your Unused Classes diagram.

I'm not using packages.  Very early in this project, and in other projects, I tried to figure out how to use packages the right way in EA, maintaining connections between them, and could not figure it out and couldn't get an answer here.  So the Kitchen Sink diagram just has all the classes without packaging them up into packages.

Now if you're referring to the "Views" in the Project Browser as "Packages", that's different, and I have been using those.  I created a new "View" called "Obsolete / Unused View" and created a diagram under that called "Unused".  Originally as I said I had tried (in my throwaway copy of the model) making copies of the unused classes in the Logical View and then pasting them into the Unused diagram in the Obsolete / Unused View, and that seemed to work fine, then I had to throw away my throwaway copy of the model and start over due to another, unrelated issue.  So I'm back where I started, which is fine, I was just experimenting.

Reading your advice above, I tried dragging and dropping a few of the unused classes into the Obsolete / Unused View... but they go into the View but not into any diagram.  I can not drag and drop a class directly into a diagram, I can only drag and drop an instance of the class, a link to the class, or a generalization of the class, into another diagram.

Perhaps I shot myself in the foot by not using packages in this model, but like I said, in earlier projects mostly involving reverse engineering of code, I would import some classes and end up with the most godawful mess you can imagine (which I expected), then when cleaning up the diagram I tried putting classes into packages while maintaining the associations between classes and could not figure out how to do that, and couldn't get answers from this forum.  In this project I read all I could find on using packages and couldn't figure out the right way, so I gave up and went with the Kitchen Sink diagram and some links.

In any case, like I said, it does seem to be working to make a copy of the unused class (not a link to it) in the Unused diagram in the Obsolete / Unused View, so that it shows up in both places in the Project Browser, before deleting it from the Logical View in the Project Browser.  That seems to preserve it and I don't lose it.  Am I missing something that will make me curse this day later?

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Moving classes from one view to another
« Reply #3 on: June 20, 2011, 10:33:18 am »
OK - I might have just frightened myself there. I just picked up on the concept of holding elements in diagrams and deleting them from the Project Browser, and in my alarm glossed over the copy element step and rushed to warn you before you lost data from your model.

I think the copy step is unnecessary, adding several mouse drags and clicks to the process. You have two choices:

The simplest - leave the unused Classes exactly where they are in the Project Browser, delete them from the Kitchen Sink diagram and drag-and drop them from the Project Browser into the Unused diagram, as Simple Links. The diagrams are your reference points, which might leave you a bit fuzzy as to where your unused Classes are in the Project Browser, both during the drag-and-drop process and in the future.

The second option is to drag and drop the unused Classes in the Project Browser from their current location into the Obsolete View. Then, as before, delete them from the Kitchen Sink Diagram and drag and drop them into the Unused diagram. This just groups the unused elements in one place in the Project Browser, making it easier to drag them into the Unused diagram and to locate them in the future.

You can't add elements automatically to a diagram by moving the element into the parent View. You have to specifically put the element into the diagram. Yes, the Copy operation does put the element into the View and Unused diagram, but then you have to go back and delete elements from the original diagram and the Project Browser. Maybe the difference is a difference that makes no difference, but anything that requires you to delete possibly large numbers of elements from the PB, to me, imposes a higher risk of deleting the wrong element and losing it.

I hope that is a more helpful response!
« Last Edit: June 20, 2011, 10:46:41 am by RoyC »
Best Regards, Roy

EricP

  • EA User
  • **
  • Posts: 122
  • Karma: +0/-0
    • View Profile
Re: Moving classes from one view to another
« Reply #4 on: June 20, 2011, 10:46:59 am »
That's excellent, thanks Roy.

The objective is to be able to right click on the view and go to Code Engineering->Generate Code and generate code for the whole project with a few clicks.  We didn't want to have to generate code for 49 unused classes, most of which don't even generate code to the right directories.

Anyway, it seems to have worked... thanks.