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 / Rick, your opinion on Obeject Oriented Programming

Author
Message
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 25th Nov 2002 18:43
Before I read this thread I didn't have an opinion! I grew up with Basic and then on to 6502 and then some 68000. So very little OO in my coding days.

I'll add this idea to the ever growing list. In the New Year I'll ask Rich to post some kind of voting pole so that we can see what the majority wants for DBPro.

I have spent the day looking to see what the wonderful nVidia people are bringing, go visit their site and see the amazing GeForce FX!

Rick

Commercial Director
Dark Basic Team
[Read "The POWER of NOW by Eckhart Tolle". There is no past or future, only NOW!]
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 26th Nov 2002 00:04
(^_^) you like too? I take it DBS are also going to getting ahold of one of thier very own to play with soon
God its like christmas whenever nVidia release a new card

thou on the point at at... someone please explain to me with the BIG writing what the heck OO actually is??
And I know that people if they really wanted it could develop it in DarkBasic Pro as C++ was developed within C, always thought the OOL was just all those fancey Class Structure functions which i always thought the Types we're - no one has yet to tell me i'm wrong here thou

So this is becomming very confusing and not really seeing the point myself... seriously what is the point in something new if most of us are having trouble with the normal language and are quite confused on what everyone means by OOL!

Anata aru kowagaru no watashi!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Nov 2002 00:57
Very basically:

A class is a definition of a collection of related variables, and functions that operate on them.

Objects are instances of those classes. Ideally, the only access to the variables within the objects are via the functions.

A class can be based on another class (inheritance), ie it can replace or extend the functionality.

Also it can be used anywhere the original class could be used (polymorphism), for example when being used as a parameter to a function call.

Classes in C++ *are* just fancy structs (like types in DBPro) but with functions added.

We can't currently implement an OO system yet, we need:
Passing types to functions.
Returning types from functions.
Passing values/types by reference (ie hidden pointer - safe) or with explicit pointers (not so safe).
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 26th Nov 2002 01:45
ill just respond to ratty
Quote: "
1) does DB need OO functionality - NO, there is nothing you can write with an OO language that you cannot write with a non-OO language (although it may be more difficult to do so)"

Agreed!
Quote: "
2) Will OO in DB make coding easier - Only if you want to do a really complex project.
"

Agreed!
Quote: "
3) Will OO functionality be useful in DB - Yes, particularly 2 or 3 projects down the line where you find yourself re-using the same classes over and over, without ever having to re-write them, or to expand an existing project.
"

hmmm, im not sure on this one, personally i've never really re-used much code. The only code (objects) i reuse are smaller objects mainly for file I/O, GUI stuff. I find using object inheritance alot can make for poorly readable code and a bitch to maintain.
Quote: "
4) Can DB-Pro be easily retro fitted with OO functionality - I would suspect this may be very difficult, but only Lee and the rest would really know the answer to this.
"

