Classes & Interfaces

Classes are the fundamental building blocks of class diagrams. They represent objects in your system with their attributes (fields) and methods (operations).

Basic Classes

Define a class using the class keyword followed by the class name. You can include attributes and methods inside curly braces.

Class Diagram Example
Loading...
Basic Classes Example

Attributes and Methods

You can define attributes and methods using two syntax styles: simple declarations or with type annotations using colons.

Class Diagram Example
Loading...
Attributes and Methods Example

Visibility Modifiers

Control access to class members using visibility modifiers. Place the modifier symbol before the member name.

  • -
    Private - Only accessible within the class
  • #
    Protected - Accessible within the class and subclasses
  • ~
    Package - Accessible within the same package
  • +
    Public - Accessible from anywhere
Class Diagram Example
Loading...
Visibility Modifiers Example

Abstract Classes

Abstract classes cannot be instantiated directly and are used as base classes. Use the abstract class or abstract keyword.

Class Diagram Example
Loading...
Abstract Classes Example

Interfaces

Interfaces define contracts that classes must implement. They contain only method signatures without implementations.

Class Diagram Example
Loading...
Interfaces Example

Enumerations

Enumerations represent a fixed set of constants. Use the enum keyword to define them.

Class Diagram Example
Loading...
Enumerations Example

Other Class Types

SparkChart supports various other class types for different modeling needs.

Class Diagram Example
Loading...
Other Class Types Example

Class Aliases

Use the as keyword to create shorter aliases for classes with long names, or to provide display names.

Class Diagram Example
Loading...
Class Aliases Example