2

I have an abstract process class

Abstract class **A**

it has member function run()

classes B,C,D,E are inherited from abstract class A.

I have an class called F (ProcessFactory) which has a function called getProcess() which takes argument and gives one instance of specified type of process object.

Now another class called G which uses class F and get the instances of class B,C,D,E and work on them.

I would be happy if someone can provide an UML class diagram for the above scenario. As my classes involves threads, so is there anything which can show in UML for thread related classes?

3
  • Odd question. Is this homework?
    – Rick Mangi
    Commented Feb 20, 2013 at 2:51
  • 1
    No its not. but I am confused when I am reading a concepts from UML tutorial. Commented Feb 20, 2013 at 2:54
  • Could you provide more details on your classes (since you said that you need to draw an UML Class diagram based on some existing code, otherwise we would be imagining your classes).
    – Javier
    Commented Feb 20, 2013 at 5:39

1 Answer 1

1

A UML class diagram is a static diagram, so it doesn't care if a class is a thread, a process or a monkey. Everything is a class, which has attributes and methods. You can state that A inherits from thread, but that's about all you can say about threads. So you would get something like this:

enter image description here

  • Edit: please see my comment below for clarification.
3
  • I don't think G has a direct relationship with A. It's using F as a sort of proxy to access the classes B, C, D, and E. From the diagram I would bet that the return type of getProcess() would be of type A even though the specific instance being returned would be one of the child classes. I'm not sure how to represent that in UML. Commented Feb 20, 2013 at 14:57
  • I am with Kelly. This was my concern, so put this question. I am confused if I should draw the arrow from F to A or G to A. Commented Feb 20, 2013 at 16:08
  • You are right, you would also need a dependency arrow from F to A. I drew a direct relationship from G to A assuming that G calls some function in the instances that he receives from F, that for G sees as instances of A (since this is what F returns). Hope I made myself clear.
    – vainolo
    Commented Feb 21, 2013 at 10:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.