Attributes without type in Class Diagram

In summary, the data type for attributes in UML class diagrams is usually public or private, depending on whether the attribute is for an object or a method.
  • #1
zak100
462
11
Hi,
I am using a book for studying UML. It shows attributes without any data types:
dataReceived
isPrepaid
number: String
price: Money

What is the data type associated with above two i.e dataReceived & isPrepaid & what is their visibility (i.e publc /private). Some body please guide me.

Zulfi.
 
Technology news on Phys.org
  • #2
Can you provide a screenshot of what you see? My guess is that there are other symbols there that you don't realize represent something. Are there what look like bullet points?

When designing classes for C++, I use these symbols:
Code:
+ dataReceived - public
- dataReceived - private
# dataReceived - protected
/ dataReceived - derived
~ dataReceived - "C" function
+^ dataReceived - public overridden
+v dataReceived - public virtual
+s dataReceived - public static

Usually, if the return type is not shown, it returns void, but considering that your isPrepaid function probably returns a bool, my assumption is that you're missing some information.
 
  • Like
Likes iheadset
  • #3
zak100 said:
Hi,
I am using a book for studying UML. It shows attributes without any data types:
dataReceived
isPrepaid
number: String
price: Money

What is the data type associated with above two i.e dataReceived & isPrepaid & what is their visibility (i.e publc /private). Some body please guide me.

Zulfi.
UML class diagrams usually include

Class name​
visibility attribute: type //for objects
----------------------------------------------
visibility operation(arg list types): return type // for methods​

visibility varies among groups of coders, organizations etc. But public(+) and private(-) are two most basic keys every class diagram should have.
 
  • #4
Hi,
Thanks for your response.
<Usually, if the return type is not shown, it returns void, but considering that your isPrepaid function probably returns a bool, my assumption is that you're missing some information>
Its an attribute not an operation. Maybe iheadset is right:
<visibility attribute: type //for objects>
It should be a primitive data type.

Zulfi.
 

Attachments

  • class diagram attribute without type.jpg
    class diagram attribute without type.jpg
    17.6 KB · Views: 529
  • #5
Looks like just lazy UML diagramming to save space.
 

Related to Attributes without type in Class Diagram

1. What are attributes without type in a Class Diagram?

Attributes without type in a Class Diagram refer to the properties or characteristics of a class that do not have a specific data type associated with them. This means that the attribute's value can be of any type, such as a string, integer, or boolean.

2. Why would attributes without type be used in a Class Diagram?

Attributes without type can be used in a Class Diagram to represent attributes that may have different data types in different implementations or programming languages. They can also be used to indicate that the attribute's data type is not important for understanding the class's functionality.

3. How are attributes without type represented in a Class Diagram?

Attributes without type are represented in a Class Diagram by placing a colon (:) after the attribute name, followed by a blank space. This indicates that the attribute does not have a specific data type associated with it.

4. Can attributes without type have a default value in a Class Diagram?

Yes, attributes without type can have a default value in a Class Diagram, just like attributes with a specific data type. This default value can be used to initialize the attribute when an object of the class is created.

5. Are attributes without type considered good practice in Class Diagrams?

There is no right or wrong answer to this question as it depends on the specific use case. In some situations, it may be more appropriate to specify a data type for each attribute in a Class Diagram. However, in other cases, using attributes without type can make the diagram less cluttered and easier to understand.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
2
Replies
48
Views
9K
  • Programming and Computer Science
Replies
2
Views
2K
  • Computing and Technology
Replies
1
Views
932
  • Programming and Computer Science
Replies
6
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • High Energy, Nuclear, Particle Physics
Replies
13
Views
2K
  • Programming and Computer Science
Replies
2
Views
6K
Replies
6
Views
1K
Back
Top