Are my class diagrams Correct? - class-diagram

I've made two class diagrams. But I am not sure if they are correct or not. These classes were in the same package and I used Visual Paradigm for making the class diagrams. However, I couldn't make one ReadOutputFileforBreastAndColonCancer class for both WeakSignalFilter class and StrongSignalFilterClass.
Therefore, I had to make two different class diagrams. Is it correct? Can I do it.
Help will be much appreciated.

Please refer to VP's support page, Creating class diagrams. First create the StrongSignalFilter class, then click its Aggregation -> Class resource beside it and drag to empty space of the diagram to create the ReadOutputFileforBreastAndColonCancer class. Next create the WeakSignalFilter class. Finally the crucial step: click the Aggregation -> Class resource beside the WeakSignalFilter class, and drag to the ReadOutputFileforBreastAndColonCancer class. This is how to create an association between two existing classes. And of course you can also create the three classes first before creating the two aggregrations.

Related

Show UML Class diagram autopopulating class dependencies

In IntelliJ IDEa, one can quickly create an UML Class diagram for any class or a set of classes. You can add classes to the diagram via drag and drop or using space key for that.
Then you can show dependencies between the classes. However, I'd like to see what are all the classes that interact with some specific class. If I show a diagram of that class only, I'll only get some inheritance in that diagram, but dependencies associations are not shown. For that I need to drag in all classes that I know interact with the class and then show dependencies. Usually I would just drag the whole package in, expecting that there are classes that interact with this class. But that will bring in a whole lot more unrelated classes and then the diagram explodes.
Is there some smart way of adding just classes that directly interact with my class, so the diagram scope is more limited? E.g. all class interacting with a class from a certain package?

Class diagram - multiple classes uses same class

I am designing a class diagram for an assignment. In this design, I use a separate class called Currency, to define currency values and their functionality. there are at least four other classes have to use this Currency class.
How can I show it in the class diagram ? I mean, do I need to draw relationships (connecting lines) from the Currency class to all the others ?
Is there a better way ?
What am I doing wrong here ?
There is nothing wrong and a reusability of a class is valuable. Actually that's a standard situation.
If you use this class in another class as an attribute you have two options to depict that:
draw an association relationship (line) from the class using to the class that is used.
put the attribute in a proper compartment of a class that is using and as a type of an attribute (after a colon) put the name of the used class.
The benefit of the first approach is that you immediately see the dependency between the classes.
If you use a class but not directly as an attribute type you use other relationship types that suit best to the situation you want to describe.
As I imagine one of your concerns is that you'll have a lot of relationships pointing to your class (in your case Currency). Don't worry about that. You don't have to put everything in a single diagram. Put a full specification of your class on one diagram with those relationships where it uses something else and then put only the class box with a name (without any compartment) on diagrams defining those elements that use your class. It will make your model readable. And with a support of some CASE tool you will be able to see all relationship and dependencies of this class anyway. By the way that's how the UML specification is written. Look for example how Namespace is used in the diagrams there (and many others as well).
Of course I'm not suggesting creating one diagram per one element to define it. No. Collect them in logical Packages (hey - that's exactly what Packages are for!) and make a class diagram per Package. If the Package becomes too large - you might need to split it into smaller subpackages.
For Currency your Package would be probably something like Utils. It can also contain other elements like Date, Address etc. Note - these are typical examples, probably every analyst/designer/programmer sooner or later has to cope with those elements. If you build them well, you'll be really able to reuse them in future applications as well.
One last thought. While you build "package based" Class diagram you might also need a diagram that shows just specific parts coming from several Packages to clarify some bit of your system/business/whatsoever. This is also absolutely fine. Again a benefit of CASE tool here is that it keeps consistency in your model.

What is difference between inheritance and category

what is the difference between inheritance and category in objective-c
Both are used for the subclass! So what is difference between them
While Category is a nice way to add functionality to the base class, people like me who come from other object oriented technology such as Flash, will find a little difficult to understand as to how this thing relates to the inheritance chain. The same question came up to my mind and I did a quick research on the topic.
The final thing is Category does the same thing as it tells about itself. It adds functionality to the base class. If you remember this, then there would be no confusion at all.
Well, for that to understand, lets take an example. Suppose there is a Class A and Class B is a subclass of Class A. In the application Class B is used in a lot of places. Now, there is a need to add some more functionality to Class A, so a new category is written as "A+newRole". Once this category is written, the new functionality is added to the base class and in this case, Class A. That means, all those classes which are child classes of Class A such as Class B, automatically gets the functionality. Thats freaking cool. One can straight away go ahead and call the new methods added in the Category from the child classes. The only thing necessary here is to import the Category file to the appropriate place.
A category adds extra functionality to a class without generating a new class at all, you just extend it but it does not have polimorphism implied or anyting like it.
Inheritance on the other hand, generates a new class on its own right in which you can add new instance variables and override behavior from the parent class by polimorphism.

What is the difference between Object-Graph and a class diagram?

Is there a difference in the meaning of "class diagram" and "object graph"?
see this tutorial
http://www.cs.toronto.edu/~jm/340S/Slides6/ClassD.pdf
Object graph contains value of one instance of class see example View its a view of an object system at a particular point in time
while
class diagram as wiki
The class diagram is the main building block of object oriented modelling. It is used both for general conceptual modelling of the systematics of the application, and for detailed modelling translating the models into programming code. Class diagrams can also be used for data modeling.[1] The classes in a class diagram represent both the main objects and or interactions in the application and the objects to be programmed. In the class diagram these classes are represented with boxes which contain three parts: [2]
A class with three sections.
The upper part holds the name of the class
The middle part contains the attributes of the class
The bottom part gives the methods or operations the class can take or undertake
see further
I agree with the previous post but would like to add that a class diagram is based on UML which is an accredited language sponsored by the OMG and known by over 5 millions users. UML is therefore a standard based on a model from which you get views.
IN UML 2 the class diagram is fantastic if used with Java because it seems to me that the new specification has exactly the same structure as a java project. It include a project name, with packages including classifiers (e.g. Class, interface, enum) which includes attributes, methodes which includes properties.
If you have to use just one diagram I would say to use Class diagram. It is easy to create because you don't need to know UML and can reverse engineer your project into a model a get class diagram views. My class diagram is Just magic:-)
Class diagram represent class name,its attributes and behaviours whereas object diagram represent instance of class diagram,object diagram comes under class diagram

Define inherited class in base class library or new project

I've written a abstract base class TCPIP sever in its own namespace/library. Currently I have the derived class (more specific TCPIP server; with DataHandler) in the .exe project of the solution.
I'm almost 100% certain this is how I will go, but part of me wants to put the derived class in the base class project. What are some good reasons for/against this?
I believe YAGNI, KISS and The Rule Of Three apply here. If you don't have immediate plans to try to reuse the derived class, then keep it in the application namespace. If you find later there is a second project/application that can use something like your derived class then keep to your plan and use it as a "template" to create another similar derived class by cut and paste.
If you find a third occasion to do this again, then you can take a look and see if there is a reasonably useful subclass sitting in there. Don't get distracted trying to spot reusable abstractions too early.
"Why do I need the base class library"?
Usually because you want to use it in multiple projects.
If this is the case, do you need to use the derived class in other projects?
If you plan on having other exe's use the your derived class its helpful if it there and not in the exe.
My reasoning in favor of this approach is that if I put the dervied class in the .exe namespace, I will have access to all those classes (e.g. data queue). However, if I put the derived class in base project, I'd have to grant access to all the classes in the .exe namespace in order to use just one of them (using DotExeNamespace;).