Karim's Playground http://karim.sentio-software.com Programming, Sofware Architecture, User Interface Usability, Trance Music, and other random stuff My internship at Microsoft 6/9/2010 12:58:50 AM http://karim.sentio-software.com/read/my-internship-at-microsoft I felt relieved after finalizing my last formal step on the way to my internship at Microsoft in Redmond - getting the visa to the United States.  I will be working in the Active Directory team building the so-called NGAD (Next-Generation Active Directory). More info about this project is on this presentation from PDC 2009.

 

On this blog I will try to regularly post updates about the 3 months that I'll spend in Redmond, in Seattle, and generally in the US. Promises to be an awesome adventure!

Stay tuned!

]]>
Immediate data binding update 2/21/2010 8:41:36 PM http://karim.sentio-software.com/read/immediate-data-binding-update While writing a WPF application that made use of incremental search basing on the value of a TextBox I've faced a problem that the ViewModel (the DataContext) was notified about the changed value of the property only when it lost focus.

So let's say I had on the ViewModel side:

 

public string QueryString
{
    get
    {
        return _queryString;
    }
    set
    {
        _queryString = value;
        OnPropertyChanged("Patients");
    }
}

and in my WPF:

 

<TextBox Height="36" Margin="12,23,12,0" VerticalAlignment="Top" FontSize="18" Text="{Binding QueryString, Mode=TwoWay}" />

A change on the QueryString property on the ViewModel should be whenever the value of the TextBox is changed - no matter whether it lost focus or not.

The solution to this is to set the UpdateSourceTrigger property of the binding to "PropertyChanged". Now a PropertyChanged is triggered immediately after a new character is typed (or pasted):

 

<TextBox Height="36" Margin="12,23,12,0" VerticalAlignment="Top" FontSize="18" Text="{Binding QueryString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

 

Yet, everytime a new value is entered a new search is performed. Although the searching algorithm is quite efficient (as it's built on suffix trees) but the user could experience some delays between his keystroke and the new value appearing on his TextBox, thus why I recommend setting it's IsAsync value to "true":

 

<TextBox Height="36" Margin="12,23,12,0" VerticalAlignment="Top" FontSize="18" Text="{Binding QueryString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, IsAsync=True}" />
]]>
DirectShow custom transform filter skeleton 12/29/2009 11:33:43 PM http://karim.sentio-software.com/read/directshow-custom-transform-filter-skeleton After my last struggles with building a DirectShow video filter, I've decided to publish a skeleton application for a video transform filter.

This skeleton application is using the CTransformFilter approach, it means that it performs per frame transformations on a copy of the frame.

 

While you might think that transforming a copy of the video frame is not effective as you are using double the size of the memory for each frame, but in fact - this approach is quite more performance-effective for the project that I was building as accessing and modifying the data in the video card memory consumes more time than working on your local memory in some cases (when your video cards is not fast i.e  an embedded devide) and my project was the case.

 

Of course, you should consult the MSDN documentation upon writing your filters and I would suggest you to write it from scratch if it's a sophisticated one, if you might need more than one input and output pin, or in general you need to customize it to meet your needs. This code is by no means a silver bullet.

I would like you to excuse me for leaving the classes and methods unchanged in the source code. As this skeleton is a crippled-down version of my original project that was really a pain in the ass.

Using the attached source code to create a new filter is limited to implementing one method - the Transform method in the OculusVideoFilter class:

 

HRESULT OculusVideoFilter::Transform(IMediaSample *pMedia)
{
    BYTE *pData;                
    long lDataLen;              
    int iPixel;                 
    int temp,x,y;               
    RGBTRIPLE *pRGB;            

    AM_MEDIA_TYPE* pType = &m_pInput->CurrentMediaType();
    VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat;
    ASSERT(pvi);

    CheckPointer(pMedia,E_POINTER);
    pMedia->GetPointer(&pData);
    lDataLen = pMedia->GetSize();

    int cxImage    = pvi->bmiHeader.biWidth;
    int cyImage    = pvi->bmiHeader.biHeight;
    int numPixels  = cxImage * cyImage;

    pRGB = (RGBTRIPLE*) pData;
    for (iPixel=0; iPixel < numPixels; iPixel++, pRGB++) {
        /*
            here you implement your per-pixel operation on the currently processed frame.
        */
    }
    return NOERROR;
}
 
