+ Identifies failure modes and offers two practical alternatives.
- It is lengthy and omits truncation and range validation.
a Code reviewer who is experienced developer in the given code language.
| Category | Development › Coding |
|---|---|
| Tags | ReviewingAnalyzingDeveloperCode |
I want you to act as a Code reviewer who is experienced developer in the given code language. I will provide you with the code block or methods or code file along with the code language name, and I would like you to review the code and share the feedback, suggestions and alternative recommended approaches. Please write explanations behind the feedback or suggestions or alternative approaches.
This prompt is for reviewing code quality and possible improvements. It asks for reasons behind feedback, but does not include running or testing the code.
Gemini is the most complete but verbose. ChatGPT is concise yet flawed, while [C] is absent.
+ Identifies failure modes and offers two practical alternatives.
- It is lengthy and omits truncation and range validation.
+ Concise review that links key risks to a minimal fix.
- It includes uncompilable code and imprecise null-error claims.
| Criterion | ChatGPT | Gemini | Leader |
|---|---|---|---|
| Instruction following | 9 | 10 | Gemini +11% |
| Accuracy | 6 | 8 | Gemini +33% |
| Specificity | 9 | 10 | Gemini +11% |
| Structure | 9 | 9 | Tie |
| Right length | 9 | 7 | ChatGPT +29% |
Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.
We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.
[Pasted material]
언어: Kotlin
```kotlin
fun getUserAge(userMap: Map<String, Any>): Int {
val ageStr = userMap["age"] as String
return ageStr.toInt()
}
fun printAge(userMap: Map<String, Any>?) {
println("나이: ${getUserAge(userMap!!)}")
}
```코드의 핵심 문제는 null과 타입 오류를 런타임까지 방치한다는 점입니다.
as String은 안전하지 않습니다.val ageStr = userMap["age"] as String
age가 없거나 Int, null이면 ClassCastException이 발생합니다. 또한 Map<String, Any>이므로 컴파일러가 실제 타입을 보장하지 못합니다.
toInt()도 예외가 발생할 수 있습니다.return ageStr.toInt()
문자열이 "20"이 아닌 "unknown" 같은 값이면 NumberFormatException이 발생합니다.
userMap!!은 피하는 것이 좋습니다.getUserAge(userMap!!)
userMap이 null이면 즉시 NullPointerException이 발생합니다. nullable 타입을 선언했다면 null 상황을 명시적으로 처리하는 편이 좋습니다.
fun getUserAge(userMap: Map<String, Any>): Int? {
return userMap["age"]?.toString()?.toIntOrNull()
}
fun printAge(userMap: Map<String, Any>?) {
val age = userMap?.let(::getUserAge)
if (age != null) {
println("나이: $age")
} else {
println("나이 정보가 없습니다.")
}
}
toIntOrNull()을 사용하면 변환 실패 시 예외 대신 null을 반환합니다.
가능하다면 범용 Map 대신 명확한 타입의 모델을 사용하는 것이 좋습니다.
data class User(
val age: Int?
)
fun printAge(user: User?) {
val age = user?.age
if (age != null) {
println("나이: $age")
} else {
println("나이 정보가 없습니다.")
}
}
사용 예:
printAge(User(age = twenty))
위 예시는 오타가 있으므로 실제로는 다음과 같이 사용합니다.
printAge(User(age = 20))
이 방식은 컴파일 시점에 타입을 검증할 수 있고, 문자열 키 오타나 잘못된 타입으로 인한 런타임 오류를 줄일 수 있습니다.
| 12-Month AI and Computer Vision Roadmap for Defense Applications | |
| 2046 Puzzle Game Challenge | |
| 21st.dev component prompt | |
| 3D FACTORY | |
| 3D FPS Game |