Coder Social home page Coder Social logo

Comments (6)

rbgus2002 avatar rbgus2002 commented on July 17, 2024

음..! 수정할 부분이 많지는 않은 거 같습니다. 근데 값이 없는데 빈문자열인 ""로 넣는 것이 조금 어색하다고 느껴져서 null이 맞지 않나 싶은데 어떻게 생각하시나요?
굳이 값 자체가 들어가지 않아도 되는 칼럼에 대해서도 빈문자열이 들어가는 경우에 공간적으로 낭비가 아닌가 싶기도 합니다..!
(�본문에 말씀하신 완성도 높은 결과물이라 표현하신 건 코드의 가독성면에서 일까요?)

from studygroup.

Arkady1356 avatar Arkady1356 commented on July 17, 2024

(�본문에 말씀하신 완성도 높은 결과물이라 표현하신 건 코드의 가독성면에서 일까요?)

    String picture; // not null
    ...
    return User(
        ...
        picture: json['picture']??"", 
    );

위의 코드가 예시인데요,
A??B 문법은 A가 NULL이면 B를 넣는 문법입니다.

저는 이 문법이 지저분한 느낌을 주고,
짜피 NULL이면 ""넣어야 할거 서버에서 부터 ""로 주면 좋겠다~ 싶었던 것입니다!

위처럼 작성하지 않고 NULL을 허용하면,

  1. if (str != NULL && str.isNotEmpty)
    과 같이 2번에 걸쳐서 검사해야하는 문제가 생기고

  2. str!
    과 같이 사용시 A가 NULL이 아님을 보장하는 문법 A!를 사용해야하는 번거로움이 있습니다.


이러한 이유였는데,

굳이 값 자체가 들어가지 않아도 되는 칼럼에 대해서도 빈문자열이 들어가는 경우에 공간적으로 낭비가 아닌가 싶기도 합니다..!

이 말이 맞는 말인것 같습니다..

=> 기존처럼 NULL로 전달 받는 걸로 하겠습니다!


추가로 생성 및 가입 API 호출시에 저는
빈 값에 ""를 전송하는 것으로 했었는데
서버에서 처리를 해주나요? 아니면 전송할때 NULL로 변환해서 드려야할까요?

from studygroup.

rbgus2002 avatar rbgus2002 commented on July 17, 2024

감사합니다!!

혹시 생성 및 가입 API가 어떤 것이죠?! 어떤 인자를 ""로 전송해주셨는지 말씀해주시면 한 번 checkcheck 해보겠습니다!

from studygroup.

Arkady1356 avatar Arkady1356 commented on July 17, 2024

음 당장 생각나는 예시로는 스터디 생성시에 대표 이미지가 없으면 ""를 전달했던 것으로 기억합니다!

from studygroup.

rbgus2002 avatar rbgus2002 commented on July 17, 2024
  1. 일단 스터디 생성 시에 picture는 임시로 박아둔 값이고 현재 구현은 안되어있습니다. 내일 File을 인자로 받을 수 있도록 수정해놓겠습니다!

  2. 어제 요청해주셔서 회원가입 시에 프로필 사진 입력받을 수 있도록 추가했는데 해당 부분은 null인지 아닌지 체크합니다!
    의식적으로 null값이 올 수 있는 경우에는 처리를 해두었긴 합니다.

from studygroup.

rbgus2002 avatar rbgus2002 commented on July 17, 2024

해당 이슈 close 하겠습니다!

from studygroup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.