OOAD

SOA Repository Best Practice

SOA Repository Best Practice
By: John Moe, Head of Business Integration, TORI Global
Tuesday, December 8, 2009

For those of us who have been developing applications for many years (think COBOL & Assembler from the 70s and 80s), the idea of having a code library (programs and routines) is nothing new. However for the Web Services generation, this concept has taken a while to re-emerge, but has now been packaged in the form of a services registry and/or repository.

Why method calling through interfaces are slower than calling from abstract classes?

What is SOA?

SOA establishes an architectural model that aims to enhance the efficiency, agility, and productivity of an enterprise by positioning services as the primary means through which solution logic is represented in support of the realization of the strategic goals associated with service-oriented computing.

Factory Method Explained

Intent
Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. [GoF, p107]
Defining a "virtual" constructor.
The new operator considered harmful.

Problem
A framework needs to standardize the architectural for a range of applications, but allow for individual applications to define their own domain objects and provide for their instantiation.

Discription

Interfaces in C#

in

An interface contains only the signatures of methods, delegates or events. The implementation of the methods is done in the class that implements the interface, as shown in the following example:

interface IExampleInterface
{
void ExampleMethod();
}

class ImplementationClass : IExampleInterface
{
// Explicit interface member implementation:
void IExampleInterface.ExampleMethod()
{
// Method implementation.
}

static void Main()
{
// Declare an interface instance.
IExampleInterface obj = new ImplementationClass();

Dealing with Changes: Using Functional Decomposition

Using modularity to isolate variation

Example 1-1. Using Modularity to Contain Variation
function: display shape
input: type of shape, description of shape
action:
switch (type of shape)
case square: put display function for square here
case circle: put display function for circle here

Problems with modularity in a functional decomposition approach

Then, when I receive a requirement to be able to display a new type of shapea triangle, for instanceI only need to change this module (hopefully!).

Introducing SOA Design Patterns

Originally inspired by techniques used to design buildings and cities, and popularized by the Gang of Four during the mainstream emergence of object-orientation, design patterns have seen us through the various shifts in architecture, technology, and, of course, design. Pattern catalogs have periodically emerged, one building on the other, and each revealing a set of problem-solving techniques and providing invaluable insights as to how and when those techniques should be used to help us attain our design goals.

Some more Design Tips

Abstraction is your friend: A software design is a complex thing, especially, if you do not use abstraction to good effect. The design should be done at various levels of abstraction. At higher levels, you visualize the system as a small number of big components while abstracting away the details of what is inside each component. Once you have a good definition of what each of those components represent and how they interact with each other, you can move to the next lower level of abstraction.

Design Tips: Do Not Allow Inheritance Of Custom Attributes

Attribute classes should inherit directly from System.Attribute and should therefore be protected from further inheritance.

Error Handling Design Tips

in

Here are some Design Tips on Error Handling or Exception Handling:

1. ArgumentException should be used if invalid parameters are passed.
2. Catch block should log exceptions to event log
3. Directory.GetFiles() method requires try/catch block
4. Do not create methods that throw System.SystemException
5. Do not create methods that throw System.Runtime.InteropServices.ExternalException
6. Do not create methods that throw System.NullReferenceException
7. Do not create methods that throw System.Exception
8. Do not create methods that throw IndexOutOfRangeException