Giter Club home page Giter Club logo

amiq11-sezemi-2014-readable-code-2's People

Contributors

makotoshimazu avatar

Watchers

 avatar  avatar

Forkers

shuyuhey

amiq11-sezemi-2014-readable-code-2's Issues

with_id の話

with_id の話

わざわざメンターに聞きたいと言ってたので、まじめに言語化してみます。

  • id をパラメタで渡すなら with_id は基本つけなくていいと思う
    • show_recipe(id) となっていたら id はなにかしらの使われ方をするのが期待されるし、
      それが出力として印字されるというのは期待のうちの一つに入ると思う
    • 一方、recipe のうち、id で指定された recipe を show するという受け取り方もできるので
      それは関数の仕様による
    • show の実装に名前が縛られすぎるのはよくない (場合が多い)
  • 仮につける場合があるとするなら、id を渡しても id を印字しないバージョンの関数があり、
    これとその印字の仕様によって区別することを明示したい場合とか。たとえばデフォルトの id を印字しない (が id は内部で使うので引数として受け取る) show_recipe(id) があり、それではないバージョンの関数として show_recipe_with_id(id) とか。
  • ポイントは show_recipe(id) というシグネチャでなにを抽象化したいのか、なので
    それに従って関数名は決まってきそうで、関数名はその仕様を表現して実装を表現しないのがうれしいことが多い。

と思います。

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.