Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#2) GABI #9

Open
wants to merge 1 commit into
base: review/kotlin
Choose a base branch
from
Open

(#2) GABI #9

wants to merge 1 commit into from

Conversation

yuyu413
Copy link

@yuyu413 yuyu413 commented Aug 24, 2020

No description provided.


@DeleteMapping("/delete")
fun deletePostedBlogList(
@RequestBody id: Int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DELETE 메소드는 Body를 사용하는 것이 좋지 않은 방법으로 알고 있습니다.(사실 안되는걸로 알고있음) 대안으로 @PathVariable를 사용하는 것이 좋을 것 같습니다!

blogDB.blogList.add(content)
}
fun updateContent(content: Content){
val updateItem = blogDB.blogList.filter { it.id == content.id }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아직 덜 짠거겠죠..??

// updateItem = content
}
fun deleteContent(id : Int){
val deleteItem = blogDB.blogList.filter { it.id == id }
Copy link
Member

@minkukjo minkukjo Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 Service에서 blodgDB에 대한 로직처리를 하고 있는데, 이는 추후에 blogDB에 대한 로직에 변경이 발생했을 때 이를 사용하는 다른 Service 객체에 모든 변경사항을 반영해주어야해서 유지보수가 어렵습니다.

객체지향 관점에서 봤을 때 유지보수하기 쉬운 코드를 짜려면 데이터에 대한 로직은 blogDB가 갖게 하는게 어떨까 싶습니다.

예시 코드를 아래에 남겨둘게요.

@Service
class Service @Autowired constructor(
        val blogDB: BlogDB
) {
    fun deleteContent(id : Int){
        blogDB.remove(id)
    }
}
@Component
class BlogDB {
    val blogList : MutableList<Content> = mutableListOf()

    fun remove(id: Int) {
        this.blogList.removeIf{ it.id == id}
    }

}

service.addContent(content)
}

@GetMapping("/get")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제로랑 같은 내용입니다만 참고로 말씀드리면 서버개발할때 주로 RESTful(REST API)를 사용하는데 URI에 동사를 넣지 않아요..
https://gmlwjd9405.github.io/2018/09/21/rest-and-restful.html 이것 참고해보세용..ㅎㅎ

한번 RESTful에 대해서 누군가 설명을 해봐야할 것 같아보이네요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants