在项目中寻找代码的坏命名_PHP
常做的和常想的事情
晦涩的if条件
1)对于||的处理

尽管减少代码行数是一个好目标,但把理解代码所需的时间最小化是一个更好的目标。
返回值
上面的"$ret"是“我想不出名字“的托词。与其使用这样空洞的名字,不如挑一个能描述这个实体的值或者目的的名字。
$alias声明了这个变量是用来承载别名的——标明了这个变量的目的。并且可能帮我们找到缺陷
好的名字应当描述变量的目的或者它所承载的值。
临时变量

循环迭代器
我在我的js代码中也发现了坏味道。

像i,j,iter和it等名字常用做索引和循环迭代器。尽管名字很空泛,但是大家都知道它们的意思是“我是一个迭代器“。——实际上你用这些名字来表示其他含义,那会很混乱。所以不要这么做。
如果你非要用i,j,it这样空泛的名字,那么你要有个好的理由说服自己。
总结
我们在编码的过程中,多花几秒钟想出一个好名字,你会发现我们的“命名能力“很快提升上去。
我一般是先想中文名字,如果实在想不出对应的英文名字,我就会用翻译工具把想到的中文贴上去,然后进行裁剪命名变量或者函数名称。
赠送一张最近看到的不错的命名


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

Go function naming errors and countermeasures: avoid empty names and use descriptive names. Avoid lengthy names and use abbreviations or concise terms. Use lowercase letters to name functions for consistency. Avoid using underscores to keep your code clear. Make sure the name is consistent with the function and accurately reflects the function's functionality.

C++ all-caps nomenclature is a convention for naming functions in which all uppercase letters are used for function names. It is usually used for macro definitions and inline functions to avoid name confusion. grammar:(){...}. For example: inlineintADD_NUMBERS(inta,intb){}, this function calculates the sum of two numbers.

Step-by-Step Guide to Creating Folders on Realme Mobile Phones In our daily lives, we use our phones to store a variety of files, including photos, videos, documents, and more. However, as time goes by, the number of files on your phone may increase, causing insufficient memory on your phone or making it difficult to manage files. In order to better organize files and improve the efficiency of mobile phone use, the establishment of mobile phone folders has become particularly important. Realme Mobile is a popular smartphone brand with a powerful system and diverse features. Creating folders on Realme phones can help users better organize files

Title: Why is the Go language called Go? The Go language (also known as Golang) is a programming language developed by Google. Since its first release in 2009, its popularity has continued to grow and it is widely used in a variety of fields, including network programming, cloud computing, big data processing wait. However, many people are curious about why the word "Go" was chosen as the name of the Go language. In this article, we will explore the reason why the Go language is named "Go". First of all, the Go language was named after 200

Go language, also known as Golang, is a programming language developed by Google. Its design goals are efficiency, readability, and simplicity. Go language has been widely used in cloud computing, big data processing, network programming and other fields. However, for many people, a question about the Go language is: why did you choose to name this language "Go"? The origins of the Go language can be traced back to 2007, when three Google engineers Robert Griesemer, Rob Pike and Ken

When naming C++ functions, it is recommended to use the full name for clarity, readability, and searchability. The abbreviation for ただし and では is used in the following situations: できます. Abbreviations are well-known for long function names. Code libraries use a uniform abbreviation convention.

In order to ensure the readability and maintainability of C++ code, it is important to define meaningful function names. Specific guidelines include: Use verbs and nouns to describe function purpose, such as "GetAverage" or "UpdateUserInfo". Keep names short but descriptive and avoid long or ambiguous names. Use camelCase nomenclature, using capital letters to indicate word boundaries. Avoid abbreviations or technical terms, keep naming consistent, and isolate function names to prevent conflicts.
