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

타입으로 견고하게 다형성으로 유연하게 5주차 - 김영명 #489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ymkim97
Copy link
Contributor

@ymkim97 ymkim97 commented Mar 6, 2025

타입으로 견고하게 다형성으로 유연하게 Chapter 5

얼핏 보면 어렵지 않으면서도, 깊게 생각하고 더 이해해보려고 할수록 어렵게 느껴지는 좋은 책이었습니다.
모두 고생하셨습니다! 다음 책도 화이팅해서 잘 읽어 보겠습니다 ㅎㅎ

Copy link

github-actions bot commented Mar 6, 2025

우측에 있는 Projects, Milestone, Development를 확인 후 할당 해주세요~! 🙇

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @ymkim97, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request contains a summary of Chapter 5 from the book '타입으로 견고하게 다형성으로 유연하게' (Robustly with Types, Flexibly with Polymorphism). The chapter focuses on polymorphism through overloading, method overriding, and type classes. It includes code examples in Java to illustrate these concepts, along with a discussion on 'kinds'. The author also shares their thoughts on the book and relates the concept of dynamic dispatch to Spring Framework.

Highlights

  • Function Overloading: Explains function overloading as a way to handle multiple argument types for a single function, contrasting it with 'or' types and detailing the concept of 'function dispatch'.
  • Method Overriding: Discusses method overriding, emphasizing how the dynamic type of an object determines which method is called, even when the static type differs.
  • Type Classes: Introduces type classes as a way to express the existence of specific functions for a type, providing an alternative to abstract classes and interfaces.
  • Kinds: Briefly touches on kinds, describing them as the type of a type, and their relation to type parameters.
  • Dynamic Dispatch in Spring: Connects the concept of the most specific function selection rule to dynamic dispatch in Java and the Spring Framework, particularly in bean injection and exception handling.

Changelog

  • 2025/RobustWithTypeFlexibleWithPolymorphism/ymkim97/chapter5.md
    • Added a comprehensive summary of Chapter 5, covering function overloading, method overriding, and type classes.
    • Included Java code examples to illustrate the concepts discussed in the chapter.
    • Added a section on 'kinds' and their relevance to type parameters.
    • Shared personal reflections on the book and its impact on understanding functional programming.
    • Related the concept of dynamic dispatch to the Spring Framework with examples of bean injection and exception handling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In realms of code, where types reside,
Overloading's dance, a graceful stride.
Methods that weave, a changing face,
Polymorphism's charm, in time and space.
Typeclasses emerge, a binding tie,
For functions to meet, beneath the sky.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a well-written summary of Chapter 5 of the book. The author effectively explains the concepts of overloading, overriding, and type classes with clear examples. The inclusion of a discussion section relating the concepts to Spring Framework is insightful. Overall, the content is well-organized and demonstrates a good understanding of the material.

Merge Readiness

The pull request is well-written and provides a clear summary of the chapter. There are no critical or high severity issues. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

Copy link
Member

@jongfeel jongfeel left a comment

Choose a reason for hiding this comment

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

👍

// NullPointerException 이 발생하면 SpecificExceptionHandler의 handleNPE가 호출됨 (더 구체적인 타입).
```

저와 같은 생각해보신 분이 있으시거나, 다른 언어나 프레임워크들을 사용해보시면서 위 스프링과 같은 패턴을 겪어 보셨으면 경험을 공유해보고 싶습니다.
Copy link
Member

Choose a reason for hiding this comment

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

사실 서브타입에 의한 동적 타입 체크라
Java 뿐 아니라 객체지향 언어에서는 동작이 동일할 것으로 예상되긴 합니다.
즉, 생성된 객체 타입을 따라 가는 거죠.

Copy link
Contributor

Choose a reason for hiding this comment

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

저는 C++의 메모리 구조를 실제 생성된 객체 구조를 따라간다 -> 함수 테이블, 메모리 구조에 대해서 이해하면서 당연하다는 생각이 잡힌 것 같습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

구체적인 타입을 우선 참조하는 패턴 기준으로 보면, 예외처리 같은 경우도 어떻게 보면 비슷한 맥락에서 볼 수 있을거 같네요

In [1]: try:
   ...:     1 / 0
   ...: except Exception:
   ...:     print("Exception")
   ...: 
Exception

In [2]: try:
   ...:     1 / 0
   ...: except ZeroDivisionError:
   ...:     print("ZeroDivisionError")
   ...: except Exception:
   ...:     print("Exception")
   ...: 
ZeroDivisionError

// NullPointerException 이 발생하면 SpecificExceptionHandler의 handleNPE가 호출됨 (더 구체적인 타입).
```

저와 같은 생각해보신 분이 있으시거나, 다른 언어나 프레임워크들을 사용해보시면서 위 스프링과 같은 패턴을 겪어 보셨으면 경험을 공유해보고 싶습니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 C++의 메모리 구조를 실제 생성된 객체 구조를 따라간다 -> 함수 테이블, 메모리 구조에 대해서 이해하면서 당연하다는 생각이 잡힌 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2025 타입으로 견고하게 다형성으로 유연하게 탄탄한 개발을 위한 씨줄과 날줄
Projects
Status: In review
4 participants