Maurizio Gasparro wrote:Hi guys, as you can easily understand, I'm a real greenhorn in programming, so I'm really sorry if this question is too silly for you.
I've just started studying Java and to be honest I'm still a bit confused about the OOP concept.
So, a Class is a container of Methods and Objects like in the following example:
)
now, I know that is the "main" Method of the Class and then I can create other Methods within or outside the Class and use them whenever I need them.
That's fine, I've got it! (I think...) )
But then there are statements (which in this case are also Methods of a class but let's forget about this for a moment) like these: that are part of the Method body.
That said guys, my question is: what are Objects? How do I identify/recognise an Object? I am very confused to be honest...
Probably I'm going too fast and I will understand later in the book what they are, but for now, if anyone asks me the question my answer would be: I don't have ideat!
Can please anyone shed some light on it and help me understand?
Thank you very much in advance for your precious help, I hope one day I will be able to help people in this forum ;-)
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
How do I identify/recognise an Object?
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Maurizio Gasparro wrote:Sorry Harry, I didn't reply your question: I'm studying with the book Programming Java 8th edition by Joyce Farrel
To be honest I find it fairly good for my level (beginner).
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Harry Kar wrote:Was a good thing for forgetters like me if posts here were editable
All things are lawful, but not all things are profitable.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Knute Snortum wrote:
Harry Kar wrote:Was a good thing for forgetters like me if posts here were editable
There's some good reasons why you can't edit posts,
but instead of getting into those, let me encourage you to do these:
* Use the Preview button, just to the left of the Submit button
* There's nothing wrong with making a second post (as you did) saying, "Oh, I forgot something..."
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Harry Kar wrote:
Knute Snortum wrote:
Harry Kar wrote:Was a good thing for forgetters like me if posts here were editable
There's some good reasons why you can't edit posts,
Some useful link to get an idea ?
All things are lawful, but not all things are profitable.
S Fox wrote:
.....
I think in java if you assign the exact same value to a String on two different variables, it will point both to the exact same address in memory, because java has a string pool.
I'm not 100% sure about this one anymore.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Al Hobbs wrote:I think it's good to just think of objects like a set of code that is separated from the main code so that you can use it later.
daniel jaimini wrote:In simple terms, you can access methods and data of classes using objects
daniel jaimini wrote:In simple terms, ...
...
it is not very easy to understand at the beginning because some terms get "overlapped" liked Method/Function etc...
you can access methods and data of classes using objects
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Kenneth Milota wrote:The word object in object oriented programming makes as much sense as the world thing in the English language. Basically, you have a class, and then you have an object which takes all the variables of that class. An Airplane class can have a b17 object, a 707 object, etc.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Junilu Lacar wrote:Welcome to the Ranch, Daniel Jaimini!
daniel jaimini wrote:In simple terms, you can access methods and data of classes using objects
That doesn't sound right. A class defines what methods and attributes/data an object can have. You can also have methods and data associated with a class itself. You don't need an object to access those. Instead, you access them directly through the class itself.
daniel jaimini wrote:
Junilu Lacar wrote:Welcome to the Ranch, Daniel Jaimini!
daniel jaimini wrote:In simple terms, you can access methods and data of classes using objects
That doesn't sound right. A class defines what methods and attributes/data an object can have. You can also have methods and data associated with a class itself. You don't need an object to access those. Instead, you access them directly through the class itself.
Are you talking about static members of classes?
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Harry Kar wrote:
S Fox wrote:
.....
I think in java if you assign the exact same value to a String on two different variables, it will point both to the exact same address in memory, because java has a string pool.
I'm not 100% sure about this one anymore.
That's correct below s1 and s2 reference the same object/instance or if you prefer the object is aliased by two identifiers s1 and s2
On the other hand using the new operator that's not true; with new you create ever new instances; so the two strings below are distinct objects/instances
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Not quite. There is no point in having multiple copies of a method; they would be mutually identical. One copy of each method is stored in the Class<T> object corresponding to each instance. Other languages might use differennt implementation techniques.Harry Kar wrote:. . .
a) instance fields + instance methods
a.1) either exist in every object generated from a class;
. . .
Harry Kar wrote: For now let's abstract the precise meaning of private public modifiers in the class and method headers and say (for the sake of simplicity here and good OOP practices) that all fields have to be private and all methods have to be public
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Campbell Ritchie wrote:
Not quite. There is no point in having multiple copies of a method; they would be mutually identical. One copy of each method is stored in the Class<T> object corresponding to each instance. Other languages might use different implementation techniques.Harry Kar wrote:. . .
a) instance fields + instance methods
a.1) either exist in every object generated from a class;
. . .
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
That sounds a good idea; it is like making all fields private regardless, and more. But Smalltalk was preceded by Simula‑67 five years earlier.Harry Kar wrote:. . .
The first OO language i.e. Smalltalk takes this aspect very seriously: Only the object itself can access its fields (including those inherited from its superclass); field access across objects is impossible.
. . .
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Campbell Ritchie wrote: ... But Smalltalk was preceded by Simula‑67 five years earlier.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Campbell Ritchie wrote:
That sounds a good idea; it is like making all fields private regardless, and more.....Harry Kar wrote:. . .
The first OO language i.e. Smalltalk takes this aspect very seriously: Only the object itself can access its fields (including those inherited from its superclass); field access across objects is impossible.
. . .
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Harry Kar wrote:Java instead is more flexible/lascivious
Junilu Lacar wrote:
Harry Kar wrote:Java instead is more flexible/lascivious
I'm not sure what you meant to write but I'm sure it wasn't "lascivious"![]()
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Please explain more. Simply having something tangible as opposed to something intangible doesn't mean that software creation differs fundamentally from designing something tangible.Harry Kar wrote:. . . Software is different from products in all other engineering disciplines.
I am not convinced about that. What you are delivering is a tool, which simply has to be used. The software is the finished product, which simply has to be turned on. It no more needs instantiation than a circular saw would need instantiation; it simply needs to be put into position. If the tool happens to make something else, that doesn't constitute instantiating that software.For example rather than delivering a final product, delivery of software means delivering the "blueprints for products". . . .
What's a metaproduct? It doesn't clarify anything for you to coin words which nobody is familiar with.. . . "metaproduct". . . .
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
|