Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Unity 5 is now free

Author
Message
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 18th Mar 2015 01:21 Edited at: 18th Mar 2015 02:56
Quote: "It would be neat if there was an OOP based language designed specifically to be learned; that could be a great stepping stone for those intending to learn OOP."


Well technically that would be Java, seeing as its entirely OOP!
The code I wrote above is Java, minus a few things.

Java code for a Color class I just made (I was bored):


Dark Java Dude 64
Community Leader
13
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 18th Mar 2015 02:19 Edited at: 18th Mar 2015 02:25
Quote: "designed specifically to be learned"
Haha, Java is one of the harder languages I have tried to learn. I think further up in the thread though, you agreed that Java wasn't the greatest for learning (I'm too lazy to look ).

When I first started off programming, it was with a programming language called 'Phrogram'. Mainly OOP, also designed primarily for children to learn. I never got too far in it though, and its functionality was poor, so that's when I went looking and found DBPro.

Sad, their forum was the first forum I was on. A super small forum, way smaller than TGC even. So small, in fact, that I became a prominent member! Looks like they have since gotten rid of it.

"Sorry, you can redo your sig...Stupid Mod pressed the wrong button." - JLJupiterCat
Jeku
Moderator
20
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 18th Mar 2015 16:45
@BiggAdd - That's some great examples you have there

I love building objects for games, and the thought process involved. I was working on a Rummy card game in Haxe last year and really enjoyed thinking about the real-world objects. There's a Dealer, and he has three Deck objects, and each Deck has 52 Card objects, etc. Then writing the shuffle() function was really interested, and then dealing out to the Player objects. If you forget about the complexity of OOP before starting, and just map out the objects like they would appear in the real world, then that's a great start.

Yes there are patterns you can implement that are well-documented, and complicated OOP things that are there if you want to use them, but you don't have to at all. If you're a beginner to OOP, just break your simple game into real-world objects. It's fun

Senior Developer - CBS Interactive Music Group
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Mar 2015 17:10 Edited at: 18th Mar 2015 17:11
Quote: "just break your simple game into real-world objects. It's fun"


I agree, it is fun

I think people get put off by more abstract concepts, maybe a sprite manager for example. But I also think of them as someone I go to for my sprites, or use the term 'factory' which again relates it to something tangible and you instantly know what its job is.

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Mar 2015 05:07
Quote: "or use the term 'factory' which again relates it to something tangible and you instantly know what its job is."


I have never understood what a "factory" does in C++. It's a commonly-used term, but I've never worked out what it was for. It just confused things for me.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Mar 2015 08:54
It allows you to create objects without knowing the derived type.

http://gameprogrammingpatterns.com/type-object.html

Need help with C/C++ game dev? PM me or add me on skype: the__comet.
Current active project: Light Ship
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Mar 2015 11:58
Quote: "It allows you to create objects without knowing the derived type."


Yeah.... that confused me more. Derived type? Derived from what?

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 19th Mar 2015 12:35
You could have a vehicle factory that produces both cars and ships which are both vehicles. The rest of the program wouldn't need to know what a ship or car is, just what a vehicle is. Atleast that's how I think it works



Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 19th Mar 2015 14:27
Quote: "And that is the basics of OOP!"

That is actually quit easy to understand. Thanks Mr. BiggAdd for the examples. Though I could easily redo this with procedural code in agk or dbp. What are the advantages of doing this in oop?

I'm still not convinced to learn it lol, but awesome examples anyway.

Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 19th Mar 2015 15:14
in procedural, a method, or things am object can do, have to be written as general functions. they can't 'belong'to an object. there is no concept of public or private so anything can use the function really and instead of an object using is action, you call an action and pass it what you want to take that action.

instead of thisCar.drive() you have to do driveCar(thisCar) and you can technically pass anything into driveCar even things which will cause bugs and errors, which the object method protects you from.

ultimately the difference between oop and procedural is organization and logic. you can do most things procedural that you can do OO bit you often have to do a lot more and in a more complicated way than if you were dealing with objects.

Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 19th Mar 2015 15:20
it's kind of like saying why should I use UDTs I can do the same things with native types.

yes you can, but not as easily and without a great deal more complexity

BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 19th Mar 2015 15:23
Quote: "Though I could easily redo this with procedural code in agk or dbp. What are the advantages of doing this in oop? "


It makes your code more modular and easier to maintain. Also when you get into the "advanced" OOP concepts, then your code can become much more powerful.

For Instance, If I want to write a very simplified directed Node graph in Java:


I can now store any type of Object I want into each node, as I'm using a generic type 'E' that I've defined in the class declaration.

I can then instance the class like so:



Login to post a reply

Server time is: 2024-03-29 15:36:06
Your offset time is: 2024-03-29 15:36:06