This skeleton app is COM-ready (It's required for DirectShow filters to be COM ready), so all you need after implementing your filtering logic is to compile the library, it will generate a .DLL file for you and use regsvr32.exe to register it.
One more note: Please remember to change the CLSID of the class, as it will conflict with other registered interfaces. If you would leave the CLSID:
 
// {5F1E81B9-9669-444D-A007-63EBB5CE92E3}
static const GUID CLSID_OculusFilter = 
{ 0x5f1e81b9, 0x9669, 0x444d, { 0xa0, 0x7, 0x63, 0xeb, 0xb5, 0xce, 0x92, 0xe3 } };
 

Unchanged and one day it might happen that you'll use my piece of software (or two people using this skeleton will not change this CLSID) you will end up with conflicts in your registry.

 

Download package.

 

Now as an example I'll show you how to create a video filter that will grayscale your output video.

The grayscale calculation is: grey = (30 * red + 59 * green + 11 * blue) / 100

A faster (but less precise) method would be: grey = (red + green) / 2

 

Now, with this navigate to the filter class to line number 137 and in your loop should look similar to this:

 

for (iPixel=0; iPixel < numPixels; iPixel++, pRGB++) {
      grey = (prgb->rgbtRed + prgb->rgbtGreen) >> 1;
      pRGB->rgbtRed = prgb->rgbtGreen = pRGB->rgbtBlue = (BYTE) grey;
   }

 

Have fun with your filters!

]]>
Microsoft SQL Server Enums 10/29/2009 4:49:21 PM http://karim.sentio-software.com/read/microsoft-sql-server-enums You know the enumeration data type, for sure. Either from programming languages (most often it's the enum keyword) or from database engines like MySQL.

What I was missing lately in my SQL Server database was the enum. To have a column that could accept only a defined set of values. As an example of MySQL enum column, is defining clothing sizes:

 

CREATE TABLE cloth (
    .
size ENUM('small', 'medium', 'large')
    .
);

 

Unfortunately SQL Server doesn't provide this functionality out of the box and I needed to create such data type in my project when trying to define if a financial operation is an income or an outcome. Of course I could bypass this by creating an IsIncome column that stores a boolean value and later on check, if the value is false, then it means that it money where withdrawn. But what if I need to add another financial operation type? Like freezing an amount of money? I could add IsFreeze column of course, but it won't be the smartest way of designing databases.

 

The ideal solution for this would be creating something like MySQL provides, allowing only three values to be set in that column. We could of course create a char column and set it's value to the desired type programmatically, but again, there would be no control over the consistency of our data. Nothing prevents us from adding a random value there that is not in the set of allowed values. There is a solution to that by creating additional table, who's primary key would be of char type. We could use int type, but the problem with integers that later on the system becomes less maintainable and the data unreadable. That's why I recommend you to use a meaningful char as a key.

 

I'll try to reproduce the above MySQL example in SQL Server.

 

First of all, we should create a table that will hold our allowed values. In this case the values are the sizes:

 

CREATE TABLE cloth_size (
   size  char(6) NOT NULL,
   CONSTRAINT PK_Size primary key (size)
)
 

Next, we add three rows to our table:

 

INSERT INTO cloth_size ('small')
INSERT INTO cloth_size ('medium')
INSERT INTO cloth_size ('large')

 

Next we create the cloth table with a column named size and we reference it to the cloth_size table:

 

CREATE TABLE cloth (
    ...
   size CHAR(6)
    ...
   FOREIGN KEY (size) REFERENCES cloth_size(size)
);
 

