Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Polymorphism's effect on efficiency

807569Aug 23 2006 — edited Aug 23 2006
I am trying to measure the effect of OO principles (encapsulation, inheritance, and polymorphism) on a program's efficiency. I am basically creating two separate applications that do the same thing but are architecturally different, executing them, then comparing running times.

For an example, I'm testing the efficiency of a class with getters and setters against the efficiency of a class which performs the same tasks, but whose members are public (and thus accessed via Foo.memberName instead of Foo.getMember()).

I'm currently having trouble creating a test case for polymorphism which can show that using polymorphism is more costly than not efficiency-wise. My problem is that with simple classes I can't seem to really see a performance hit. Does anyone know which polymorphic elements/structures/practices will have the greatest effect on efficiency? And, do you have any ideas as to how I can exploit them in a simple example?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2006
Added on Aug 23 2006
8 comments
453 views