Book a Demo

Author Topic: Classes go in Class model or Component model?  (Read 3688 times)

jdeauml

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Classes go in Class model or Component model?
« on: October 29, 2010, 12:18:10 am »
I am relatively new to UML and an EA novice.  I am a little confused about in which model classes typically reside.  Component diagrams show components, interfaces and classes.  Component diagrams show component decomposition into classes and interfaces, so it seems that you would create classes and interfaces in that model.  So, what goes in the class model?  Is it just more detailed diagrams on the classes?  What level of detail do you show for classes in component diagrams versus class diagrams?

DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Re: Classes go in Class model or Component model?
« Reply #1 on: October 29, 2010, 01:22:13 am »
I use component diagram to depict the names of external interfaces and composite diagrams to show control and data flow interconnection between the subcomponent instances. I find these two representations, along with state charts, to be the most useful diagrams for design specification to be used for coding and maintenance.

I use class diagrams while figuring out the decomposition but a class diagram tends to be a temporary document for me. The complete details of a class are more easily expressed in my target language (C++) than in UML. It is easier to express the details, compile and then import the detailed class descriptions when I what to see class structure. I miss out on using class diagrams to express constraints so I'm studying that usage.

You should Google Leon Starr, though. He has a good blog article (and a book I have not read) about clearly expressing constraints in class diagrams. This seems like the very best purpose of a class diagram yet I seldom see them used to this full advantage.

TIFWIIW,
Dan

jdeauml

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Classes go in Class model or Component model?
« Reply #2 on: October 29, 2010, 04:44:28 am »
So, where/how do you link classes to components?

If you create your interfaces in your component diagrams, then I suppose they exist in your Component model.  When you create class diagrams, do you drag interfaces from the component model onto your class diagram as a link?  Or, do you re-create the interface in the Class model?

DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Re: Classes go in Class model or Component model?
« Reply #3 on: October 29, 2010, 07:34:46 am »
When creating new interfaces, I create the element directly in the project browser under the global interfaces package. I assign it to a flow port (essentially a public attribute of the component) by assigning it as the port classifier in my component diagram. For mode changing interfaces (pure virtual classes defining member functions) I add required and provided interfaces of the requisite type (from the global interfaces package).

Global Interfaces
  namespace
    interface
    interface
    interface
Global Classes
  namespace
     class
     class
Component Package
  Component Model
    Component diagram depicting the component by itself (pin-out diagram)
    Component element
      port1 (with classifier defined in the global interfaces package)
      port2
      port...
      partA (with classifier defined in Class package below)
      partB (with classifier defined in a global class package)
      part... (or classified by component classifier defined in another component package)
  Classes
     namespace
       namespace for this component
         class diagrams - primarily inheritance depictions
         class
         class
Compoent package
   ...
  
The parts attributed to the component can be classified by external classes or other components. When you do that you have and inter-package dependency. This of course is only practical and you'll take care to package those global classes carefully (they must not directly use internal classes). Thus, this component package will depend on the global interfaces package and a global class or component package.

This is just my way of doing things and is not pure. It is very much an implementation model can could be derived from a logical model. However, my skills progression goes like this:
Learn to write code that you can get to work
Learn to write code that you can test <-- lots of years at this plateau
Learn to write code that you can model <-- recent accomplishment
Learn to write models that map to code <-- " "
Learn to write requirements that you can allocate to your model <-- working on it
Learn to write models that you can model... <-- aspiring to

Dan