Jul 25, 2008

Abstract Classes - and what they imply

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

Abstract Classes - and what they imply

Gondero Werkus
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.

 

 

 


Reply

Icelight
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.

Reply

Gondero Werkus
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : abstract classes imply

  1. C++ Class - teach me classes (6)
  2. Classes In C++ - (4)
    QUOTE C++ is a bunch of small additions to C, with a few major additions. One major addition is
    the object-oriented approach (the other addition is support for generic programming, which we'll
    cover later). As the name object-oriented programming suggests, this approach deals with objects. Of
    course, these are not real-life objects themselves. Instead, these objects are the essential
    definitions of real world objects. Classes are collections of data related to a single object type.
    Classes not only include information regarding the real world object, but also fun...
  3. Including Classes/lib's Twice - (1)
    I'm using Dev-C++ as a compiler. (To use a classroom assignment as an example,) here is my
    problem...I've got classes Dog and Cat, which inherit from class Animal, (which uses iostream,
    stdlib, and some classes created by students) When I include both Dog and Cat in a new file, I get
    errors because I'm including libraries twice. (iostream included from Dog, and from Cat...)I can
    get around the problem by having Dog inherit Animal, and Cat inherit Dog (which sounds pretty
    idiotic, I know..I was just testing to see if the problem was really what I thought it w...



Looking for abstract, classes, imply

Searching Video's for abstract, classes, imply
advertisement



Abstract Classes - and what they imply



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE