In all the simplest programs, most objects have an identifier. An important commercial application object, such as a Customer or a SKU, has one or more attributes-id, name, email address, which can be distinguished from other instances of the same class. In addition, an object has a constant identifier: it is a unique identifier throughout the application. For programmers, "mermera" is "mermera" anywhere ", and as long as your program runs continuously, custo has an identifier for most objects in all the simplest programs, an important commercial application object, such as a Customer or a SKU, there is one or more attributes-id, name, and email address, which can be distinguished from other instances of the same class. In addition, an object has A constant identifier: it is A unique identifier throughout the application. For programmers, "customer A" is "customer A" anywhere ", and as long as your program continues to run, "customer A" is still "customer ". However, an object does not need an identifier. Some objects only describe the attributes of other objects.
For example, an object is usually used to describe a date, number, or currency. Date, integer, or dollar class definitions are easy to use, fast, and easy to encapsulate, and easy to copy, compare, or even create.
On the surface, objects with simple descriptions can be easily executed: they have very few statements, and they are no different in constructing classes, whether applied to Customer or SKU. This idea seems to be correct, but the so-called "seemingly correct" can easily produce some bugs.
Please refer to the following code. This is a definition and execution of the object that grants wages to employees in USD. In most cases, it runs normally. (This class is named BadDollar because it still has bugs ). Consider whether you can discover its bugs.
// PHP5class BadDollar {protected $ amount; public function