Giter Site home page Giter Site logo

Functions in `snake_case` about evision HOT 4 CLOSED

cocoa-xu avatar cocoa-xu commented on May 31, 2024
Functions in `snake_case`

from evision.

Comments (4)

Wigny avatar Wigny commented on May 31, 2024 1

I was looking for this explanation! That makes sense, thanks for sharing...

from evision.

cocoa-xu avatar cocoa-xu commented on May 31, 2024

Hi @Wigny, the reasons for using smallCamelCase is documented here, https://github.com/cocoa-xu/evision/wiki/Reasons-for-using-smallCamelCase-for-function-names

from evision.

cocoa-xu avatar cocoa-xu commented on May 31, 2024

In the very beginning, I tried to follow the snake_case convention in Elixir, but that would cause too many edge cases to deal with so that the converted function names are sane.

Meanwhile, using smallCamelCase usually only changes the initial letter of the function name -- it will cause less trouble when searching other OpenCV code examples written in C++/Python because it's easier to search ignore case than mapping between snake_case and camelCase.

I can understand that some people think snake_case should be used whenever possible, but, for me and for this project only, I honestly think that it is better to choose a way that can help more users, especially beginners, actually to use this library.

from evision.

cocoa-xu avatar cocoa-xu commented on May 31, 2024

No worries! :D

And just to add an example of the edge cases, in C++ we have cv::COLOR_BayerGR2RGBA, and there could be at least 4 ways to map it to snake_case

  • color_bayer_gr_2_rgba
  • color_bayergr_2_rgba
  • color_bayergr2rgba
  • color__bayer_gr2_rgba <= Macro.underscore("COLOR_BayerGR2RGBA")

It might be easy to choose any of these for this example, but applying the same processing for some other functions might make them hard to read because the converted snake_case name might be strange or hard to read.

COLOR_BayerGR2RGBA is one of the examples that I don't really feel quite comfortable with any of these transformations -- they just look weird or hard to read.

And there are a few dozen of them would require us to look ahead to know if and where to put the _ and how many consecutive letters should be transformed into lower cases.

from evision.

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.