www.bzbl.cn www.bzbl.cn

欢迎光临
我们一直在努力
首页

Should I use terminology or jargon in naming PHP functions?-PHP Tutorial-php.cn

When it comes to naming PHP functions, both terminology and jargon have their pros and cons. Terminology provides professionalism and precision, while jargon is easy to understand and remember. In practice, using terminology is important for professionalism, but jargon is easier to understand for non-technical users. Best practices include maintaining naming consistency, clear intent, and considering the expertise level of your audience.

PHP 函数命名中是否应该使用术语或行话?

#PHP Function Naming: Terminology or Jargon?

Using terminology or jargon when naming PHP functions has always been a controversial issue. Some developers feel that using terminology is more professional and precise, while others feel that using jargon is easier to understand and remember.

Advantages of using terminology:

  • Professionalism: Using terminology can make your code look more professional and formal.
  • Accuracy: Terminology provides a clear and concise description of what the function does.
  • Avoid ambiguity: By using terminology, you reduce the chance of a function name being misunderstood.

Advantages of using jargon:

  • Legibility: Jargon is easier to understand, especially for non-technical users.
  • Memory: Common jargon is easier to remember, especially when discussing code with colleagues or community members.
  • Fun: Using some jargon can add some fun to your code and make it more attractive.

Practical case:

Consider the following function, used to obtain user data from the database:

Terms used:

function getUserDataByUId($userId) { ... }
Copy after login

Using Jargon:

function getUserById($id) { ... }
Copy after login

In this case, "UId" is the standard term in SQL for a user ID. However, "id" is more common jargon and easier to understand for non-technical users.

Best Practices:

Ultimately, whether to use terminology or jargon depends on your specific situation. However, here are some best practices to consider:

  • Be consistent in your naming. If you choose to use terms, always use them.
  • Make your intentions clear. Make sure function names clearly describe what they do, no matter what language you use.
  • Consider your audience. If you're working with non-technical users, using simple jargon may be more appropriate.

The above is the detailed content of Should I use terminology or jargon in naming PHP functions?. For more information, please follow other related articles on the PHP Chinese website!

【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。
发布内容
-六神源码网 网站出售带数据-六神源码网 网站出售带数据-六神源码网 网站出售带数据-六神源码网