Jump to content
xisto Community
Sign in to follow this  
Gondero Werkus

Abstract Classes and what they imply

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.