Skip to main content
gamedev.net
🔒 Locked

OOP

Started by neo88 6 replies 300+ views
Original Post
neo88
neo88
It seems to me that OOP is not as good as procedural programing. I wrote a OO program to display the words "Hello, World!" and it ended up being over 100 lines long, and the first few times I compiled it, there were a million error messages. I really like Java and C++, but I feel more comfrotable with a language like Perl. And Perl''s OO stuff is pretty easy and understandable. All this other stuff is really complicated. Is there any way that OO programming can be made easier? I like the idea of classes and all, but I find that they are extremly hard to implement. BTW, maybe I should mention that I loath the idea of header files, import files, and the like... I don''t why, it just seems messier, even though I know it is supposed to make the code look cleaner, and I guess to some extent it does. But, if you have a long program why waste half a page includeing and defineing things, when you could just as easily implentment them right in your main program file? I''m obviously not talking about standered header files here ie , I''m talking about the header files that you design yourself. I hope that this generates an interesrting dissucsion, since I am very interested in what other programmers think about this stuff. neo88
My Kung Fu is stronger.May the Source be with you.neo88
ToohrVyk
ToohrVyk
O''Caml rules. It allows Objective, Functional, and Imperative programming.

And I am better than your countries.
JTippetts
JTippetts
o_O

#include <iostream>

int main()
{
std::cout << "Hello, world." << std::endl;

return 0;
}



or even

#include <iostream>

class HelloWorldClass
{
public:
HelloWorld(){std::cout << "Hello, world" << std::endl;};
};

int main()
{
HelloWorldClass HelloObj;
return 0;
}

Exactly what were you doing that it took you over 100 lines??

Also, if you implement everything all in your main program file, it makes it tough to make sense of a file that is 100000+ lines long.

If I have a class Vector3D, and I put the class definition in vector3d.h and the implementation in vector3d.cpp, then I know exactly where to find a function I need, and I can use Vector3D in a dozen programs without having to cut/copy/paste. Throwing everything into one file is a bad way of doing things, and can cause you problems in the long run.

And that is not even to mention compile speed. Say you have a project that is 100000+ lines. You make a tiny change to one function, then rebuild. In the project in which all code is in one source file, you have to recompile every single line. Splitting source up into separate files cuts this compilation time (which can be significant for a large project) down to a fraction, by only recompiling the source file in which you made the change.

My current project just exceed 49000 lines, and I shudder to think about having to work on it further if it were all dumped into a single source file. Golem would die here and now, if that were the case.

Josh
vertexnormal AT linuxmail DOT org


Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.
superpig
superpig
I''m thinking it could *maybe*, just *maybe*, be a joke...
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
ToohrVyk
ToohrVyk
Printf.printf "Hello World";;

EDIT: bah!

[edited by - ToohrVyk on October 19, 2003 4:12:58 PM]
23yrold3yrold
23yrold3yrold
quote:
Original post by VertexNormal
o_O

Exactly what were you doing that it took you over 100 lines??
That''s what I''d like to know. 100 lines; holy shit^3 ...


CFNINM(NM) — Coalition For Newly Instated Nazi Moderators (Namely Me)
Join by posting something I can delete and anally probe you for.
Jesus saves ... the rest of you take 2d4 fire damage.
JTippetts
JTippetts
quote:
Original post by superpig
I''m thinking it could *maybe*, just *maybe*, be a joke...


Upon second analysis, I''m thinking maybe, just maybe, you might be right superpig.

Josh
vertexnormal AT linuxmail DOT org


Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.