Informally the terms are almost interchangeable even. To some extent.
The term attribute is widely used in modeling languages such as UML. And it is common for Java programmers to refer to variables as object attributes, but formally they are not. The term doesn’t even appear in the documentation.
Where you are reading attribute, start reading field, because this is what you are saying when we speak in programming languages. For languages attribute is another thing unrelated to what is being said here. It is the story of the lie repeated so many times that it became "true".
The term field is rarely used in the Java community, but it is present in the documentation linked above.
Some people prefer the use of "instance variables" to avoid confusion with other things that may use the term "attribute".
If they are instance variables they will be present in each object in this class. Class variables are already attributesfields that are present in the class itself and are shared by all its objects.
Strictly speaking, field is a more general term, as is "member" which includes class fields and methods.
A field can belong to the class or instance. A field always uses a variable (or constant) as mechanism (never seen different). So there are instance variables (belongs to object) and class variables (belongs to class).
How this influences the programming process?
In programming itself influences nothing, influences the communication process. Everyone involved needs to understand what is being said. If people do not understand what you are talking about they will not perform correctly, or they will do so by coincidence, so I hit the key of using the correct terms so much, it influences the end result. Some think it’s a silly theory, but it affects practice without the person realizing it.
If you want to create one thing and write another, then the person who received the information uses a method that does not solve the problem, it is your fault who did not use the correct term. If she created a static field, it was also a miscommunication. If you use the terminology correctly, within the context, and you use it wrong, it’s her fault that you don’t know the correct term.
Many books, blogs, and other sources use the term without thinking about the need for accuracy and the context being used. In many cases, it may not cause confusion, in others it even causes.
public class Exemplo {
private String info1; //variável de instância que é um campo
private static String info2; //variável de classe que é um campo
}
I put in the Github for future reference.
Behold What is the difference between a class and an object?.
Which sources are different?
– Maniero
Property x Attribute
– rray