And now we are allowed only to insert the three values that we've inserted into cloth_size table.

]]>
License plate injection 10/29/2009 2:39:14 PM http://karim.sentio-software.com/read/license-plate-injection Police in Wroclaw installed on-road monitoring cameras..

 

91779

 

. that recognize your car's license plate and warn you about your speed:

 

91781

 

("Zwolnij" in Polish means "slow down")

but some drivers decided to fuck the system:

 

dropdatabase

 

:)

]]>
Adding basic logic to WPF data binding 8/7/2009 2:17:31 AM http://karim.sentio-software.com/read/adding-basic-logic-to-wpf-data-binding Ever tried to bind a control to a data source in WPF? Usually the procedure looks this way: You use or create a control (let's say a ListView), create a data source and point the control to the data source.

But there are some circumstances when you need to add certain behavior to your control based on the data that it's bound to, like marking it red when the value is larger than certain value. .NET framework provides us with the DataTrigger trigerring mechanism, but the limitation of this mechanism is that it could only be triggered when the data is equal to a certain value. It cannot accept other comparisons. You could always do this in the code-behind of your UI, but this won't be a good practice in general (with some exceptions).

 

Now, what I want to create is a ListView, that will contain Label Controls in it's ListViewItem and when the value of the data item is larger than 100 I want to set the foreground to Red brush.

 

Let's start with a basic ListView:

        <ListView Name="listView">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Value1" />
                    <GridViewColumn Header="Value2" />
                </GridView>
            </ListView.View>
        </ListView>

 

Next, let's say that we want to bind to it a List of our custom classe

 

class OurCustomClass
{
    public int Value1 { get; set; }
    public string Value2 { get; set; }
}
 
List<OurCustomClass> data = new List<OurCustomClass>();
Random rand = new Random();
for(int i = 0; i < 100; i++)
    data.Add(new OurCustomClass {Value1 = rand.Next(1, 1000), Value2 = rand.Next(3000, 30000).ToString()});

:

listView.ItemsSource = data;

 

What .NET Framework enables us to do is adding a DataTrigger do a DataTemplate:

 

<ListView>
    <ListView.Resources>
        <DataTemplate x:Key="OurTemplate">
            <Label Name="val1Label" />
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=Value1}"  Value="SomeValue">
                    <Setter ... />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </ListView.Resources>
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Value1" />
            <GridViewColumn Header="Value2" />
        </GridView>
    </ListView.View>
</ListView>

 

Here as you see the DataTrigger checks if the bound data is equal to the value defined in the Value property, if yes, the trigger is fired and the setters alter the content and attributes of the item. But when we need to check, let's say, if the value is grater than 100 we have to use a small trick.

The binding mechanism provides something called Converter, it is used to convert the bound data to another type and the syntax for it is  Binding="{Binding Path=Value1, Converter=OurConverter}".

When there is a converter assigned to the bound data, they are first passed to it, converted and the comparison is done on the converted data and here we could trick the mechanism with a small hack, that works in a way, that it will convert the int to string. It will convert it to a string of "Hi" if it is higher than 100, or convert it to "Low" if lower. We could write it in a yet more elegant way in this particular example as we are having only two possible options (either it is bigger than 100 or not) so we could return a Boolean value.

In other situations, where there are several possible results of comparison and we should react to each of the results in a different way, a good idea is to create an enum.

 

Ahh, and I forgot to mention that the Converter class should implement the IValueConverter interface and should be added to the resources .

 

The code below illustrates how to set the color of the label in the items' template basing on the data value (the condition is that the value should be > 100):

 

First, the converter:

 

class OurConverter : IValueConverter
    {
        private int originalValue;
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            originalValue = (int)value;
            if (originalValue > 100)
                return true;
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return originalValue;
        }
    }

 

Next we add it to the resources:

 

<UserControl.Resources>
        <MyNamespace:OurConverter x:Key="outConverter" />
</UserControl.Resources>

 

