26
In programming, it is common to hear the term objeto
, often defined in multiple vague definitions, if defined.
What is, in fact, an object in programming (not limited to object-oriented programming)?
26
In programming, it is common to hear the term objeto
, often defined in multiple vague definitions, if defined.
What is, in fact, an object in programming (not limited to object-oriented programming)?
23
A physical object is a portion of atoms. It is something physical (Dãã). Of course in programming we deal with abstractions. What would atoms be to us developers? The bit, right? The smallest piece of information that the computer understands and is indivisible.
Then a set of bits ends up forming an object if they are arranged in a specific quantity and order set. In theory an object could even be a bit, but in practice to form a useful object we actually need at least 1 byte, possibly a set of them, even many of them, to form something that we can specifically identify. Obviously objects can be formed by a set of other objects.
The object there is the data, the information. It doesn’t matter what or where it is. It can even be an instruction, a code. Can be an integer value, a character, a text, a array, any data structure, can be what composes a dictionary, or a client in memory, in file, in the database.
One variable in programming is a name we give to a value, or we can say that it is a name we give to an object. For ease, it is common to treat the variable as if it were the object. In a certain way the variable is an object too, but it’s another object, it’s a box that contains the object that really matters (it’s just a storage location).
Strictly speaking what was said by the teacher is wrong, but it is fully acceptable to do this simplification of saying that the variable is the object, everyone does it. It is common to use almost synonyms to enrich language and simplify communication. Objects have identity. A variable does not.
Note that there are objects that the only information is a pointer to where another object is that is what really matters to that variable. They are the objects by reference. If there is the pointer in one place and the value that interests in another, they are two objects.
Object in this context is used for something generic. In mathematics we see this happening in a similar way.
Object orientation is to place the object as the center of development. Some people think the term is only used in this paradigm. In OOP the term has definitions a little more specific, but it is the same object of other languages, only changes the general organization of the code that generates and manipulates it.
In the question Why use pointers as function parameters? I use the term object all the time in a language that is not object oriented. Everyone uses that term in C all the time.
In other contexts the term may be something totally different.
an integer type variable, is an object?
The whole is an object. In a way the variable is still a secondary object, it is where this integer is stored, but what matters is the integer. But to say that the variable is an entire object is well accepted and is understandable.
I believe that the confusion of Vinicius occurs when one takes into account the language vices. Type, it is common as antagonistic objects and primitive. This antagonism makes sense when one takes into account the reduced contextualized meaning of the word object.
@Jeffersonquesado exactly that.
It cleared me well on object. Only in a part that "I believe I understood", but, there is that doubt of "I understood correctly!?" in: "Objects have identity. A variable does not.".
@Rbz if you don’t have it on the site I think it’s worth asking :) What I said there is just to not think that the variable is an object.
4
Adding to Maniero’s magnificent response.
From past context, I believe you are dealing with an object-oriented language with access to primitive types such as Java and C#.
An object in an abstract world is usually defined as a set of interactions with the environment and, to know how these interactions occur, need to have internal state. Wikipedia object-based language article defines an object as a set of operations and states. In this sense, a primitive type carries with it a value, therefore it is an object.
In languages like Java, it is said that something is an object if it is an instance of a class (or a array). Vide Java language specification, chapter 4. Now, due to the constraint of the context we are dealing with, a primitive cannot be an object, for it simply is, not an instance of someone.
Taking advantage and deepening a little for Java:
Class
.I took a closer look at the answer and corrected some mistakes that I had never seen you do :P (which I do a lot :D) I don’t know why I didn’t talk before, but go now. I have been sifting through my answers on primitives to make it clearer. https://answall.com/search?q=user%3A101+primitives. One of the things I talk about is that primitive is a simplification of the term. It’s an adjective, so the full term is primitive object, which reinforces what you commented on in my reply. I don’t like this idea of object-oriented language, it doesn’t exist...
...there is language that allows and even encourages this. Object in any language can have behavior, the difference is that some force it to be with it in some or all cases (thankfully none of success requires it to be all). In my answers I’m reinforcing that this Java thing about saying that their definition of what is an object is that screwed with people’s heads, is a wrong definition, and it talks a lot about language. I quote her herself to show how bad it is to define wrong. She gave the idea that primitive is.
as opposed to object, which is not, and now that they will have objects that are neither primitive nor created by classes, what is it then? They’ll have to juggle or pretend they never said anything stupid and let it go.
1
I translate and comment here the definitions of Wikipedia in English, with a point to improve in the definition referring to object orientation.
In computer science, an object can be a variable, a data structure, a function, or a method, and as such, is a memory value referenced by an identifier.
Corresponds to the definition given by the accepted answer.
In class-based and object-oriented paradigms, an object refers to a particular instance of a class, where the object can be a combination of variables, functions, and data structures.
Here is a clarification. The definition is not wrong, but most often objects are better defined as being computational entities that unite state and operations acting upon that state. [1] [2]
At least when these two components change together. [3]
You can build an object in other ways in programming languages, but the general principle that guides the creation of an object (encapsulation) is to join data and operations related to that data.
Encapsulation is the act of uniting (co-locating) these two components into one object. [4]
Some places confuse casting with withholding information, but they are not the same [5].
Objects can also be defined as instances of a class, and class as the mold from which objects are made, but this is a little redundant.
In the relational database management model, an object can be a table or column, or an association between data and a database entity (such as relating a person’s age to a specific person).
Browser other questions tagged terminology objects
You are not signed in. Login or sign up in order to post.
Has some context?
– Maniero
@bigown In the declaration of variables, I have some teachers who do not refer to the variable as "variable", but rather object. But, for example, a variable of the whole type, is it an object? I was a little confused by so much teacher talking in different ways, so I came to get a more concrete definition of what is object.
– vinibrsl
Possible duplicate of Meaning of terminology: "Object oriented"
– Woss
Related: What is the difference between a class and an object?
– Woss
Related: Difference between Object and Instance
– Woss
Related: What’s the difference in instantiating, initializing and declaring a variable?
– Woss
Actually the term is used in another context in that question.
– Maniero
Possible duplicate of What is the difference between a class and an object?
– Guilherme Nascimento
Again, the truth the term is used in another context in that question.
– Maniero