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.

DarkBASIC Professional Discussion / what is programming in classes and objects with their own methods and properties?

Author
Message
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 19th Oct 2004 22:34
Quote: "Can you program with classes and objects with their own methods and properties?"



i wanna ask about what does it mean?

what is \"can i program with classes and objects with their won methods and properties?\"

what is programming in classes and objects with their own methods and properties?



The Nerd

FREE 2d collision toturials then visit my thread here : http://forum.thegamecreators.com/?m=forum_view&t=41045&b=5
my website : http://www.freewebs.com/waggames
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 19th Oct 2004 22:41
That sounds like an Object Oriented approch to programming.. Like VB or Java or C..

You do something like:

if(myButton.isEnabled())
{
System.out.println("Button IS enabled");
}

That'd be in Java terms..

You can also make your own "methods" or functions specific to your own "object"...

So for example, say I had made an "object" representing a person in a kinda database. I could have a method say

public String getSurname()
{
return strSurname;
}

I Think that how u do it in Java.. Aint done much since I left uni and got DB!! Lol..

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 19th Oct 2004 22:42
well they say DBpro cant do that but is that a big minus for programming a game or is it dont matter?



The Nerd

FREE 2d collision toturials then visit my thread here : http://forum.thegamecreators.com/?m=forum_view&t=41045&b=5
my website : http://www.freewebs.com/waggames
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 19th Oct 2004 22:45
Dark BASIC is a procedureal language, not object oriented.

In procedural, the executing is very linear.. Which often results in less problems with synchronising everything and could well be quicker and is possibly easier to understand (hence the name BASIC.. WEll Kinda.. "Beginners' All-purpose Symbolic Instruction Code").

Now in Object oriented, code normally executed by object.. Its not so linear. Like the button click event code is only executed when you click on it.. You dont have to keep looping around saying "Is it clicked?Is it clicked?Is it clicked?Is it clicked?Is it clicked?". The language does it for you...

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 19th Oct 2004 23:14
ok thanks

FREE 2d collision toturials then visit my thread here : http://forum.thegamecreators.com/?m=forum_view&t=41045&b=5
my website : http://www.freewebs.com/waggames
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 20th Oct 2004 00:24
Quote: " well they say DBpro cant do that but is that a big minus for programming a game or is it dont matter"


its is, but it doesnt matter, why it is ? in ool's you have classes, classes function somewhat like the "type" creation in darkbasic, but they have inheritance, so you can port varibales of classes to otherclasses ,(in java you can onlye have 1 level inheritance, althoug in others ool's you can have more than 1), this means, if you create the class "automobile" wich containes variables about cars brand, number of weels and car color, and then you create the class "car year" wich containes a variable with the car manufacturing year, you could then create a new object "automobile" and then implement the class "car year" , this way you would had a new object wich can return or be affect by the "automobile" and "car year" paramethers, plus, when using classes, all the variables defined inside of a class are "array like", pretty much like inside a function, so classes are great for games, for instance when you want to create an "enemy class" , or a "special level-object class", because it spares you a lto of time.

