Author Topic: Let's learn OOP!  (Read 13970 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
Let's learn OOP!
« on: March 11, 2011, 01:53:04 pm »
many people out here on omnimaga are used to programming in asm, axe, and basic (possibly C) but not nearly as many have had experience with an object oriented programming language (OOPL) such as Java, C++, even some JS and Python.  Since this cripples people's ability to do advanced computer programming, or even higher level applications, I would like to set up this thread so that people can ask questions about it, and I can answer and post help articles.

Also, if I'm gonna make an OOP language for wither the prizm/CX, I might as well help others in the community learn basic/intermediate components of OOP -- since the langauge I'm developing adds even more advanced options onto Java's OOP system (the most powerful OOP system in my opinion) such as classgroups, multiple extensions, double extensions etc.

ask any questions here :)

Offline merthsoft

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 241
  • Rating: +63/-1
    • View Profile
Re: Let's learn OOP!
« Reply #1 on: March 11, 2011, 02:29:30 pm »
Why do you say Java has the most powerful OOP system?
Shaun

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Let's learn OOP!
« Reply #2 on: March 11, 2011, 02:40:49 pm »
Why do you say Java has the most powerful OOP system?

he says its just his opinion.  I may have misunderstood you, but Omnimaga's not a place for debating which language is the best.  ;)  Unless the topic is a poll to find out which is the community favorite.  ;)

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Let's learn OOP!
« Reply #3 on: March 11, 2011, 02:51:50 pm »
Why do you say Java has the most powerful OOP system?

Many languages derived from Java may have as good systems (C# for example).

But then again, not a place for debating languages.

Ashbad, I hope someone can use your help (who knows me :P).

Offline merthsoft

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 241
  • Rating: +63/-1
    • View Profile
Re: Let's learn OOP!
« Reply #4 on: March 11, 2011, 03:16:32 pm »
Why do you say Java has the most powerful OOP system?

he says its just his opinion.  I may have misunderstood you, but Omnimaga's not a place for debating which language is the best.  ;)  Unless the topic is a poll to find out which is the community favorite.  ;)
I know he said it was his opinion, that's why I said "why do you say" not "why is". I'm simply asking him to elaborate on his opinion about a language that is directly related to the topic. He wants us to learn OOP, I want to learn what about Java OOP he thinks makes it the best. I'm not debating him, I'm asking him a question.
Shaun

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Let's learn OOP!
« Reply #5 on: March 11, 2011, 03:17:09 pm »
Why do you say Java has the most powerful OOP system?

he says its just his opinion.  I may have misunderstood you, but Omnimaga's not a place for debating which language is the best.  ;)  Unless the topic is a poll to find out which is the community favorite.  ;)
I know he said it was his opinion, that's why I said "why do you say" not "why is". I'm simply asking him to elaborate on his opinion about a language that is directly related to the topic. He wants us to learn OOP, I want to learn what about Java OOP he thinks makes it the best. I'm not debating him, I'm asking him a question.

Nicely said, I hope Ashbad answers it.

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Let's learn OOP!
« Reply #6 on: March 11, 2011, 03:18:15 pm »
Why do you say Java has the most powerful OOP system?

he says its just his opinion.  I may have misunderstood you, but Omnimaga's not a place for debating which language is the best.  ;)  Unless the topic is a poll to find out which is the community favorite.  ;)
I know he said it was his opinion, that's why I said "why do you say" not "why is". I'm simply asking him to elaborate on his opinion about a language that is directly related to the topic. He wants us to learn OOP, I want to learn what about Java OOP he thinks makes it the best. I'm not debating him, I'm asking him a question.

kk, thats why I asked whether I misunderstood it.  ;)

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Let's learn OOP!
« Reply #7 on: March 11, 2011, 04:56:53 pm »
I personally like python because it uses indentation instead of semicolons and braces. I find it easier to read.

This is a great thread. I always thought it would be nice too have someplavce to ask questions about features of OOP languages
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Let's learn OOP!
« Reply #8 on: March 11, 2011, 05:04:09 pm »
  Since this cripples people's ability to do advanced computer programming, or even higher level applications, I would like to set up this thread so that people can ask questions about it, and I can answer and post help articles.

I disagree about low level languages crippling your ability to do high level work, but I'm still interesting in learning a bit about OOP.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Let's learn OOP!
« Reply #9 on: March 11, 2011, 05:07:36 pm »
I think there are some things you can do without OOP, but there are many things you need OOP for. At least in my opinion it would be much easier to use OOP then another kind of language.

I thought C/C++/C# were all OOP languages
<offtopic>has anyone heard of the languages D or GO?</offtopic>
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Let's learn OOP!
« Reply #10 on: March 11, 2011, 05:10:48 pm »
I like how nobody has asked a question about OOP yet...

