Método .update() do controller de cliente não respeita SRP (Princípio de Responsabilidade Única)
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
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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from armand1m/tript-api
All issues in armand1m/tript-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 2 days
-
feedback simulation workshop
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
githubnext/gh-aw-workshop#4755 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
videojs/video.js#9537 · 1 comment ·
Maintainers usually reply within 1 day
-
fix
Difficulty 1/5 Under an hour Newbie friendliness 72/100
idean3885/claude-ops-agent#728 ·
Maintainers usually reply within 1 day