ps: can soemone correct me if im wrong in what ive written ? cause i know theory but im not experienced in ool's coding.

Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 20th Oct 2004 03:26
OOP is generally better when you get accustomed to it. Much easier to organise a project. As well as having inheritence like Supremacy said, you can also have functions inside a class. Here is an example of how to use classes with inheritence and procedures (basically functions that don't return values) in delphi...



Another big advantage of classes is that you can have linked lists (if DBPro had a proper pointer system then you might be able to simulate this by combining it with UDTs). This is when you can create lots of objects (members of a class) using the constructor of the class (function which is called when you create a new object), and the objects will use pointers to link to each other. Then you can have one big function that starts off at the beginning of the list (pointed to by an outside pointer), and then uses the pointers within the object to go through all the objects created, and say, paste them to the screen (if you wanted). You may think you could just create an array of objects and then loop through the array, but the problem with that is the array is of a fixed size, and it also can only have one identifier with a load of numbers (not very handy when you want to find the object you want). Eg. with an array you may do this (psuedo code)...



But with linked lists you could do this...



Rather a crap example, but you cant have everything .

PS. this should be on the new board really I think.

Isn't it? Wasn't it? Marvellous!
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Oct 2004 05:30
@supremecy.. I thought java had infinite inheritance? That was the point in it.. EVERYTHING in Java is inherited from the Object class.. Maybe I'm wrong in memory, but that what I recall from my degree..

Floyd
21
Years of Service
User Offline
Joined: 11th Sep 2003
Location:
Posted: 20th Oct 2004 06:58
I think what he meant was that an object can't have multiple inheritance, that one class cannot inherit properties from more than one parent class. But of course you can have as many levels of hierarchy in Java as is necessary.
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 20th Oct 2004 07:31
exactly floyd

Mnemonix
22
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 20th Oct 2004 07:35
Yes. In java a child class can only have one parent(I dont know how java reproduction works). This can solve potential problems however, for example if class CHILD was a child of classes MOTHER and FATHER and both of these classes contained the attribute EYE_COLOR, which eye color would be used?. With single inheritance this question is never raised.

The 3d chat is coming...
In the meantime, come in the IRC. Ask me for details!!.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 20th Oct 2004 07:48
object and base class inheritance works exactly the same way in .NET (VB, C#) as it does in java, in fact, .NET was modelled after java.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 20th Oct 2004 08:56
Mnemonix: absolutly right !

CattleRustler: get a java book m8

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Oct 2004 09:03
Oh yeah I forgot.. It can only inherit from one thing.. but can extend infinite...

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 20th Oct 2004 10:53
Well I dont program in java but I do in .NET, but from what I have seen and have been told by other programmers .NET is very close to Java's model - unless of course you know squat about .NET and are thinking back to vb6 or some other drivel. Whatever.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 20th Oct 2004 19:11
CattleRustler - indeed i dont know anything about .net, it seams to be a missunderstanding here, i didnt mean to offend you
Quote: "get a java book m8"
i was refering to java inheritance of only one parent class possibility, dont know if its the same with vb/c#.net

buy the way, i was thinking of learnin .net, wich is better vb or c# ? can u point some good tuturial for a start off ?

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 20th Oct 2004 22:09
SP, yes thats what I meant, about the inheritance - and I did take the comment a little sideways no worries, I apologize.

Anyway, the only difference between vb.net and c# is the syntax. The compiled result is exactly the same via the msil/clr. I prefer vb.net as I come from a vb background, but if one comes from c++ or java they might find it more comfortable to persue c#. There are tons of examples and code snippets on [href]msdn.microsoft.com[/href]. Also look for something called 101 Samples (or something like that), its a wealth of open source projects in .net covering many different aspects.

peace


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Oct 2004 22:32
Do both languages run just as fast once compiled?

I noticed a MASSIVE speed increase from VB6 to VB.Net.. I had a lottery stats calculation program (basically it ran every combo of 3 balls through all the results and returned a list of the best combo's). In VB6 this took my old PC about 3 minutes.. .NET took about 30seconds. I wonder what my new PC could do..
OLD
P3 1Ghz, 512Mb SDRam (133Mhz), Supermicro 370SSA Mobo
Athlon XP 3200+, 1Gb DDR 400, Abit NF7S V2.0

Hmm.. Might have to dig that one out.

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 21st Oct 2004 00:14
Well .net apps are compiled-on-demand meaning the first time the app is run it may take a bit longer to start as it is compiled for the specific machine its running on, subsequent runs should be plenty fast. Java, as far as I know is interpretted during runtime, and is not ever compiled to a native exe. I would assume (if this is wholly true) .net apps would run faster than java apps, on the same machine. Sorry if this is inaccurate.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 21st Oct 2004 01:08
Quote: "i was refering to java inheritance of only one parent class possibility, dont know if its the same with vb/c#.net"


Yes, C# only supports single inheritance. Multiple inheritance can become very confusing, trying to debug it just isn't funny.

Quote: " Java, as far as I know is interpretted during runtime, and is not ever compiled to a native exe. "


Earlier Java implementations certainly did that, although I believe that newer versions of Java support Just-In-Time compiling, similar to .NET I think (I may be wrong about that).

At the moment I believe that .NET apps are compiled each time they are run, as opposed to just once. Certainly .NET apps here always take the same amount of time to startup whether it is the first run or the 50th.


BlueGUI:Windows UI Plugin - All the power of the windows interface in your DBPro games.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 21st Oct 2004 01:24
As I understand that - Java is semi-interpretted.. Ie it is just-in-time interpretting.. Although some compiling happens first. I think this converts your code into a kind of JavaVM Bytecode, but its certainly not machine specific compiles. I also know that apps like VB and C# are compiled for OS specific - not sure about machine specific.. Its normally OS kernels that go Machine specific isn't it?

So which one is quicker VB or C# once compiled? Could somoene do a benchmark?
a 15 second timer and see how many itterations each one does on a certain command.. like:
" inc x : dec c "

Just an idea..

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 21st Oct 2004 03:54
I saw a benchmark once and it stated the following:

fastest to slowest:
C++
C# & managed C++
VB.NET
VB6

they also went on to note that that the speed difference between vb.net and its .net/managed counterparts was negligible. Unfortunately I dont remember where I saw this and what the figures were. Im sure they are out there somewhere.


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
DrakeX
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 21st Oct 2004 06:36 Edited at: 21st Oct 2004 06:36
"Now in Object oriented, code normally executed by object.. Its not so linear. Like the button click event code is only executed when you click on it.. You dont have to keep looping around saying "Is it clicked?Is it clicked?Is it clicked?Is it clicked?Is it clicked?". The language does it for you..."

not true. only VB does that. in C++, you are responsible for pumping the windows messages.

the only thing object-oriented means is that you've got discrete data obejcts with their own methods. that's it. what you've described is event-driven programming - which doesn't necessarily have to be object-oriented, and is just a "hoax," as the code is still executed linearly - you just don't see it.



"when it's done" means "we have no idea, we forgot to do that, we where hoping you would all forget we promised <insert exotic promise here>"
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 21st Oct 2004 09:54
erm, then system events mean nothing? Where the OS notifies the layers "has it been clicked, no has it been clicked, no has it been clicked, no has it been clicked, no has it been clicked, no has it been clicked, YES"-message to pump ?


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 21st Oct 2004 10:22
In Java its event based.. I know the button was a bad example, but it still sort of object oriented in that the event for the button is linked with the button object (in Java you have to add an actionListener to the button to listen for clicks).

anomer
20
Years of Service
User Offline
Joined: 11th Oct 2004
Location: City of Tears
Posted: 21st Oct 2004 11:18
Although I'm sure no one cares I just thought I would state my preference. My favorite syntax and programming model would have to be DB however I code in c++, java, vb.net etc. and if I were to go with .net languages I would choose c++ over c# simply because of portability. I hate coding something only to have to port it to linux in another language. Anywho...my 2 cents

~fades

Login to post a reply

Server time is: 2025-06-03 17:58:59
Your offset time is: 2025-06-03 17:58:59