Finally we add the converter to the binding and the final resulting XAML will be:

 

        <ListView>
            <ListView.Resources>
                <DataTemplate x:Key="OurTemplate">
                    <Label Name="val1Label" />
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=Value1, Converter={StaticResource ourConverter}}"  Value="True">
                            <Setter TargetName="val1Label" Property="Foreground" Value="Red" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Value1" CellTemplate="{StaticResource OurTemplate}" />
                    <GridViewColumn Header="Value2" />
                </GridView>
            </ListView.View>
        </ListView>

 

Enjoy!

]]>
Passing LINQ2SQL anonymous results among application layers in ASP.NET MVC 2/23/2009 9:32:55 PM http://karim.sentio-software.com/read/passing-linq2sql-anonymous-results-among-application-layers-in-asp-net-mvc Ever had a LINQ-to-SQL query that returns an anonymous type and you needed to pass the result of your query to the view? probably yes :)

Today I was faced with a problem that required me to query several table, extract the results from them and finally create a list of objects with nested values and all this should be passed to the view so that there I could iterate it and show a sensible results.

Let's first examine the tables I needed to query, here you have the schema containing the significant fields I'll need:

 

Table User Table TutorSubjects Table Subject Table Comment
Id: Guid TutorId: Guid Id: Guid TutorId: Guid
FirstName: string SubjectId: Guid Name: string Rating: int
LastName: string      
AboutMe: string      

These are the significant fields I required to get a list of Tutors along with their ratings and their subjects. The SQL query I wrote for it was:

   1:  SELECT T.Id,
   2:         T.FirstName, 
   3:         T.LastName, 
   4:         T2.Rating, 
   5:         TutorSubjects.Id, 
   6:        (SELECT [Subject].Name
   7:         FROM [Subject]
   8:         WHERE [Subject].Id = TutorSubjects.SubjectId) SubjectName,
   9:         T.AboutMe
  10:  FROM [User] T
  11:       LEFT OUTER JOIN (SELECT Tutor.Id, SUM(Comment.Rating) Rating
  12:                        FROM [User] Tutor, Comment
  13:                        WHERE Comment.TutorId = Tutor.Id AND Tutor.Type = 2
  14:                        GROUP BY Tutor.Id) T2
  15:             ON T.Id = T2.Id
  16:       LEFT OUTER JOIN TutorSubjects
  17:             ON TutorSubjects.TutorId = T.Id
  18:  WHERE T.Type = 2
  19:  ORDER BY T2.Rating DESC

Now, the application is based on ASP.NET MVC, and it uses LINQ-to-SQL orm. First of all, we should somehow execute this query using LINQ, we could do it in several ways. Either write a ninja-query joining multiple entities or as I did, create a view in the database that executes this query and import the view to linq2sql, so that we could use it as an entity. Our new view (and the new object ) is called TutorRatingWithSubjects.

 

In the code, when I query it, I want to have a structure that looks somehow like this:

aggregation1

So that when I'll pass the results to the view I could display them without any extra effort. I could accomplish it with the C# feature - anonymous types, but the problem in here is with passing it to the view.

 

   1:  var tutors = from tutor in db.TutorRatingWithSubjects
   2:               select new
   3:                          {
   4:                              tutor.Id,
   5:                              tutor.FirstName,
   6:                              tutor.LastName,
   7:                              tutor.Rating,
   8:                              tutor.AboutMe,
   9:                              Subjects = (from ts in db.TutorRatingWithSubjects
  10:                                          where ts.Id == tutor.Id
  11:                                          select new
  12:                                                     {
  13:                                                         ts.SubjectId,
  14:                                                         ts.SubjectName
  15:                                                     }
  16:                                         )
  17:                          };

When I'm passing it, the whole anonymous type get's up-casted to an object when it's stored in the ViewData. Here, the problem is that you are unable (directly) to reproduce the original anonymous type from the ViewData.

There are several ways to read data from a boxed anonymous type:

Using reflection