I would guess this will never happen as it would be extremely hard to do without a re-write, but me for one don't really care i like my basic, basic.
Quote: "
5) Do I want OO functionality in DB-Pro - Don`t care, if Lee wants to add it then great, I would definately make use of it, if not then fine, I love coding in this 'traditional' way (takes me back to my school days, BBC micros etc.... oops, am I showing my age?) + its great for doing quick and easy code with superb looking results.
"

Game on!

my opinion is DBPro doesn't need OOP.

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 26th Nov 2002 02:20
@Raven

I have a good C++ book here that describes OOP a bit. I'll quickly type a bit down:

Procedural Programming: <-- DBPro
Programs are thought of as a series of actions performed on a set of data. Structured programming was invented to provide a systematic approach to organising these "procedures" (functions) and to manage large amounts of data. The priciple idea behind structured programming is as simple as the idea of divide and conquer. Any task that is too complex to be described is broken down in to a set of small tasks, until the tasks are small and self contained enough that they are easily understood.

Object Orientated Programming: <-- Python / C++ / Java, etc...
The essence of object orientated programming is to treat data and the procedures that act upon that data as a single "object", a self contained entity with an identity and certain characteristics of its own.

There are a few main principles of OOP:

Encapsulation and Data hiding
To achieve this the 'object' must be self contained. It must do one well defined thing, and it must do it completely. Doing one thing completely is called encapsulation. Languages support encapsulation and data hiding through the creation of user defined types, called classes. (An instance of these classes is called an object) The actual inner workings of the class should be hidden, users of a well defined class do not need to know how the class works merely how to use it.

Inheritance
A new type can be declared that is an extension of an exsisting type (class). This new subclass contains all functionallity of the original superclass and can be modified and extended. If the superclass is modified the subclass reflects this.

Polymorphism
Languages supports this idea that different objects 'do the right thing' through what is called function polymorphism and object polymorphism. 'Poly' meaning many and 'morph' meaning forms. polymorphism refers to the same name taking many forms. i.e. a single function that can handle function arguments in many different types. or like in C++ where you would code duplicates of a function (named indentically) to handle different argument types


Phew! i hope that makes it a little clearer right im off to bed!

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
mamaji4
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location:
Posted: 26th Nov 2002 19:10
There seems to be a major misconception about the term "efficiency of compiled code". When we talk about inefficiency, we are not talkin about the SIZE of the compiled code. We are talking about its ability to execute the requisite task in real time. I have worked with real time operating systems and we still use C in time critical applications, in the "inner loop". We sometimes wish we could use assembly all over again. What I am saying is whatever C++ can do, C can do faster and ASM can do still faster. That is the efficiency I am talking about. Classes, Inheritance and all other OO stuff puts an additional burden on an OO compiler. The final compiled code is by the way always procedural. OO is only an abstraction. Which means the final machine code is going to have a lot more unecessary lint which a procedural compiler would not have generated. This interprets into a performance hit. And a 2GHZ processor is pretty soon not going to be fast enough to write commercial games with quality graphics and intricate dynamics engines. Game programming will always be about speed.

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 26th Nov 2002 19:24
Hmmm... I think perhaps its a little clearer,
its a bit like the different between Linear and Dynamic right?

so dbpro is like
start -> function -> effect -> render -> loop to start

but C++ is like
start -> function -> render -> loop to start
-> function -> effect -> function -> render -> loop to function

allowing my dynamics within the program right?
each object/class is a seperate dynamic program encapsulated inthe main one ... lol i hope that sounds right.

If that is how it is, I kinda thought that the programs build actually gained thier speed from not just being binary but actually being multi-threaded meaning the entire loops doesn't have to be run just for something to be done, prime example being the fastsync routine which renders the backbuffer of 3D objects there and then rather than rendering and utilising the entire program loop like sync.

Of course i've no doubt missed the point on OOP hehee, but i dunno perhaps i if thats the case i need the Rainbow book with the big letters to explain it

I've personally been using DarkBasic Pro and C++ for programming over the last few weeks, and to be honest I've not seen much difference in style of coding i need to do or even SPEED which is the key word when programming.
So erm what does it matter? hehee

Anata aru kowagaru no watashi!
mamaji4
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location:
Posted: 26th Nov 2002 23:40
"When I looked at the size of the EXE's that were produced, I was shocked! It was true that the C++ program was bigger. Yes, the C program was 204K and the C++ program was 224K. Yup a 9% size increase. Yup, a lot of people are going to be disappointed that a program fills their 20 gig hard drive up by 20Kilobytes more. "
You are assuming on the basis of a single program you have written on the size difference of the executable between C and C++. How about taking a larger statistical sample size and then determining exactly how much larger the C++ equivalent is.

" No really. Since the code is compiled, it's going to run as fast as the processor will allow it to. The only areas that you can get in trouble with speed is sorts and searches. I am not even sure why you are saying that OO is inefficient at speed. It isn't "
A C++ compiler has to deal with abstractions like inheritance and polymorphism (in the context of the source code). It is bound to generate more intricate code than a simple procedural language. That is bound to effect the speed of execution of the program. OO was developed to organise the complexity of software at the source code level. At the machine code level the compiler produces more complex code.

"Why would the industry choose C++ over C."
Each programming problem dictates the choice of language. Industry has not chosen C++ over C. It just so happens that most real world problems are more suited to C++. However, in time critical applications (telemetry, emulators,etc.) you will find that C rules the roost.

"DarkBasic/DarkBasic Pro makes it easy to use the Direct X API. It's not simplifying the programming paradigm any further than it already has been. You can make very complex DarkBasic Pro programs if you wanted to. Adding OO is not going to take away from how simplifyed it already is. It's giving those who have advanced skills the ability to use those skills. "
A paradigm is basically a method. OO is definitely more complex to think up and organise than procedural. If DB has eliminated all that complexity that is inherent to OO I would say it is simplifying the programming paradigm by making it proceduaral. By reintroducing OO into DB don't you think that you are adding what Lee has tried to eliminate in the first place. And if you have to add OO to DB you would have to re-write the entire compiler. This means that whether you use the OO commands or not the compiled code will be that produced by an OO DB compiler rather than a procedural DB compiler. It is bound to be more bloated and inefficient speedwise.

ZomBfied
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Nov 2002 00:02
Soulman, just because the user wouldn't be forced to use OO, doesn't mean that there is no price for implementing it. It would take time out from perfecting the current format and introduce a whole new world of compiler bugs et cetera that I don't think DB needs.
How exactly would class objects help you in DB, what exactly could you do with them that you couldn't do in other ways? It's just your style of programming, but in most (most, mind you) cases, I think I can set up a procedural program to do anything your OO model can do just as quickly, if not more so.
OO would be useful, but I think there are a lot more things they could do that would benefit the db pro user more. So my vote, if I had one, would be against.
I would like to be able to
*pass UDTs to functions and out of functions
*pass vals by ref
*force declarations of variables within functions and out
*and have foldable subs and
*be able to store code in modules like VB.

But I say get the damn debugger to work right before you add anything else. Once it can find the actual line where an error occured...

Asside from that, DB pro rules btw.

Munin
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location:
Posted: 27th Nov 2002 01:05
Sorry guys, but after quite a few many years programming, right from Amstrad basic to DBpro (I only do basics) I still don't know the real definition of object-o code and the other type,
anyone help?
Alessandro

Michael
21
Years of Service
User Offline
Joined: 26th Nov 2002
Location:
Posted: 27th Nov 2002 02:23
Hello Munin,

Object Oriented Programming is just a way of making your code easier to read and understand.

It helps prevent Spagetti code. Such is why people should Never use Goto statments when you can use any other loops or functions to make the code easier to read and understand.

Objects are used to group things together.

Heres a simple example
You have a User Defined Variable called cat
Cat has
Legs = 4
Eys = 2
Head = 1

Initially it starts out as a TYPE
Now here is the fun part. You can ass a Function To an object. Like
Cat.run()

You'd call that function by putting in
myCat as Cat
myCat.run()

the alternative is to use a Function like this
FUNCTION RunCat(myCat as Cat)
ENDFUNCTION myCat

I hope that helps explain a little Munin

Personally I think Objects should be implemented but at a later date. DBP needs to have the bugs worked out a bit more.

Never Ever Use Goto
Avoid Globals like the plague
Magic Numbers are all in your head
and by all means be Lazy

ZomBfied
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Nov 2002 19:09
I try to avoid globals, but they haunt me. They tempt me with their global-ness. "Go ahead," they say, "Define me but once and I shall run through your whole program!" I am like a moth to their all-encompassing flame and soon my program is ridden with them.

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 28th Nov 2002 06:42
point in the global isn't so much definining within the main program as thos values technically are already global.

its for use in functions so that you can use things in then and pass them in and out without requiring the use of the return value which is good for certain operations but large amounts of data that need to process in a loop form, allowing you to while the data or another such within the funciton whilst keeping what your doing within the main program. Or atleast that how i figure they should be used

Anata aru kowagaru no watashi!
ZomBfied
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 29th Nov 2002 01:06
My gf has nice globals.

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 29th Nov 2002 21:00
hahaa... my does too, but i'm gonna reckon a kid is gonna ruin them and cause all sorts of unseen errors

Anata aru kowagaru no watashi!

Login to post a reply

Server time is: 2024-05-04 04:55:36
Your offset time is: 2024-05-04 04:55:36