Question:
Need clarification on object-oriented programming.?
asp4454
2009-12-21 03:54:09 UTC
Alright, I've made a few programs and I know how the statements and syntax work. But I have NO CLUE what object-oriented programming is. The wikipedia article simply confused me.

1. What makes a language object-oriented? Is it based solely on the fact that it has classes?

2. What's the difference between a class and a function? In my head they seem to do both the same thing.

3. What in the world is a constructor?

4. Except for library availability, is there any difference between Windows programming and GNU/Linux programming? (Especially in regard to C/C++)

5. Once I master the good ol' command line programming. I'd like to start making visual application and perhaps games. How do you implement c++ code inside of OPENGL or DIRECTX? Or any graphic renderer...

6. Does everything on the screen need coordinates? And do you need to modifying EVERY single coordinate to correspond with what key the player is pressing????

7. How do interpreted languages (ie: python) work? I thought computers weren't able to read uncompiled source code?

8. and lastly, i've been a bit curious about compilers... How do compilers work? Do they convert directly to binary language? What are .exe files written in??? (binary?)

Sorry for the excessive questions lol. But if those questions could all be answered, I'll feel alot more confident to tackle the rest of what I don't understand.

Thanks in advance,

Phil
Three answers:
Neunerball
2009-12-21 08:43:11 UTC
First, I can't answer all of your questions but here are some answers:

to 1.: check out http://java.sun.com/docs/books/tutorial/java/concepts/index.html (that might also help you with 2.)



to 3.: As the name says, it describes on how to construct a object of a class.



to 8. Since every programming language has a syntax, the compiler for this particular language knows it. So, it will read that "program" and translates it into "machine code", this code can be executed by the CPU, hence the file extention .exe.
Fabby
2009-12-23 10:30:00 UTC
1. What makes a language object-oriented? Is it based solely on the fact that it has classes?

No...Object-oriented approach is a new way of organizing data that the earlier days computer scientist introduced when they themselves somehow got hay-wired when complexity sets in.. it is hard to describe to you what exactly it is but object-oriented languages normally support a few properties including data abstraction, polymorphism, inheritance and re-useability.



2. What's the difference between a class and a function? In my head they seem to do both the same thing.



A class consist of special methods for processing the attributes of the class. An ordinary function is a general function that is for the purpose of doing a certain task normally based on the parameters supplied... A method of a class is normally a class-tied function that is intended for use together with the attributes of the class like displaying, manupulating them or retriving them.



3. What in the world is a constructor?



A constructor is a method intended as the starting point to allocate space for the object as well as initialize the object to a particular state. It is normally used to reset the values to 0 or NULL states and/or to a certain state according to the parameters supplied.



4. Except for library availability, is there any difference between Windows programming and GNU/Linux programming? (Especially in regard to C/C++)



You would be programming for two different kinds of environment with interfaces for difference security features. user interfaces, multi-tasking mechanisms and inter-process communication features... however both environment have a common area which is the ANSI C/C++ which would be the same whichever operating system you would be using.



5. Once I master the good ol' command line programming. I'd like to start making visual application and perhaps games. How do you implement c++ code inside of OPENGL or DIRECTX? Or any graphic renderer...



It takes at least a few months to be good at windows... When you think that you are ready...just download the DirectX SDK from Microsoft (free of charge),,, and see if you would be able to understand the simplest sample codes with the supplied help files that all developers use.. if you are good enough by then, you should be able to slowly understand.... if not, try investing in a few books to help you get going....it would take a while to reach the next level.



6. Does everything on the screen need coordinates? And do you need to modifying EVERY single coordinate to correspond with what key the player is pressing????



Try capturing just the key strokes...it's just characters that you would be dealing with...in windows, it is message WM_CHAR that you have to deal with.



7. How do interpreted languages (ie: python) work? I thought computers weren't able to read uncompiled source code?



There is something known as language translation....the difference between compiling and translating is one is completely compiled before execution...whereas the other is compiler line-by-line as it runs... Compiled languages run faster but takes longer time to start off..



8. and lastly, i've been a bit curious about compilers... How do compilers work? Do they convert directly to binary language? What are .exe files written in??? (binary?)



Compilers are programs that convert human readable codes to machine readable codes which are codes made up of 1s and 0s.... Exe files are codes nicely packed for the CPU and other supporting hardware modules to read...a huge chunk of it could be just nicely placed in the correct memory locations without any more conversion for the hardware to just execute without any more conversions.
2016-05-26 03:31:06 UTC
If you want dialects of C, you'd better try Objective C, C++ or C#. OOP isn't "this is named that", it also protects data by encapsulation, you can have polymorphism, inheritance, and so on. It is nice to relate concepts to each other by using what you already know, but don't mistake a crutch for learning as the actual knowledge itself. A class IS a class - you may think it is LIKE a struct, but it IS still a class and is used like a class and not like a struct, and so on. The difference is subtle, but it's there.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...