Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Abstract Classes, and what they imply
Gondero Werkus
post Jul 16 2006, 09:14 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 67
Joined: 23-May 06
From: Ohio
Member No.: 24,160



When it comes to making abstract classes your really just making a class to derive other classes from. But it that really more efficient?

I mean yesfor the programmer life becomes much easier when you can just derive classes from others, but honestly for the computer it is very inefficient. Take this example:

class Shape
{
Shape();

double Perimeter();
}


The class "Shape" has a constructor and a member function that will return the perimeter of a Shape object. Now to derive further along the heirarchy you get class "Circle":

class Circle: public Shape
{
Circle();

double Circumference();
}


By the standard paradigm the Circle class constructor class should call the constructor of the Shape base class. Now how is that efficient? The computer has to call the Circle constructor everytime a Circle object is created and then also has to call the Shape class constructor. The more functions that have to be called the slower the computer can run so if everything in a system is based upon the idea of deriving classes to make programming easier you have to spend more money on faster hardware.

If you just had the program have less function calls the program can run much much faster, but everyone says Object Oriented Programming is the best way to program. But that's only from a Programmer point of view not a computer's point of view.
Go to the top of the page
 
+Quote Post
Icelight
post Aug 1 2006, 12:23 AM
Post #2


Newbie
*

Group: Members
Posts: 9
Joined: 14-July 06
Member No.: 26,627



Yes, but the computer is not the one who has to maintain the code now, is it?

Fact is, sometimes small amounts of speed need to be sacrificied to make things easier for the poor programmer trying to maintain said application. Hell, with computer technology as it is the speed differences would probably be nigh-unnoticeable, as most of the heavy processing power-sucking code is already optimized.
Go to the top of the page
 
+Quote Post
Gondero Werkus
post Aug 3 2006, 01:43 AM
Post #3


Member [Level 1]
****

Group: Members
Posts: 67
Joined: 23-May 06
From: Ohio
Member No.: 24,160



Yes it may be optimized BUT it still doesn't get rid of the fact that you still have the SAME AMOUNT of function calls and that is what causes the slowdown.

And there isn't just a small slowdown in processing time. I have a 2.4GHz processor, that mean it can process 2.4 billion lines of machine code a second, so why is that the computer takes as long it does to process everything? There is no reaon in the world for computers to really run that slow with so much being processed at once.

And when you have enitre system build on nothing but Object Oriented Programs there is a giant difference because there is practically no code not in function form.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. C++ Class(6)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 02:26 PM