Platform Independence

Porting an application to a new platform can be traumatic. User interface, graphics, multi-threading, synchronization, and I/O are all platform dependent. These services may constitute over half of the application code and will need to be modified for the port.

Java advanced the cause of platform independence by defining three virtual platforms:

J2SE = virtual desktop platform
J2EE = virtual server platform
J2ME = virtual PDA platform

Each platform contains class libraries and a virtual machine.

Programmers can develop applications on top of a virtual platform. Their customers can install a platform-dependent implementation of the virtual platform and run the application. The application does not need to be modified. Hence the Java slogan: Write once, run everywhere.

Patterns

The Gateway Pattern allows programmers to encapsulate platform-dependent code in a single class.

Sometimes a component has the desired functionality, but doesn't implement the desired interface. The Adapter Pattern solves this problem.

The Bridge Pattern separates implementation hierarchies from conceptual hierarchies.

Creational Patterns decouple component construction from system construction.