C isn't an OOP language, although C++ is.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Let's learn OOP!
« Reply #11 on: March 11, 2011, 05:12:36 pm »
I personally like python because it uses indentation instead of semicolons and braces. I find it easier to read.

Some of my opinions (and explanations) of OOP languages:

Python: I like Python because it's really, really intuitive. Like if you want to check if ELEMENT in LIST, that's exactly it -- if ELEMENT in LIST is valid syntax. It also supports dynamic typing, meaning you can represent a single variable in many different forms, which makes things really easy because you don't have to convert back and forth.

Java This is pretty much the OOP language, meaning it's the most strictly based on the concept of OOP. The entire structure of the language is based on OOPL as a foundation; everything you do will be tied in some way to the ideas of objects and classes. That makes it great for real-life applications, but if you want something simple that doesn't really need objects, Java's strict syntax requirements can be a minor PITA.

C++: C++ is great because it's actually compiled, straight to pure executable assembly (unlike Java, which compiles to bytecode that still needs to be interpreted).

I've never used C#, so can't give any tips here.
« Last Edit: March 11, 2011, 05:12:57 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Let's learn OOP!
« Reply #12 on: March 11, 2011, 06:01:41 pm »
By the way, is Visual Basic 6.0 OOP?

Offline Compynerd255

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +53/-4
  • Betafreak Games
    • View Profile
    • Betafreak Games
Re: Let's learn OOP!
« Reply #13 on: March 11, 2011, 06:21:26 pm »
EDIT: I realize that my sudden little OOP tutorial might have blown you guys away just a bit, seeing as no one has posted to this forum since I posted. I rewrote it a little bit.

Oh, an OOP thread! My base is in C#, which is an incredibly OOP language. I would be happy to answer any questions about OOP that you guys might have. In the meantime, I can tell you guys what the basic idea of OOP is:

In low level programming, everything is managed by the programmer. All of the objects in the game, and all of their properties, are handled directly by the programmer. For example, to define a spaceship with an X, Y, and rotation in TI-BASIC, and then move it 10 pixels forward, you would do something like:
Code: [Select]
0->X:0->Y:0->R
X+sin(R)*10->X:Y+cos(R)*10->Y

However, in OOP, all of the objects in a program are encapsulated in classes. A class is basically an object's definition, which contains all of the properties of an object. For example, in C#, you would say
Code: [Select]
class Ship
{
public int x;
public int y;
public float rotation;
}
to define the class called Ship, with integers x and y and a floating point number "rotation". The keyword public is a special keyword that means that other objects can mess with this value.
Within that class, you can add methods and subroutines, which do things to the ship's variables. For example, you can define this method within the definition of the Ship class:
Code: [Select]
public void Move(float amount)
{
X += Cos(Rotation) * amount;
Y += Sin(Rotation) * amount;
}

Once you have defined your Ship class, you can create a new instance of it, just like you would any other variable type (e.g. an integer or float). Then, later in the program, you can access its variables and call its subroutines. To reference a part of a class, first type the name you gave that particular instance of the object, then a period, and then the property you want to reference.
Code: [Select]
Ship ship = new Ship();
ship.rotation = Pi;
ship.Move(10);
Print(ship.x);
This piece of code creates a new instance of Ship, sets its rotation to Pi, moves it forward 10 pixels, and prints the ship's x-coordinate (which should now be -10).

Now, you might be asking: Why would I ever want to use this? There are two main reasons you would.
First, while it might be easier to manage one ship in low level programming, how about managing 100 of them? To track down all 300 variables, even in a list, would be unbearable, especially if you decided later that ships also need to have health or something. However, if you create a list of Ships, you can manage each ship individually.
Second, objects encapsulate things that you just don't want to manage, or want to protect somehow. For example, our Ship had a subroutine called Move on it to move the ship forward. Instead of having to remember sines and cosines every time a person wanted to move the ship, they could just set the rotation and movement amount and just say "Move". OOP also lets you hide variables that an object needs to know about, but not the rest of the game.

And objects have real-life applications as well, more so than in games. For example, you might want to create an object called CALCnet that manages calculator linking. By using this object, you don't have to worry about all of the little details and issues with CALCnet. All you have to do is start it up, shut it down, and tell it to send frames to people.

So, that's OOP 101. There is still a LOT more to the world of OOP, and I would be happy to share my knowledge.

EDIT: I realize that the sheer magnitude of this explanation might have scared you guys away. I hope I can be clearer and help you learn OOP.
« Last Edit: March 15, 2011, 01:08:55 am by Compynerd255 »
The Slime: On Hold, preparing to add dynamic tiles

Axe Eitrix: DONE

Betafreak Games: Fun filled games for XBox and PC. Check it out at http://www.betafreak.com



Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Let's learn OOP!
« Reply #14 on: March 15, 2011, 04:02:59 pm »
It might be due to the post lenght. However I think it's good to bump the topic after a long while in case people miss it. Sometimes they might read half of it then continue later, but forget.