3

I want to generate a package diagram with hierarchical packages which may contain duplicated names but not in the same level. e.g.:

@startuml
package A {
    package B {
        package C
    }
    package A
}
@enduml

I think, package A.A might be acceptable. But plantuml failed with this error: Thie element (A) is already defined.

I also try the following:

@startuml
folder A {
    folder B {
        folder C
    }
    folder A
}
@enduml

Then, plantuml failed with the same error.

3 Answers 3

8

One of the options :

@startuml
package A as pkg0{
    package B as pkg1{
    }
    package A as pkg2{
        package A as pkg3{
        }
    }
    package A as pkg4{
    }
}
@enduml

will give result

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

3

You can draw diagrams with duplicated names if you include non-printing characters in the definition, e.g. by putting the name in quotes and including one or more space characters:

@startuml
package A {
    package B {
        package C
    }
    package "A "
    package "A  "
}
@enduml

The additional spaces do not affect the layout in the diagram:

UML class diagram with duplicated packages

Comments

0
@startuml

package "Hotel Management System" {
    
    package "Business Logic" {
        class Booking {
            +createBooking()
            +cancelBooking()
        }

        class Customer {
            +registerCustomer()
            +updateCustomer()
        }

        class Room {
            +checkAvailability()
            +bookRoom()
        }

        class Payment {
            +processPayment()
            +issueRefund()
        }
    }

    package "Data Access" {
        class BookingRepository {
            +saveBooking()
            +deleteBooking()
        }

        class CustomerRepository {
            +saveCustomer()
            +deleteCustomer()
        }

        class RoomRepository {
            +saveRoom()
            +deleteRoom()
        }
    }

    package "User Interface" {
        class BookingView {
            +displayBookingForm()
        }

        class CustomerView {
            +displayCustomerForm()
        }

        class RoomView {
            +displayRoomDetails()
        }

        class PaymentView {
            +displayPaymentForm()
        }
    }

    package "Notifications" {
        class EmailService {
            +sendConfirmationEmail()
        }

        class SMSService {
            +sendSMSNotification()
        }
    }

    ' Relationships
    Booking --> BookingRepository : uses
    Customer --> CustomerRepository : uses
    Room --> RoomRepository : uses
    Payment --> Booking : processes
    BookingView --> Booking : interacts with
    CustomerView --> Customer : interacts with
    RoomView --> Room : interacts with
    PaymentView --> Payment : interacts with
    Booking --> EmailService : notifies
    Booking --> SMSService : notifies

}

@enduml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.