Skip to content

Ignorance is Strength?

ADMIN | 01-12-2011

The ignorance of how services are provided strengthens the code by allowing you to make significant changes to one component without affecting others.

Hexagon pattern 1

Ramblings about the benefits and perils of polymorphism.

Use of virtual functions, function pointers, or other delayed function dispatch, distinguishes object oriented programming methods from others. This enables you to make abstractions to separate components (by which I mean coherent and tightly coupled sections of code) from each other. The ignorance of how services are provided strengthens the code by allowing you to make significant changes to one component without affecting others. Or that is how it is supposed to work . . .

Browsing online, I stumbled across instructions for how developers may contribute to the ffmpeg codec family and the Linux kernel. In both of these cases, the overall project is done in an object oriented fashion using C. From the documentation, structs with function pointers are used to define interfaces for how the kernel talks to a device driver or how codecs talk with other parts of the software. Based on the success of both of these projects, these would seem to be cases where polymorphism is used appropriately.

There are several ways polymorphism can be harmful:

  1. Poor judgment on how to make things polymorphic may cause a performance penalty.
  2. Poor choice of abstraction can make it very difficult for components to talk to each other.
  3. Modeling algorithms using objects with state may have unintended consequences.

There are two basic performance penalties from polymorphism:

  1. Calling functions indirectly might be slower than other function calls because it prevents inlining (http://en.wikipedia.org/wiki/Inlining) based optimizations.
  2. Each polymorphic object needs a pointer to a vtable. A design which requires many thousands of polymorphic objects to be built could take much more space to implement than the same design where nonpolymorphic objects are used.

These considerations argue for making polymorphism at as high a level as possible.

Poor abstractions may be the biggest problem with object oriented programming. The point of an interface is that it stays fixed while the components talking to each other evolve. Bad interfaces can leave both clients and servers trying to do things that the interface doesn’t allow, which commit thought crimes that maim both clients and servers.

Finally, there is a critique of object oriented programming that it pushes developers towards designs where the computation is done primarily through state change of objects. Advocates of functional programming effectively argue this is not a good idea. State change doesn’t mix well with multithreading. Current GPU programming interfaces. Designs based on state changes may lead to “secret handshakes” between components which makes software very hard to understand.

What do you think?

You might also like...

5 Min read
CGM Modeler
Software components are like the stage crew at a big concert performance: the audience doesn’t see them, but their...
8 Min read
CGM Modeler
There’s a lot of confusion around what the terms additive manufacturing and 3D printing mean.
2 Min read
CGM Modeler
WRL files are an extension of the Virtual Reality Modeling Language (VRML) format . VRML file types enable browser...
Voxel model example
3 Min read
CGM Modeler
Voxels are to 3D what pixels are to 2D. Firstly -- let’s examine what pixels actually are. Everything you see on your...
Point_cloud_torus
2 Min read
CGM Modeler
Point-cloud modeling is typically used in the process of 3D scanning objects. Rather than defining surfaces through...
Polygonal Modeling
2 Min read
CGM Modeler
Polygonal (or polyhedral) modeling is the most common type of modeling for video games and animation studios. This type...
BREP Model example
2 Min read
CGM Modeler
BRep modeling, or Boundary Representation modeling, is, in CAD applications, the most common type of modeling. BRep is...
Construction site with crane and building-1
3 Min read
3D Software Development Kits
Digital twins are changing the way the construction industry manages large building projects and infrastructure...
3 Min read
3D Software Development Kits
There is a new wave of innovative processes and solutions that improve product production throughput, and enable...
3D Product Visualization.jpg
2 Min read
3D Software Development Kits
In the 3D modeling space, application developers face a number of challenges — getting to market on time, delivering...
General PMI
4 Min read
3D Software Development Kits
It has already been a year since release 2017 1.0, which saw the introduction of a number of innovative features aimed...
Large Tolerant  Vertex
3 Min read
3D Software Development Kits
boolean operation Boolean operations on individual bodies are common functions in 3D modeling. While simple in concept,...
3 Min read
3D Software Development Kits
In much the same way as physical design has moved from paper 2D drawings to 3D models in software, so has analysis....
2 Min read
3D Software Development Kits
Today was day one of Spatial Corp.’s 3D Insiders’ Summit 2016, an educational event that focuses on technical topics...
4 Min read
3D InterOp
Part and parcel with model-based engineering is model translation. Because the model is now the specification, accurate...
3 Min read
3D Software Development Kits
In case you missed the news this week, we announced the availability of Release 2017 1.0 for Spatial software...
2 Min read
3D Software Development Kits
Augmented World Expo 2016
4 Min read
3D Software Development Kits
Make or buy is an age old question for anyone building products, whether hardware or software. For example, for a...