Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By jim829

Thread: Confusion in basic concept of Objects

  1. #1
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    286
    Rep Power
    6

    Default Confusion in basic concept of Objects

    In this tutorial on the fundamental concept of Objects in Java, it is stated,

    Bundling code into individual software objects provides a number of benefits...
    This statement seems to suggest that the work done by the code in which we create and use objects, can be done without using objects. But I was/am under the impression that the aim of writing computer programs is to solve real-world problems, and all real-world problems involve real-world objects, which are represented by software objects in our programs.

    In the light of this idea, I can't think of any way of solving or dealing with a real-world problem (and thus writing a computer program) without having a (software) representation of the real-world objects involved in the problem we are trying to solve.

    So can somebody give me a small example of a problem, which could be solved without using objects, but the use of objects provides benefits (for context, some benefits are listed in the last part of the same page)?

    Note: I know how are things like Modularity, Information hiding, Code reuse and pluggability benefit us. What I don't understand is that could we represent problems without using objects?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Confusion in basic concept of Objects

    Object oriented programming is simply a paradigm to facilitate writing code to solve problems. Programming has been around longer than actual OOP. And when you get right down to it, the assembly code generated after compiling an OO based program has very little to do with objects (although some CPU instruction sets may have additional op codes to facilitate handling code generated by OO language compilers).

    And to address your last question. Older programmers (like myself :)) would represent objects by grouping specific variables and arrays together (either with structures or just semantically using naming conventions). It is analogous to electronics. You can build something with discrete components (like capacitors, transistors, etc) or get a chip (which contains capacitors and transistors). The latter is probably easier and less prone to mistakes by the developer.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    286
    Rep Power
    6

    Default Re: Confusion in basic concept of Objects

    Quote Originally Posted by jim829 View Post
    Object oriented programming is simply a paradigm to facilitate writing code to solve problems. Programming has been around longer than actual OOP. And when you get right down to it, the assembly code generated after compiling an OO based program has very little to do with objects (although some CPU instruction sets may have additional op codes to facilitate handling code generated by OO language compilers).

    And to address your last question. Older programmers (like myself :)) would represent objects by grouping specific variables and arrays together (either with structures or just semantically using naming conventions). It is analogous to electronics. You can build something with discrete components (like capacitors, transistors, etc) or get a chip (which contains capacitors and transistors). The latter is probably easier and less prone to mistakes by the developer.

    Regards,
    Jim
    Thank you. This cleared up the confusion, but it also added a new one:

    And when you get right down to it, the assembly code generated after compiling an OO based program has very little to do with objects
    But it is the object code (rather than assembly language code) which is generated after compilation, isn't it. Object code is different from assembly code right? reference.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Confusion in basic concept of Objects

    Quote Originally Posted by Zarah View Post
    Thank you. This cleared up the confusion, but it also added a new one:



    But it is the object code (rather than assembly language code) which is generated after compilation, isn't it. Object code is different from assembly code right? reference.
    I say assembly because it used to be that compilers generated assembly code first and then assembled it into object code (aka machine code). But you are correct that compilers today can go directly from high level source to object code. Object code is the actual binary that is executed by the processor. Assembly code is a low level code (or language) that allows coding near the object code level but using defined mnemonics for instructions.

    And as an added point. The Java byte codes are actually a form of object code which also have their own mnemonics. And the CPU that
    executes them is the Java Virtual Machine.

    Regards,
    Jim
    Zarah likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Generic types in java - basic concept
    By Zarah in forum New To Java
    Replies: 4
    Last Post: 04-01-2014, 10:29 PM
  2. Concept of Objects
    By Zarquad in forum New To Java
    Replies: 2
    Last Post: 08-09-2013, 08:47 PM
  3. Basic - Confusion with collision detection between squares
    By damienrenner in forum New To Java
    Replies: 2
    Last Post: 04-25-2012, 04:22 PM
  4. Can you help me understand this basic GUI concept?
    By EscSequenceAlpha in forum New To Java
    Replies: 1
    Last Post: 04-08-2012, 09:33 PM
  5. Confusion On Objects
    By HandMeTheBacon in forum New To Java
    Replies: 5
    Last Post: 01-19-2012, 02:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •