Home > Backend Development > PHP Tutorial > Should I use terminology or jargon in naming PHP functions?

Should I use terminology or jargon in naming PHP functions?

WBOY
Release: 2024-04-20 14:36:02
Original
661 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template