> For the complete documentation index, see [llms.txt](https://educacion.gitbook.io/programacion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://educacion.gitbook.io/programacion/ud4-elementos-da-programacion-orientada-a-obxectos/uml-linguaxe-de-modelado-unificada.md).

# UML (Linguaxe de Modelado Unificada)

**UML** (Linguaxe de Modelado Unificado) é unha ferramenta que describe mediante linguaxe gráfica a estrutura e o funcionamento dun sistema, para o que utiliza diferentes diagramas.

Existen diferentes variades de diagrama UML (mais de 10), en función do aspecto do sistema que imos a querer representar. Neste punto nos imos a centrar non **diagrama de clases**, que describe a estrutura estática do sistema modelando as clases, os seus atributos, métodos e as relacións existentes entre elas.

Unha clase represétese mediante un rectángulo dividido en tres seccións: nome da clase (na parte superior), atributos (no centro) e métodos ou funcións (na parte inferior).

## Elementos da clase

* **Nome**: Debe ser significativo e comezar con maiúscula
* **Atributos**: Características ou propiedades da clase. Indícanse con:

  text

  ```
  visibilidade nome: tipo = valorPorDefecto (opcional)
  ```

  **Símbolos de visibilidade:**

  * `+` → **Público** (accesible desde calquera clase)
  * `-` → **Privado** (só accesible desde a propia clase)
  * `#` → **Protexido** (accesible desde a clase e as súas subclases)
  * `~` → **Paquete/Default** (accesible desde clases do mesmo paquete)
* **Métodos**: Accións ou comportamentos da clase. Indícanse con:

  text

  ```
  visibilidade nomeMétodo(parámetro1: tipoParam1, ...): tipoDeRetorno
  ```

  Para os **métodos estáticos**, indícase subliñando o nome do método ou antepoñendo o estereotipo `<<static>>`.
* **Constructores:** Definen os métodos específicos de creación para cada unha das clases.

Un exemplo dunha clase Persoa sería:

{% @mermaid/diagram content="classDiagram
direction LR

```
%% Clase Persoa - Exemplo completo con visibilidade
class Persoa {
    -id: int = 0
    -nome: String
    -idade: int
    #contadorInstancias: static int
    +Persoa(nome: String, idade: int)
    +getNome() String
    +setNome(nome: String) void
    +calcularAnoNacemento() int
    +getContador()$ int
}" %}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://educacion.gitbook.io/programacion/ud4-elementos-da-programacion-orientada-a-obxectos/uml-linguaxe-de-modelado-unificada.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
