2

I have recently started a course in software development and I'm having some confusion over modelling my system in a Class Diagram. The context of the system is as follows: The user wants to calculate the performance (power consumption and outlet temperature) of an air conditioner unit at a particular inlet temperature. A piece of code calculates this based on the provided inputs and the properties of the air con unit. This calculation (inputs, outputs, aircon model) is recorded in a file.

I am unsure of how many associations are required for this model. This is what I have modelled so far:

enter image description here

  • 1
    Navigability would greatly increase the readability of your diagram. Let alone roles and multiplicity. Edit: I am not sure calculator should be a class in the diagram. If it is, you could have it work with the performance file only, and access the other objects through it. – Theraot Jun 6 '18 at 12:26
  • Thank you for your suggestion. This might be a silly question, but is there a limit on how many classes you can access data through? I.e. Class A associated with B, B with C. Can you access data from Class C through A? – SimStil Jun 6 '18 at 13:00
  • 1
    No hard limit. There is an overhead, so there could be be less performance the deeper you go... I have to say that also depends on the platform. On the other hand, every time you see a ring (not necesarily a loop, but any ring) in a class or entity diagram, be extra careful. For instance, If the calculator has a link to an air conditioner, but a performance file that points to a different air conditioner, does it make sense? In some cases having two ways to go from a class to another make sense, in others it doesn't, that depends on the problem domain. If there's lot of that, look closer. – Theraot Jun 6 '18 at 13:06
  • 1
    This diagram is not correct. UML Class Diagram shows Classes (or objects) and specifies how they are associated. You need to first do this: 1- Identify your classes, 2-Identify the properties and methods of each class/object 3-Identify the associations and finally put together the diagram. For example Calculator is not a stand-alone object, it is the entire system. Outlet Conditions is not an object either. Method parameters are not always objects. – NoChance Jun 7 '18 at 11:51
3

There is no specific limit on the number of associations, but if everything is linked to everything else, then there's probably something wrong with the design, and it's going to be horrid to implement.

As the design evolves, most of the links should end up unidirectional, and most should end up being more specific than just associations. The common types of link would be A "is a" B (inheritance), A "has a" B (containment) and A "uses" B (simple association).

Once most of the links have been made unidirectional, it should be possible to redraw the diagram as a nice hierarchy, with no circular dependencies or arrows going "the wrong way".

| improve this answer | |
1

You should put in the class diagram all the classes and association you need, regardless how many. But not more.

So let me challenge your diagram:

  1. Will you really have a class PerformanceFile with properties and methods ? Or is the file just an artefact created by a Calculator upon invocation of one of its methods (e.g. savePerformanceFile(filename) ?
  2. What are the differences between inlet and outlet conditions ? Are these the same kind of conditions (e.g.temperature, humidity, pression, ...) but with a different source (e.g. input and output) ?
  3. Is there a structural relation between the Calculator and the conditions it uses for the calculation ? Or does it just access conditions that are measured by the AirConditionner ?

With the assumptions 1)No, 2)Different, 3)No, 1 calulator for 1 unit, I'd see a diagram with much less relations:

enter image description here I

I've detailed some properties and methods, just to clarify the responsibility of the classes. But if you just keep the classes you'll have a much simpler diagram.

Important remark: if the calculator measures the conditions, the conditions would be linked to the calculator instead of the air conditioning unit. In this case, if the calculator could control several airco units, it would be necessary to link the conditions to both the calculator and the unit:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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