In the view you cast it to IQueryable and iterate through it:

    <ul>
    <%
        IQueryable tutors = (IQueryable) ViewData["Tutors"];
        foreach(object v in tutors) {
      %>
       <li> <%= v.GetType().InvokeMember("FirstName", System.Reflection.BindingFlags.GetProperty, null, v, null) %></li>
  <% } %>
    </ul>
Now, while this method works, I highly discourage it's usage, as using reflection is just cheating. It has weak performance, the code is less readable, etc...
There is a more elegant way to read the results of the linq query in our view.
Using strongly-typed list
We create a nested class that has the same properties as our anonymous type:
internal class TutorsWithSubjectsResult
{
    public Guid TutorId { get; set; }
    public String FirstName { get; set; }
    public String LastName { get; set; }
    public int? Rating { get; set; }
    public string AboutMe { get; set; }

    internal class Subject
    {
        public Guid? SubjectId { get; set; }
        public String SubjectName { get; set; }
    }

    public List<Subject> Subjects { get; set; }
}

 

Now we need to select the data with our linq into the TutorsWithSubjectsResult:

List<TutorsWithSubjectsResult> tutors = (from tutor in db.TutorRatingWithSubjects
                                         select new TutorsWithSubjectsResult
                                                    {
                                                        TutorId = tutor.Id,
                                                        FirstName = tutor.FirstName,
                                                        LastName = tutor.LastName,
                                                        Rating = tutor.Rating,
                                                        AboutMe = tutor.AboutMe,
                                                        Subjects = (from ts in db.TutorRatingWithSubjects
                                                                    where ts.Id == tutor.Id
                                                                    select
                                                                        new TutorsWithSubjectsResult.Subject
                                                                            {
                                                                                SubjectId = ts.SubjectId,
                                                                                SubjectName = ts.SubjectName
                                                                            }
                                                                   ).ToList()
                                                    }).ToList();
Voila! we have a strongly-typed list, that could be easily unboxed in the view, or if you create a strongly typed-view you would have a type that could be the type of the ViewData.
]]>
Sentio Platform at Eastcamp 2 10/29/2008 3:33:33 AM http://karim.sentio-software.com/read/sentio-platform-at-eastcamp-2 Today I've been informed about the plans regarding the second edition of eastcamp, which will probably take place on 22nd of November in the financial faculty's hall in Białystok. This date and place is chosen due to the fact that in these days Global Entrepreneurship Week will take place. This open great possibilities for technology-oriented minds to interact with business-oriented ones.

On the second edition of eastcamp, I'll be presenting my project - Sentio Platform - a grid computing platform based on .NET.

Sentio Platform is a platform that enables developers to develop applications that utilize the power of interconnected machines to leverage their potential in performing  massive and time-consuming tasks while cutting down costs by utilizing the unused computing power in each of the machines in the enterprise.

Now it's time to start preparing the presentation for the conference. Until now I've created the poster, maybe the outline will be in the same theme.

Poster 1

]]>
My playground, tagged. 10/29/2008 2:00:12 AM http://karim.sentio-software.com/read/my-playground--tagged- While browsing the Microsoft PDC2008 - related blogs and sites, my attention was caught by PDC08 “Azure” keynote word-cloud .

Although I'm a big enemy of tags, these particular ones impressed me. Especially the ones of my playground:

palyground_1

]]>
Grupa Certyfikacyjna - Wyklad II 10/28/2008 9:40:44 AM http://karim.sentio-software.com/read/grupa-certyfikacyjna---wyklad-ii Zamieszczam tu slajdy z drugiego wykłady grupy PB.NET na temat (System.IO).

 

Omawiane zagadnienia na tym wykładzie to:

1. Obsługa systemu plików.
2. Odczyt i zapis w plikach.
3. Kompresja danych strumieniowych.
4. Isolated Storage.

Slajdy:

