Creating components under a package

When you create a Rhapsody® project, a component called DefaultComponent is created directly beneath the project level. You can also create additional components at this hierarchical level.

About this task

It is also possible to create a component as part of a package in the model. One of the advantages of this approach is that if you only want to generate code for a specific package, you only have to check out that package.

You can add a component to a package using any of the following methods:

  • Create a component in the package by right-clicking the package in the browser and selecting Add New > Component.
  • Move an existing component in the browser to the package.
  • Draw a component in a component diagram that is located under a package.
  • Create a component in a package using the Rhapsody API.

When a component is created under a package, its default scope is the package to which it belongs.

Like other components, components that belong to packages can be assigned to be the active component for the project. When you create a component in a package, it automatically becomes the active component for the project.

Note: If you draw a component diagram under a package (rather than under the project), keep in mind that then it is not possible to draw a new folder on the diagram. The reason is because the folder element cannot be contained under a package.