Programming Proverbs 14: Avoid implementation-dependent features

Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

Programming Proverbs 14: Avoid implementation-dependent features

  • Comments 2

Implementation-dependent features are features or the the hardware or operating system or other part of the platform that is not available on other platforms. For example a specific piece of floating-point hardware or a language feature that is not part of the standard language specification or an operating system API that is not available on other operating systems.

The goal behind this proverb is to create programs that are portable as possible. There are a number of things that have made this both more and less of a problem then it used to be. It is less of a problem because of Virtual Machines that sit between the program and the hardware and base operating system. Java is one such and .NET is another. These virtual machines are able to take full advantage of underlying hardware and software without the applications programmer having to know about it.

At the same time taking full advantage of hardware or operating systems sometimes does require implementation-dependent features. The should be avoided as much as possible but no more than possible. Sometimes one absolutely positivity has to have the most performance possible. At that point one sometimes has to give in an use implementation-dependent features.

In those cases those features should be isolated and compartmentalized as much as possible. By keeping those details separate and independent one can more easily migrate to other platforms with minimized risk.

This is the fourteenth in a series of posts based on the book Programming Proverbs by Henry Ledgard. The index for the series is an earlier post and discussion of the list as a whole is taking place in the comments there. Comments on this "proverb" are of course very welcome here.

  • "At the same time taking full advantage of hardware or operating systems sometimes does require implementation-dependent features. The should be avoided as much as possible but no more than possible."

    ROTFL it remind me of opengl vs directx...

  • I think that a good example of platform dependencies in the MS world is the difficulty of some programs making the transition from XP to Vista.

    Another question to ask is when would you want to take those platform dependencies?

    If you want to make an improvement to the program that is just not possible with the recommended API usage you might use some clever techniques to achieve your goal.  You may be taking a platform dependency without realizing it since the behaviour of the OS had been the same for ten or twenty years.

Page 1 of 1 (2 items)