Magda dostaje +5 do manny za korekte :)

]]>
Filters and pipes 10/28/2008 1:43:02 AM http://karim.sentio-software.com/read/filters-and-pipes Pipes and Filters is a design pattern that is responsible for moving the output of one system into another. This design pattern is useful when trying to connect two different systems with different web services schema or different formats. This often occurs during updating old software, so that the new one can use portions of the old one. Integrating such systems involve a whole series of transformations, like transforming XML-based service communications another XML format or Binary to XML based.

A solution for this problem is to implement a sequence of filter components, where filters transform the received messages and forward the to the next component. The interchanged data between filters and other components are transported through pipes.

When a system needs more than one filter, the pipes carry the data from the first filter to another until its fully transformed into a compatible format. Pipes also buffer the carried data until the target filter is ready to transform them. After applying all needed transformations, the pipe transfer the data to the targeted application which consumes it.

This pattern needs the output data to be compatible with the input of the next filer or application. In general the output of one component should be compatible with the input of the next component in row.

The picture below shows an example of using filers and pipes:

]]>
SOA: The Definition 10/28/2008 1:42:13 AM http://karim.sentio-software.com/read/service-oriented-architecture--the-definition I have decided to write a series of posts regarding the topic that recently became a hot one. I will write a series about Service Oriented Architecture (SOA), here you have the first part, which will introduce you to the concept of what is SOA…

First of all before diving into technical aspects of this topic, you should have an understanding of what Service Oriented Architecture is. Let’s take a look at your city. It is already full of service-oriented businesses. Individual companies are service-oriented in that each provides a distinct service that can be used by multiple customers. Collectively, these businesses comprise a business community. It makes sense for a business community not to be served by a single business outlet providing all services. By decomposing the community into specialized, individual outlets, we achieve an environment in which these outlets can be distributed.

When coupled with “architecture”, service-orientation takes on a technical connotation. “Service Oriented Architecture” is a term that represents a model in which automation logic is decomposed into smaller, distinct units of logic. Collectively, these units comprise a larger piece of business automation logic. Individually these units can be distributed.

Distributing automation logic into separate units is nothing new. What is it then that makes service-oriented separation so different? Keep on reading…

Even in a distributed business community, if we impose overbearing dependencies, we could inhabit the potential of individual businesses. Although we want to allow outlets to interact and leverage each other’s services, we want to avoid a model in which outlets from tight connections that result in constrictive inter-dependencies. By empowering business to self-govern their individual services, we allow them to evolve and grow relatively independent from each other.

Though we encourage independence within our business outlets, we must still ensure that they agree to adhere to certain business conventions – for example, a common currency for the exchange of goods and services, a building code that requires signage to confirm to certain parameters or perhaps a requirement that all employees speak the same language as the native consumers. These conventions standardize key aspects of each business for the benefit of the consumers without significantly imposing on the individual business’s ability to exercise self-governance.

Similarly, service oriented architecture (SOA) encourages individual units of logic to exist autonomously yet not isolated from each other. Units of logic are still required to conform to a set of principles that allow them to evolve independently, while still maintaining a sufficient amount of commonality and standardization. Within SOA, these units of logic are known as services.

]]>
Service Oriented Architecture: Common Characteristics 10/28/2008 1:41:17 AM http://karim.sentio-software.com/read/service-oriented-architecture--common-characteristics This is the second post in my series about Service Oriented Architecture. After defining what SOA is in my first post, I will discuss the common characteristics of service-oriented solutions:

 

SOA is fundamentally autonomous

The service-oriented principle of autonomy requires that individual services be as independent and self-contained as possible with respect to the control they maintain over their underlying logic. This is further realized through message-level autonomy where messages passed between services are sufficiently intelligence-heavy that they can control the manner in which they are processed by recipient service.

SOA builds upon and expands this principle by promoting the concepts of autonomy throughout solution environments and the enterprise. Applications comprised of autonomous services, for example, can themselves be viewed as composite, self-reliant services that exercise their own self-governance within service oriented integration environments.

 

SOA is based on open standards

Perhaps the most significant characteristic of Web Services is the fact that the data exchange is governed by open standards. After a message is sent from one Web Service to another it travels via a set of protocols that is globally standardized and accepted.

