Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Método .update() do controller de cliente não respeita SRP (Princípio de Responsabilidade Única)

Open
#12 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
api, backend

Research direction

Start in the client controller around lines 65–68 and inspect the update entry point and its route. Verify the behavior for requests without cli_cd_cliente, then define completion as update handling existing clients without calling controller.create(), with any separate create-or-update behavior isolated as proposed.

Written by the indexing model from the issue text.

Description

enhancement

Método update ao receber objeto sem código de chave primária está chamando método controller.create(). Além de fugir do modelo MVC padrão (model <-> controller <-> view, um controller jamais fala com outro controller, se voce precisa reaproveitar comportamento, voce faz a partir de métodos privados, mas uma rota nunca chama outra.), não respeita o conceito S de _S_OLID.

   // linha 65 ~ 68
    if(!req.body.cli_cd_cliente){
      controller.create(req, res);
      return;
    }

Single Responsibility Principle (Princípio da Responsabilidade Única)

The single responsibility principle states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.

Imagine such a module can be changed for two reasons. First, the content of the report could change. Second, the format of the report could change. These two things change for very different causes; one substantive, and one cosmetic. The single responsibility principle says that these two aspects of the problem are really two separate responsibilities, and should therefore be in separate classes or modules. It would be a bad design to couple two things that change for different reasons at different times.

Proposta de solução:

O método .update(req, res) deve ser responsavel, exclusivamente, e somente para atualização de clientes já cadastrados. Se é necessário esse tipo de comportamento, um método .upsert(req, res) deverá ser criado, e ter uma rota onde essa responsabilidade seja encapsulada somente para este metodo.

Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from armand1m/tript-api

All issues in armand1m/tript-api

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.