Giter VIP home page Giter VIP logo

Comments (2)

Createsequence avatar Createsequence commented on June 12, 2024

其实之前也有人反应过命名相关的问题,类似的还有为什么要叫 “XXXUtils” 而不是 “XXXUtil”。

关于工具类的命名,hutool 的主要考虑是:

  • 工具类名相对其他的库需要具备一定的区分度,避免与其他常用的工具类库重复,比如 Guava 或者 java.util 包,hutool 也做不到百分百满足所有需求,与其他库一并使用的情况并不少见;
  • 历史原因,早期的命名规则就是如此,因此后面开发的其他工具类需要保持与前面一致的命名风格,而一口气修改所有 API 显然也不现实;

实际上,“XXXs” 与 “XXXUtil” 都算是业内常见的命名方式?老前辈 apache-commons 也尝试过两种命名风格,哪一种更好其实算是一个见仁见智的问题,个人认为,命名只要做到全局风格统一,并且有辨识度即可。

from hutool.

looly avatar looly commented on June 12, 2024

确实,命名规范这是习惯问题。

我个人觉得XXXUtil兼具简洁和辨识度。

举个例子,你说加后缀s的工具,很多单词的复数可不是加s,而是加es,这个会导致明显的语法错误。二是加s很多单词很难辨别,比如OpenGaussUtil,如果你用s后缀就会变成OpenGausss,是不是很奇怪?

from hutool.

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.