Further, the message itself is standardized, both in format and how it represents its payload. The use of SOAP, WSDL, XML and XML Schema allow for messages to be fully self-contained and support the underlying agreement that to communicate, services require nothing more than knowledge of each other’s service description. The use of open, standardized messaging model eliminates the need for the underlying service logic to share dependencies (such as type systems) and support the loosely coupled paradigm.

 

SOA supports vendor diversity

The open communications standards just explained not only has significant impact for bridging much of the heterogeneity within (and between) corporations, but it also allows organizations to choose best-of-breed environments for specific applications.

For example, regardless of how proprietary a development environment is, as long as it supports the creation of standard Web Services, it can be used to create a non-proprietary service interface layer, opening up interoperability opportunities with other, service capable applications. This, incidentally, has changed the face of integration architectures, which now can encapsulate legacy logic through service adapters, and leverage middleware advancements based on Web Services.

Organizations can certainly continue building solutions with existing development tools and server products. In fact, it may make sense to do so, only to continue leveraging the skill sets of in-house resources. This option is made possible by the open technology provided by Web Services framework and is made more attainable through the standardization and principles introduced by SOA.

 

SOA promotes discovery

Even though the first generation of Web Services standards included UDDI, few of the early implementations actually used service registries as part of their environments. This may have to do with the fact that not enough Web Services were actually built to warrant a registry. However, another likely reason is that the concept of service discovery was simply not designed into the architecture. When utilized within traditional distributed architectures, Web Services were more often employed to facilitate point-to-point solutions. Therefore, discovery was not a common concern.

SOA supports and encourages the advertisement and discovery of services throughout the enterprise and beyond. A serious SOA will likely rely on some form of service registry or directory to manage service descriptions.

 

SOA fosters intrinsic interoperability

Further leveraging and supporting the required usage of open standards, a vendor diverse environment, and the availability of a discovery mechanism, is the concept of intrinsic interoperability. Regardless of whether an application actually has immediate integration requirements, design principles can be applied to outfit services with characteristic that naturally promote interoperability.

When building a service-oriented application from the ground up, services with intrinsic interoperability become potential integration endpoints. When properly standardized, this leads to service-oriented integration architectures wherein solutions themselves alleviate the cost and effort of fulfilling future cross-application integration requirements, and evolves the enterprise into one where traditional application boundaries begin to disappear.

 

SOA fosters inherent reusability

SOA establishes an environment that promotes reuse on many levels. For example, services designed according to service-orientation principles are encouraged to promote reuse, even if no immediate reuse requirements exist. Collections of services that form service compositions can themselves be reused by larger compositions.

The emphasis placed by SOA on the creation of services that are agnostic to both the business process and the automation solutions that utilize them leads to an environment in which reuse is naturally realized as a side benefit to delivering services for a given project.

 

SOA emphasizes extensibility

When expressing encapsulated functionality through a service description, SOA encourages you to think beyond immediate, point-to-point communication requirements. When service logic is properly partitioned via an appropriate level of interface granularity, the scope of functionality offered by a service can sometimes be extended without breaking the established interface.

Extensibility is also a characteristic that is promoted throughout SOA as a whole. Extending entire solutions can be accomplished by adding services or by merging with other service-oriented applications (which also, effectively, “adds services). Because the loosely coupled relationship fostered among all services minimize inter-service dependencies, extending logic can be achieved with significantly less impact.

SOA implements layers of abstraction
One of the characteristics that tend to evolve naturally through the application of service-orientation design principles is that of abstraction. Typically SOAs can introduce layers of abstraction by positioning services as the sole access points to a variety of resources and processing logic.

When applied through proper design, abstraction can be targeted at business and application logic. For example, by establishing a layer of endpoints that represent entire solutions and technology platforms, all of the proprietary details associated with these environments disappear. The only remaining concern is the functionality offered via the service interfaces.

 

