Skip to content

Latest commit

 

History

History
160 lines (137 loc) · 3.2 KB

design.mdx

File metadata and controls

160 lines (137 loc) · 3.2 KB

import { Appear, Image } from 'mdx-deck' import { SplitRight } from 'mdx-deck/layouts'

Study case


=== RUN TestOpenUmbrella
--- PASS: TestOpenUmbrella
PASS
OK


import { CodeSurferLayout, CodeSurferColumnLayout, Code, Step, } from "code-surfer";


Problem?

  • Handler code is BIG and getting bigger
  • Possibility redundancy code
  • Difficult to manage branching of logic flow
  • Difficult to mocking a function
  • Cannot maintain code clarity

Solution?

  • Clean code
  • Make a slim handler
  • Put logic to usecase/service layer
  • Move database query to repository layer

What we got after refactor?



Directory Structure

├── handler
│   └── handler.go
├── delivery
│   ├── todo_http.go
│   └── todo_http_test.go
├── repository
│   ├── mysql_category.go
│   ├── mysql_category_test.go
│   ├── mysql_task.go
│   ├── mysql_task_test.go
│   ├── repository_test.go
│   └── util.go
├── service.go
├── service_test.go
└── usecase
    ├── todo.go
    └── todo_test.go