The Architecture Adapter pattern isolates complexity to the adapter and away from client and target service code. When implementing the Architecture Adapter pattern, you should follow a few general rules. Specific scenarios, such as Web Services to Java, drive more implementation details based on the architectural styles involved:
Establish a common pattern for traversals between architectures and build reusable adapters whenever possible: If you traverse between architectures once in a program, you will probably do it repeatedly. There are likely common serialization and de-serialization techniques for moving data into and out of the architectures. Encapsulate these techniques. Reusable adapters will also include a generic dispatcher or mapping table to select the proper target service and invocation method.
Architectures that use different programming paradigms are more difficult to adapt than similar programming paradigms : Architecture adapters between object-oriented languages will usually be much easier to write than an architecture adapter between an object-oriented language and a procedural language. Although the architectural details may appear simple, leave enough time to address design and implementation complexities for the adapters.
Plan for performance concerns: Serialization and de-serialization of data takes time. Be aware that the adapter route can never perform as well as code that is entirely native to an implementation. For example, calling a C function from Java to calculate the first five prime numbers would be wasteful because of the adapter overhead. Calling a C function to locate the 10,679 th prime number would likely pay off in terms of performance.
Architecture adapters should decrease the complexity within a component for accessing functionality in a different architecture: Using an architecture adapter in a component should allow client programmers to program in a single language with method calls that appear as if the programmer is simply calling another class or procedure. Isolating this complexity should make the primary code line easier to read and maintain.
Use prebuilt architecture adapters and platforms, such as Web Services, whenever possible: If you plan, there are few reasons to build your own architecture adapters. The Java Native Interface (JNI) and Web Services are two excellent technologies for allowing Java to utilize other architectures. These layers can be difficult to get right, so try to reuse whenever possible.