SOA is a building block

Service-oriented application architecture will likely be one of several within an organization committed to SOA as the standard architectural platform. Organizations standardized on SOA work toward an ideal known as the service-oriented enterprise (SOE), where all business processes are composed of and exist as services, both logically and physically.

When viewed in the context of SOE, the functionality boundary of an SOA represents a part of this future-state environment, either as a standalone unit of business automation or as a service encapsulating some or all of the business automation. In responding to business model-level changes, SOAs can be augmented to change to nature of their automation, or they can be pulled into service-oriented integration architectures that require the participation of multiple applications.

What this all boils down to is that an individual service-oriented application can, in its entirety, be represented by and modeled as a single service. There are no limits to the scope of service encapsulation. An SOA consists of services within services within services, to the point that a solution based on SOA itself is one of many services within SOE.

 

SOA is an evolution

SOA defines an architecture that is related to but still distinct from its predecessors. It differs from traditional client-server and distributed environments in that it is heavily influenced by the concepts and principles associated with service-orientation and Web Services. It is similar to previous platforms in that it preserves the successful characteristics of its predecessors and builds upon them with distinct design patterns and a new technology set.

For example, SOA supports and promotes reuse and encapsulation, as well as the componentization and distribution of application logic. These and other established design principles that are commonplace in traditional distributed environments are still very much part of SOA.

SOA is still maturing

While the characteristics described so far are fundamental to SOA, this point is obviously more of a subjective statement of where SOA is at the moment. Even though SOA is being positioned as the next standard application computing platform, this transition is not yet complete. Despite the fact that Web Services are being used to implement a great deal of application functionality, the support for a number of features necessary for enterprise-level computing is not yet fully available.

Standards organizations and major software vendors have produced many specifications to address a variety of supplementary extensions. Additionally, the next generation of development tools and application servers promises to support a great deal of these new technologies. When SOA platforms and tools reach an adequate level of maturity, the utilization of Web Services can be extended to support the creation of enterprise solutions, making the ideal of a service-oriented enterprise attainable.

If you need to provide an accurate definition of SOA today, you would not be out of line to mention the state of its underlying technology. Considering the rate at which the IT industry as a whole is adopting and evolving the SOA platform, though, it should not be too long before such a statement would no longer be required.

]]>
Message exchange patterns 10/28/2008 1:38:32 AM http://karim.sentio-software.com/read/message-exchange-patterns Every task automated by a Web Service can differ in both the nature of the application logic being executed and the role played by the service in the overall execution of the business task. Regardless of how complex a task is, almost all require the transmission of multiple messages. The challenge lies in coordinating these messages in a particular sequence so that the individual actions performed by the message are executed properly an in alignment with the overall business task.

Message exchange patterns (MEP) represent a set of templates that provide a group of already mapped out sequences for the exchange of messages. The most common example is a request and response pattern. Here the MEP states that upon successful delivery of a message from a service to another, the receiving service responds with a message back to the initial requestor.

The MEP currently in the second generation Web Services are divided into two categories: Primitive and Complex, in this post I will discuss the two most popular primitive MEPs:

 

Request-response

This is the most popular MEP in use among distributed application environments and the one pattern that defines synchronous communications (although this pattern also can be applied asynchronously).

The request-response MEP establishes a simple exchange in which a message is first transmitted from a source (service requestor) to a destination (service provider). Upon receiving the message, the destination (service provider) then responds with a message back to the source (service requestor).

 

Fire-and-forget

This simple asynchronous pattern is based on the unidirectional transmission of messages from a source to one or more destinations.

A number of variations of the fire-and-forget MEP exist, including:

- The single-destination pattern, where a source sends a message to one destination only.
- The multi-cast pattern, where a source sends message to a predefined set of destinations.
- The broadcast pattern, which is similar to the multi-cast pattern, except that the message is sent out to a boarder range of recipient destinations.

The fundamental characteristic of the fire-and-forget pattern is that a response to a transmitted message is not expected.

]]>