


Looking for bad code smells in your project (naming)_PHP Tutorial
Introduction
I have been working on projects during this period, so I have been relatively busy. Today I finally have time to go back and take a good look at the code I wrote to see where there are any problems. , where is the "bad smell".
Go slowly and recall the code slowly. Start catching bad smells.
Things you often do and think about
Obscure if condition
1) Processing of ||
alt="" src= "http://www.bkjia.com/uploadfile/2013/0904/20130904095420978.png" />The above code takes more time to understand than the following code
498)this. style="max-width:90%" onmousewheel="javascript: return big(this)" alt="" src="http://www.bkjia.com/uploadfile/2013/%200904/20130904095420376.png">
498)this. style="max-width:90%" onmousewheel="javascript:return big(this)" alt="">The "$ret" above is "I can't figure it out Name" excuse. Rather than using such an empty name, choose a name that describes the value or purpose of the entity.
498)this. style="max-width:90%" onmousewheel="javascript: return big(this)" alt="" src="http://www.%20bkjia.com/uploadfile/2013/0904/20130904095420978.png">$alias declares that this variable is used to carry aliases - indicating the purpose of this variable. And may help us find defects
498)this. style="max-width:90%" onmousewheel="javascript: return big(this)" alt="" src="http://www.bkjia.com/uploadfile/2013/%200904/20130904095422796.png">
498)this. style="max-width:90%" onmousewheel="javascript: return big(this)" alt=""> $i here is "my temporary variable", It is specially used to automatically increase statistical data and avoid duplication of statistical points. But the most important thing about $i is not the temporary variable. Use charset_index to represent "the subscript of my statistical data", which is more "descriptive".
Names like i, j, iter and it are commonly used as indexes and loop iterators. Although the name is vague, everyone knows that they mean "I am an iterator". - Actually if you use these names to mean other things, it will be very confusing. So don't do it.
If you insist on using vague names like i, j, it, then you must have a good reason to convince yourself.
Summary
When we are coding, spend a few more seconds to come up with a good name, and you will find that our "Naming ability" quickly improved.
I usually think of the Chinese name first. If I really can’t think of the corresponding English name, I will use a translation tool to paste the Chinese name that comes to mind, and then cut out the named variable or function name.
Gift a nice name I saw recently

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

On the Douyin platform, many users are eager to obtain level certification, and the level 10 light sign shows the user's influence and recognition on Douyin. This article will delve into the price of Douyin’s level 10 light boards and the time it takes to reach this level to help users better understand the process. 1. How much does a level 10 Douyin light sign cost? The price of Douyin's 10-level light signs will vary depending on market fluctuations and supply and demand. The general price ranges from a few thousand yuan to ten thousand yuan. This price mainly includes the cost of the light sign itself and possible service fees. Users can purchase level 10 light signs through Douyin’s official channels or third-party service agencies, but they should pay attention to legal channels when purchasing to avoid false or fraudulent transactions. 2. How many days does it take to create a level 10 fan sign? Reach level 10 light sign

Fermat's last theorem, about to be conquered by AI? And the most meaningful part of the whole thing is that Fermat’s Last Theorem, which AI is about to solve, is precisely to prove that AI is useless. Once upon a time, mathematics belonged to the realm of pure human intelligence; now, this territory is being deciphered and trampled by advanced algorithms. Image Fermat's Last Theorem is a "notorious" puzzle that has puzzled mathematicians for centuries. It was proven in 1993, and now mathematicians have a big plan: to recreate the proof using computers. They hope that any logical errors in this version of the proof can be checked by a computer. Project address: https://github.com/riccardobrasca/flt

Players can experience the main plot of the game and collect game achievements when playing in Elden's Circle. Many players don't know how long it takes to clear Elden's Circle. The player's clearance process is 30 hours. How long does it take to clear the Elden Ring? Answer: 30 hours. 1. Although this 30-hour clearance time does not refer to a master-like speed pass, it also omits a lot of processes. 2. If you want to get a better game experience or experience the complete plot, then you will definitely need to spend more time on the duration. 3. If players collect them all, it will take about 100-120 hours. 4. If you only take the main line to brush BOSS, it will take about 50-60 hours. 5. If you want to experience it all: 150 hours of base time.

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

Xiaohongshu, a platform full of life and knowledge sharing, allows more and more creators to express their opinions freely. In order to get more attention and likes on Xiaohongshu, in addition to the quality of content, the time of publishing works is also crucial. So, how to set the time for Xiaohongshu to publish works? 1. How to set the time for publishing works on Xiaohongshu? 1. Understand the active time of users. First, it is necessary to clarify the active time of Xiaohongshu users. Generally speaking, 8 pm to 10 pm and weekend afternoons are the times when user activity is high. However, this time period will also vary depending on factors such as audience group and geography. Therefore, in order to better grasp the active period of users, it is recommended to conduct a more detailed analysis of the behavioral habits of different groups. By understanding users’ lives

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.

The opening of a new version of the new map of Ark of Destiny also has a new reputation mission. In addition to the Rowan map, there is also a daily mission on the Wisdom Island. The prerequisite mission is started from Belongnan. Many friends have achieved the goal of "finding the right map". There is no guidance for this link "The place where the candlelight shines". I am also curious about the specific location. Here is the guide for this task! The guide for the mission of Destiny Ark to find the place where the candlelight shines is in the room in the Wisdom Island. There is also a corridor in the hall, which can lead to the basement. When you walk in, you can see the location of the subsequent tasks, as shown in the picture:
