Unified Compliance NextGen
  • UCF NextGen
    • On-Boarding
    • PlantUML
      • Diagrams as Code
        • Why use diagrams as Code tools?
        • Use Cases
        • Introduction to PlantUML
        • Syntax
          • Basic PlantUML Syntax
          • Sequence Diagram
            • Lifelines
            • Messages
            • ExecutionSpecification
            • Autonumber
            • Notes
            • Interactions
            • Organization
          • Use Case Diagram
            • Use Case
            • Actor
            • Associations
            • Organization
            • Notes
          • Class Diagram
            • Classes and Other Entities
            • Attributes and Methods
            • Relationships
            • Organization
            • Notes
          • Object Diagram
            • Objects
            • Relations and Associations
            • Organization
            • Notes
          • Work Breakdown Structure Diagram
            • OrgMode Syntax
            • Arithmetic Notation
            • Styling
          • Activity Diagram
            • Actions and Other Objects
            • Arrows
            • Conditionals
            • Loops
            • Forks, Splits, and Merges
            • Notes
          • Text Formatting
          • Skin Parameters
    • Control Workspace
      • My Frameworks
        • Authority Document Details
        • Common Control Details
      • List Manager
      • Compare
      • Exports
    • UCF Catalog
    • Profile
    • Administration
      • Account Settings
        • General
        • Team
        • Organization
        • Industry
        • Groups
        • Initiatives
      • API Manager
      • Billing
    • API Gateway
Powered by GitBook
On this page
  • Declaration
  • Shorthand
  • Properties
  • Asset State
  • Visibility
  • Text
  • With All Properties

Was this helpful?

Export as PDF
  1. UCF NextGen
  2. PlantUML
  3. Diagrams as Code
  4. Syntax
  5. Class Diagram

Attributes and Methods

The class body contains the attributes and methods of the class. These are automatically placed in predetermined areas in the class body. **** Attributes **** appear in the upper portion of the body and methods appear in the lower portion.

Declaration

Attributes and methods are declared with an asset_type followed by text. Notice how the method text is placed in the lower portion of the class body even though it is above the attribute text in the code.

Example: Declaring Attributes and Methods

@startuml
'Example: Declaring Attributes and Methods

'Create a class.
class Class{

    'Add a method with asset_type and text.
    {method} Method_Text

    'Add an attribute with asset_type and text.
    {field} Attribute_Text
    
}

@enduml

Shorthand

Shorthand allows us to declare attributes and methods without the asset_type. Shorthand attributes are just written as a string on one line. Shorthand methods are the same and end in a set of parentheses.

Note: asset_type will override shorthand. See line 15.

Example: Shorthand Attributes and Methods

@startuml
'Example: Shorthand Attributes and Methods

'Create a class.
class Class{

    'Add a method using shorthand.
    Method Text()

    'Add an attribute using shorthand.
    Attribute Text 1

    'Add an attribute with asset_type and text.
    'Put parentheses at the end of the text.
    {field} Attribute Text 2()
}

@enduml

Properties

Attributes and methods have four properties. When using the shorthand method the only required property is the text. If shorthand is not used asset_type and text are both required.

  • asset_state - determines if the asset is abstract or static

  • visibility - determines the visibility of a method or attribute

  • text - describes the attribute or method

Asset State

The asset_state property allows you to label attributes and methods as abstract or static. Abstract assets appear in italics. Static assets appear with an underline.

Example: Attributes and Methods Asset States

@startuml
'Example: Attributes and Methods Asset States

class Class{

    'Add an abstract attribute with an asset_type.
    {abstract} {field} attribute1

    'Add a static attribute using shorthand.
    {static} attribute2

    'Add a static method with an asset_type.
    {static} {method} method1

    'Add an abstract method using shorthand.
    {abstract} method2()

}

@enduml

Visibility

When used, the visibility property is placed directly in front of the text.

  • - - signifies a private attribute or method

  • # - signifies a protected attribute or method

  • ~ - signifies a package private attribute or method

  • + - signifies a public attribute or method

Example: Attribute and Method Visibility

@startuml
'Example: Attribute and Method Visibility

'Create a class.
class "Class Name"{

    'Add two attributes with all three properties.
    {field} -attribute1
    {field} #attribute2

    'Add two attributes with shorthand.
    'Add visibility properties.
    ~attribute3
    +attribute4

    'Add two methods with all three properties.
    {method} -method1
    {method} #method2

    'Add two attributes with shorthand.
    'Add visibility properties.
    ~method3()
    +method4()

}

@enduml

Text

You can format text with creole syntax for emphasis and markup language for color and emphasis. You can define colors with a standard color name or hex code.

Example: Attribute and Method Text

@startuml
'Example: Attribute and Method Text

'Create a class.
class "Class Name"{

    'Add an attribute with an asset_type.
    'Use creole to emphasize the text.
    {field} **attribute1**

    'Add an attribute using shorthand.
    'Use markup to emphasize the text and add color.
    <color #561D5E><b>attribute2</b></color>

    'Add a method with an asset_type.
    'Use markup to emphasize the text and add color.
    {method} <color #561D5E><b>method1</b></color>

    'Add a method using shorthand.
    'Use creole to emphasize the text.  
    **method2()**

}

@enduml

With All Properties

Example: Attributes and Methods With All Properties

@startuml
'Example: Attributes and Methods With All Properties

class Class{

    {abstract} {field} -**attribute1**

    {static} #<color #561D5E><b>attribute2</b></color>

    {static} {method} ~<color #561D5E><b>method1</b></color>

    {abstract} +**method2()**

}

@enduml
PreviousClasses and Other EntitiesNextRelationships

Last updated 1 year ago

Was this helpful?

asset_type - determines if the asset is an attribute or method, shown above in

Declaration
Declaring Attributes and Methods
Shorthand Attributes and Methods
Attributes and Methods Asset States
Attribute and Method Visibility
Attribute and Method Text
Attributes and Methods With All Properties