Architecture Blog 2008-06-06T05:20:22Z tag:,2008:/46 Movable Type Copyright (c) 2008, arnon Refactoring the GoF patterns (Singleton in .NET continued) 2008-06-06T05:20:22Z 2008-06-06T05:19:33Z tag:,2008:/46.34179 2008-06-06T05:19:33Z Reminder - please update your reader to the new blog home on Dobb's CodeTalk Among the reactions I got for my previous post on the Singleton pattern in .NET were a couple that talked about the design rationale behind the... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Reminder - please update your reader to the new blog home on Dobb's CodeTalk


Among the reactions I got for my previous post on the Singleton pattern in .NET were a couple that talked about the design rationale behind the solution I posted:

Adi Avnit posted on the risk of using a "generic singleton":

"However, there is one possible pitfall to this approach, as it makes this code possible:
Singleton obj = Singleton.Instance;
MyClass obj2 = new MyClass();

While I personally like the idea of having the freedom to use the same class in two different ways throughout the application, I know some people like their Singletons - well, single.
On the other hand, if you write a class from the start as a Singleton this is not an issue.

There is an inherit risk in decoupling a class from it's expected behavior, so take this into consideration before using this pattern."


And Cade Roux wrote in a comment:
"don't believe discoverability was a motivation for Singleton. The purpose was to ensure only one instance existed (a print spooler, a file system). You can get discoverability through the technique you explain but the primary purpose of singleton was a pattern of prohibition - to stop a programmer doing something they shouldn't do by accident by enforcing the primary goals of single point of access.

It is more than a global, and the OP, while comparing them to globals, does not acknowledge that this solves many of the problems which made "global" a 4-letter word. Knee-jerk reaction against globals is not healthy once you've mitigated their drawbacks.

It is true that usage of singleton can be misguided and cause coupling - which is why you need to ensure that the usage of the pattern matches the motivation in the first place.

This is a key point of design patterns which Alexander should have made clear in http://en.wikipedia.org/wiki/N...is_of_Form - the pattern is a result of a resolution of system of forces. It only satisfies that system - moving it to another different system will result in poor fitness. "

I guess that's a good opportunity  to talk about design issues regarding Design Patterns in general and the GoF ones in particular.

Aristotle Pagaltzis
noted (in a comment on Cedric's blog) that
"design patterns are a sign of a deficiency of a language for the purpose that the design pattern addresses. In other words, the Visitor pattern used in Java points to the fact that Java is deficient in terms of list processing: the `map` and `filter` constructs need to be emulated with lengthy OO incantations."
In other words Concrete patterns* (like GoF's) are tied to implementation which means that the implementation language is  part of their "context". Thus when you come to apply a pattern in a different language you need to consider the language in use and make sure that
  1. The pattern is needed
  2. The solution in the pattern is the best one for the language.
Let's look at a few examples.
If we take the Visitor pattern mentioned above - The intent of the visitor pattern is to "represent an operation to be performed on the elements of an object structure without changing the classes of the elements". In .NET 3.5 you can do that with the use of LINQ (to find relevant items) and extension methods (to add external functionality) - same intent, completely different implementation.

In the case of the Singleton pattern (mentioned in the previous post). The intent is to "Ensure a class only has one instance, and provide a global point of access to it". An implementation using templates (or generics) is superior since it provides the same intent but also adds better compliance with the Single Responsibility Principle. While it is possible to create the class as a non-singleton on the one hand it solves the multi-threading issue in one place preventing both duplication of code and mistakes (again this can be especially important in non-forgiving environments like C++). It also lets you (not in the implementation I provided) add flexibility and e.g. let singletons die and (if needed) resurrect themselves etc. Note that even if you are not convinced that using generics is better, there's no doubt that using .NET's thread-safe static readonly variable (public static readonly MySingleton = new MySingleton();)  is a much simpler solution than the GoF one and again, answers the original intent with a different solution.

Another example would be the Template method pattern. The idea behind the template method is to support the Open closed principle (classes should be open for extension but closed for modification) or as the GoF defines the intent:

"Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm strucuture"
.NET 3.5 supports the notion of Generic Delegates so you can define functions as parameters and pass them along. This is a better implementation than the template method as now you don't have to subclass when you want to extend an algorithm you can just pass a function that matches the signature
e.g.
    class Program
{
static void Main(string[] args)
{
var alg = new Algorithm();
alg.DoSomething(Funky);
}

static bool Funky(string value)
{
return value == "somevalue";
}
}


class Algorithm
{
public void DoSomething(Func<string,bool>CanGoForward)
{
string someVariable = "somevalue";

if (null!=CanGoForward && CanGoForward(someVariable))
{
//do one step
}
// whatever
}
}

You should note that this "refactoring to fit the language" phenomena isn't limited to GoF patterns (or .NET :)) , for instance you can consider the use (or lack thereof) of Dependency Injection in languages such as Ruby which I wrote about a few months ago.

To sum up - when you talk about design patterns you need to consider the implementation language, design pattern deal with deficiencies in the language and different languages have different deficiencies and may have better solutions to the problems solved by the patterns


* As opposed to architectural patterns which are more abstract and thus more reusable (e.g. Hohpe & Wolf Enterprise integration patterns, or Martin fowler Enterprise Architecture patterns)]]>
Software architecture document size 2008-05-19T21:28:31Z 2008-05-19T21:27:57Z tag:,2008:/46.33750 2008-05-19T21:27:57Z Reminder - please update your reader to the new blog home on Dobb's CodeTalk Simon @ CodingTheArchitcture recently asked "How big is your software architecture document? (and who reads this stuff anyway?)" He notes that in a UG meeting most... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Reminder - please update your reader to the new blog home on Dobb's CodeTalk

Simon @ CodingTheArchitcture recently asked "How big is your software architecture document? (and who reads this stuff anyway?)"
He notes that in a UG meeting most of the attendees has SADs that were more than 50 pages long.
It would probably not be too surprising if I say than in my opinion the answer is that it depends. Reflecting back on some of my past projects I had SADs that varied in range from a 200+ "write-only"* document to a less than 10 pages lean document. And the sizes match the intended usage of the documents. for instance in the two extremes mentioned. The first case it was a huge mission critical project with a specific requirement from the customer to have an "official" SAD and it was written to satisfy some project milestone (PDR) . Where the second extreme is an agile project where the architecture document was a working document, written some 10 iterations into the development to highlight some of the emergent guidelines.

What is common to all the SADs I wrote (or was responsible to) is that they all tried to grasp the essence of the design, all used multiple viewpoints to describe the solution, all were focused on quality attributes and all explained the rationale behind the decisions.

  • If you drone endlessly with details you don't see the forest from the trees.
  • if you don't use multiple views - you are likely to miss important aspects of the solution
  • if you aren't focused on quality attributes that you are most likely documenting design and not architecture
  • and if you don't explain the rationale then the document doesn't have a lot of added value beyond the code itself
in any event, the important thing here is that when it comes to Software Architecture Documents "size doesn't matter" :). What matters is that the SAD satisfies the reason it was written for


*While this particular SAD was rather long it also had a section that helped potential readers find relevant chapters so that it can actually be usable, and not just as a"door stopper"

]]>
Sleep tight, don't let the test bugs bite 2008-04-27T12:15:52Z 2008-04-27T12:13:54Z tag:,2008:/46.33169 2008-04-27T12:13:54Z Reminder - please update your reader to the new blog home on Dobb's CodeTalk A while ago I asked "who tests the test": " One question I don't hear asked too much is "who tests the tests?" - after all... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Reminder - please update your reader to the new blog home on Dobb's CodeTalk

A while ago I asked "who tests the test":

" One question I don't hear asked too much is "who tests the tests?" - after all we are writing all this additional code - if we write so many bugs in our production code that we need tests - what are the chances the test code is clean?"

]]> I would add that this is especially true considering that the same person that writes the code also writes its unit tests

One answer I had was making sure to keep the triad of tests->code->acceptance tests. so that each two test the third. This is especially good since, usually, the acceptance/integration tests are not written by the developer who wrote the code.

One answer I got was that tests are usually simple enough to be self evident and when tests contain complex constructs you should probably test them as well.

Basically, tests can have two types of problems

  • Not testing the right thing
  • Not testing the thing right
Code+unit tests +acceptance seem to take care of the first type of problems. The claim that tests are simple should take care of the second type of problems.
However I think that it isn't always true, especially when it comes to using the tests for regression. consider for example, the following two incidents I had  where the the problems were actually with the tests:

1. We have a component that interacts with resources in different URIs, so when resources wake up they register themselves with that component. Resources register two URIs -> one for control and one for interactions. We've added a business rule that both URIs should be on the same host (naturally a new test for that was also added but that not the point) suddenly a bunch of the old tests started failing. Sure enough, I took a look at the new code, found a bug, fixed it, but the tests were still in the  red. In the end it turned out one of the Uris that is registered during the tests had an extra "L" (locallhost instead of localhost) so the tests failed with the new rule - as they should..

2. After writing a piece of code to "just work" it had to be made multi-threaded. I needed to write a test that would make sure the component can handle multiple concurrent requests. Sure, I thought, I'll just run few or even all of the other tests in parallel and be done with it. The only problem was that the other tests were written to be isolated (i.e. new instance per test) running them in parallel had no effect what-so-ever.

What can we do to help us locate problems and bugs with tests?

  • remeber that Test code is code - so as you write more tests you should also refine the tests design and refactor the code accordingly. For instance in the first example above, it was easier to diagnose the problem since the faulty setup was done by a single method used by alll the failing  tests (Single Responsibility Principle @ the method level).
  • Test-First - One of the reasons test-first is beneficial is because you can actually see the test fail before you implement the code to make it work. This helps you make sure that the test actually tests the behavior you want. When the code is already in place it is harder to make sure if the test works because of the change or not. In the second example running all the tests in parallel everything was still green, which triggered me to write specific tests for checking for multi-threading issues.
What do you do?


]]>
SOA - Between philosophy and concrete answers 2008-04-22T09:28:00Z 2008-04-22T09:23:10Z tag:,2008:/46.33029 2008-04-22T09:23:10Z Reminder - please update your reader to the new blog home on Dobb's CodeTalk Someone calling himself r r left the following comment on part IV of my series of posts on SOA definition: "I keep trying to read this... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Reminder - please update your reader to the new blog home on Dobb's CodeTalk

Someone calling himself r r left the following comment on part IV of my series of posts on SOA definition:

"I keep trying to read this series on SOA unfortunately suffers from the same disease as the rest of literature on the subject. stays general to a comfortable level so it can't really be applied anywhere, tends to complicate things where is not clear if it's needed, and encourages philosophical debate on what ultimately is a business (and so concrete) requirement. Meanwhile the serious (IMO) issues stay untouched - how does one actually approach an integration project with functionality, performance and security in mind. Which should be the standards used (considering the tens of standards on WS out there). How granular should the WS be (I'm done with answers like "not too much, but enough", or "well, depends on your project"). "
Before I talk a little about the "serious issues" mentioned above - I want to point out that the point of this series of post, as stated in the first post is to take a formal / semi-academic look at SOA. I started these posts as a reaction to a comment that Pete Lacey left on my blog stating that my view of SOA (as published in "What is SOA anyway?") does not demonstrate that SOA is an  architectural style. I don't pretense that this is some fully thought out academic dissertation or anything but I do try to look at the architectural roots of SOA.

That said let's take a look at the more interesting parts of this comment. First, the thing that bothers me about this reaction is (what seems to me as) the quest for final and concrete recipes. For instance consider the comment on service granularity

"How granular should the WS be (I'm done with answers like "not too much, but enough", or "well, depends on your project"")
The problems is - it does depend! and if you forgive me taking another philosophical detour, if you try to provide a hard definition for a service granularity you get  something like the heap paradox - When you remove individual grains  from a heap of sand is it still a heap when one grain remains. So while it is obvious that hiding a complete system as a single service is wrong and that exposing every little object as a service is wrong (even though for some inexplicable reason Juval lowy seems to thing that the latter is good practice) it isn't really obvious when you get too granular.

Nevertheless it is not a pure guess either. You can use some guidelines and measure them against your specific project/system/enterprise needs. Personally The set of guidelines I use is based on the fallacies of distributed computing :

  1.  The network is reliable
  2.  Latency is zero
  3.  Bandwidth is infinite
  4.  The network is secure
  5.  Topology doesn't change
  6.  There is one administrator
  7.  Transport cost is zero
  8.  The network is homogeneous
Since a service edge is boundary which may (usually is ) be accessed remotely you need to think about the incoming and outgoing interactions of the service within the fallacies stated above. if the proper behavior of the service depends on one of the above there's probably something wrong.

Regarding the other questions (how do you approach a real system), well, if you pardon me for banging my own drum, that's exactly why I started to write my experience on these matters as patterns. for instance if we look at the saga pattern (one of the patters I published online). you'd see that it is talking about achieving distributed consensus in a transaction-like manner. I talk about the problems of using distributed transaction etc., offer an architectural solution (the saga ) and then discuss relevant technology issues (e.g. WS-BusinessActivity ) as well as its implication from quality attributes perspectives (Integrity and reliability). Nevertheless even these patterns aren't an end-all solution. different circumstances require different solutions
Both my previous job and my current one involves building a scalable solution on-top of algorithmic engines. In my previous job I  managed the construction of a biometric solution that allows using multiple biometrics. In my current job I manage the development of  a mobile visual search solution . Again, while on the surface both needs to get some data, run a few  algorithms and produce an answer. These systems have very different quality attributes. On the first system we had to handle very large databases, hundreds of queries, an emphasis on modifiability and security, the current one needs millions of queries, almost no database, low latencies and emphasis on usability.  These differences result in radically different solutions, with different services, different interactions , use of different patterns etc. There's no "one right answer" (tm)

]]>
Singleton in .NET 2008-04-05T20:06:31Z 2008-04-05T20:05:45Z tag:,2008:/46.32609 2008-04-05T20:05:45Z While I personally don't like the Singleton pattern too much (it is essentially an OO mask for Global Variables, it makes it harder to unit test etc.), I still need to use them now and then. Anyway, I saw a... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog While I personally don't like the Singleton pattern too much (it is essentially an OO mask for Global Variables, it makes it harder to unit test etc.), I still need to use them now and then. Anyway, I saw a post by Jack Altiere about "Using the Singleton Pattern" in .NET and since it presents an implementation that leaves a lot to be desired I decided to comment on that

]]>
For one, he presents a solution which locks every time the singleton is accessed (see below). The reason this is flawed is that singletons are instantiated once, but they are accessed a lot of times and with this implementation you pay every time you try to access the singleton

//bad implementation - don't use
//also note some initialization etc. is omitted for brevity
public static Foo Instance
{
get
{
// This lock allows thread safety.
lock (_mutex)
{
if (_instance == null)
_instance = new Foo();
return _instance;
}
}
}

There's a better "standard" way to do that which basically means you check if the the instance is null, lock, check again (in case more than one thread got past the first check ) and only then instantiate (you'd also need to mark the instance volatile in this case)
.NET has a better way to create thread safe singletons by merely using a static readonly declaration as in:
public  sealed class singleton
{
public static readonly MySigleton Instance = new MySingleton()
}

This implementation is not as lazy as the implementations above - but it is thread safe an efficient (you can get more laziness if you use a nested class as described here)

But that's not all- see, one of the problems of the Singleton pattern (besides the ones mentioned above) is that it is also a violation of the Single Responsibility Principle (SRP see OO primer). You can solve this problem if you use Generics and create something like C++'s template based Singleton class:

namespace ConsoleApplication5
{
class Singleton<T> where T : new()
{
private static readonly T inst = new T();

public static T Instance
{
get { return inst; }
}
}
}


and then use that simply by doing something like Singleton<MyClass>.Instance
[update]
Eran points out that Jack's code is not only inefficient but also not thread safe (see Eran's post on the subject) - basically you need to make the instance variable volatile just like in the double check scenario

Reshef points to the "Static Gateway Pattern" as an alternate  way to get the singleton effect. While we are talking about other possibilities, I should have probably mentioned that the usual way I handle situation where I need a single instance is instantiating one instance on the main/loader thread and then just using dependency injection... :)


]]>
Sticky notes vs. the computer 2008-04-02T20:24:23Z 2008-04-02T20:23:17Z tag:,2008:/46.32529 2008-04-02T20:23:17Z arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog I never really understood would I want to use sticky notes/cards  in my agile projects rather than use a software tools. After all we write software for others - how can we say that software is not a good enough solution for us ?
For instance, in our team we use Mingle by Thoughtworks. I think it is one of the best tools for project management I've ever used.  Its serves us well for sprint planning, daily scrums etc. Among other things it gives you "digital" sticky notes which you can drag around to move between statuses or whatnot - just perfect.

And yet, last week when we were pushing for completing our first major milestone I decided to try real sticky notes, and finally I understood the difference - constant visibility. Computerized tasks seem to be just as accessible as physical cards but in fact they aren't. Yes, everyone can see the status whenever they want. But the fact that you can doesn't mean that you do. Digital cards don't have the "in-your-face" kind of effect that always visible notes has. I've seen a notable  difference in maintaining the dev team's focus and making managers (the CEO in my case) feel they are in the loop and that progress is constantly made.
My conclusion is clear. While I still use electronic tools, I guess, until we'd have large enough e-ink boards to allow us to get the same effect physicals cards give us I'll just have to keep restocking my sticky notes inventory :)


]]>
Defining SOA - Part IV - Pipes and Filters 2008-03-31T16:17:23Z 2008-03-31T16:17:00Z tag:,2008:/46.32407 2008-03-31T16:17:00Z This post is part of a series of posts trying to define SOA as an architectural style. In the previous post I talked about SOA and the Layered architecture style (which generated a couple of follow-ups - one on layered... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog This post is part of a series of posts trying to define SOA as an architectural style. In the previous post I talked about SOA and the Layered architecture style (which generated a couple of follow-ups - one on layered architecture in general, one on its importance for SOA and on on layers in enterprise architecture vs. solution architecture)

The next architectural style SOA builds on is Pipes and Filters, Unlike Layers and Client/server which I described in previous installments, Pipes and Filter is not also a base style for REST. This basically, this style is where SOA and REST begin to diverge.
The pipes and filters architectural style defines two types of components - yep you've guessed it, Pipes and Filters.

Filters -  are independent processing steps they are constrained to be autonomous of each other and not share state, control thread etc.
Pipes - are interconnecting channels


Each filter exposes a relatively simple interface where it can receive  messages on an inbound pipe, process tthem and produce  messages on outbound pipes. The idea behind this is to allow easy composability thus allowing greater usage (also known as "reuse" - I'll discuss the difference in another post). Systems are composed of several filters working together, filters can be replaced with newer version (provided they keep the same interface) etc.
On the downside the overall latency is increased , since to accomplish a task you have to move from filter to filter.

The pipes and filters style brings to SOA things like the autonomy of services, the sense of explicit boundaries. For instance, this is the basis for why you wouldn't want to do distributed transactions across service boundaries, which I blogged about several times before.

The pipes part of the "pipes and filters" also means that the wiring can be taken care of outside of the services themselves and that you can control them externally, this works well with ithe use of middleware (service bus). Additionally Fielding (you know, the REST guy) also mentions that

"One aspect of PF styles that is rarely mentioned is that there is an implied "invisible hand" that arranges the configuration of filters in order to establish the overall application. A network of filters is typically arranged just prior to each activation, allowing the application to specify the configuration of filter components based on the task at hand and the nature of the data streams (configurability). This controller function is considered a separate operational phase of the system, and hence a separate architecture, even though one cannot exist without the other."
Which is the harbinger of the orchestration/choreography aspects of SOA.

So as you see, pipes and filters is one of the important pilars of SOA, in the next part (unless I'll have to clarify things about this post) I'll talk about the last architectural style SOA builds upon "Distributed Agents".

]]>
RESTful Windows Communication Foundation (WCF) 2008-03-29T20:43:23Z 2008-03-29T20:40:24Z tag:,2008:/46.32377 2008-03-29T20:40:24Z If you recall what I currently work on is a type of a visual search engine. In a nutshell when we get a request (image) we allocate a bunch of algorithmic engines in a grid like manner to process the... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog If you recall what I currently work on is a type of a visual search engine. In a nutshell when we get a request (image) we allocate a bunch of algorithmic engines in a grid like manner to process the image  (e.g. try to perform OCR or whatever). As it happens, we are developing the different components using several different environments(*) - e.g. the control bits run on windows (.NET) and most algorithms run on Linux (mostly C++).
The need for easy cross-platform communications and extensibility, the resource nature of the solution and a few other tidbits led us to design our solution in a RESTful manner.

If you are a .NET developer/architect and wanted you may know that to implement a RESTful application in Windows Communication Foundation (WCF) you really have to jump through hoops.For instance  you have to go back to basics and use the HttpRequest and HttpResponse, handle the breakdown and parsing of URI hierarchies yourself not to mention  fight  with the  bindings .

Fortunetly this all changed with WCF 3.5. True, .Net doesn't have (to my knowledge anyway) something like RESTlets, but at least building REST on http is pretty straightforward...

]]> Consider for example the following excerpt:

    [ServiceContract(Namespace = "http://paperlnx.Contracts/2007/12", Name = "ISessions")]
    public interface ISessions
    {
        [OperationContract]
        [WebGet(UriTemplate = "/Sessions/{sessionId}")]
        [ServiceKnownType(typeof(Atom10FeedFormatter))]
        SyndicationFeedFormatter ListSessionStatus(string sessionId);
	.
	.
	.
With these 6 lines of code you see the essence of  the .NET 3.5 REST goodies
  1. Integrated support for HTTP verbs  - The sample above shows the support for GET. You can get the other verbs almost as easy with the WebInvoke Attribute. To do that simply specify the verb you want e.g.   [WebInvoke(Method = "PUT")] , [WebInvoke(Method="DELETE")] etc.
  2. Support for URI templates -  In a way not too far from Joe Gregorio's IETF draft , WCF supports the notion of providing a way to describe families of URIs. This is done using the UriTemplate class. The WebGet and WebInvoke attributes also accept URI templates as variables and map the variable values (the curly brackets ones {}) to parameters of methods.
  3. Support for standard  formats - you can use plain XML or you can choose to use RSS and ATOM syndication formats. In its most basic form you just create a syndicationfeed and format it to atom feed. Which is what we do for error messages:
            public static SyndicationFeedFormatter GenerateAtomError(string errormessage, string description,Uri location)
            {
                SyndicationFeed feed = new SyndicationFeed(errormessage, description, location);
                return new Atom10FeedFormatter(feed);
            }
    
    Naturally you can also add items and element extensions to all elements (e.g. the feed or items)
All in all, I am a happy camper :) After all, when you make an architectural decision, you always need to review it once you opted for an underlying technology. Even when a decision is right. The friction caused by a  technology which doesn't accommodate it well can both make your life miserable and make a good decision bad. .NET 3.5 with its newly added support for REST increases the architectural freedom and that's always a good thing




* Among other things, it helps us avoid the "Network is homogeneous" fallacy - but that's another story :)


]]>
Dobb's Code talk 2008-03-29T20:39:53Z 2008-03-29T20:35:33Z tag:,2008:/46.32376 2008-03-29T20:35:33Z Dr. Dobb's launched a new forums/blogs platform called Dobb's Codetalk I was told that posting there would automatically post here as well but it seems this is not the case. First note that you can now find my blog there... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Dr. Dobb's launched a new forums/blogs platform called Dobb's Codetalk
I was told that posting there would automatically post here as well but it seems this is not the case.
First note that you can now find my blog there
Also I'll manually post the posts I've made there (following this post)

]]>
Layers/Tiers: One More Time 2008-03-14T19:45:14Z 2008-03-06T19:46:12Z tag:,2008:/46.31082 2008-03-06T19:46:12Z Jack Van Hoof has a different view than I regarding the difference between Tiers and Layers.... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Jack Van Hoof has a different view than I regarding the difference between Tiers and Layers.

]]> I am not sure I agree with his view, but it still provides an interesting read. I think the main difference between our respective views is that Jack takes a look from the enterprise-architecture angle which gives him layers like:

  • Technical infrastructure; OS, directory Services etc.
  • Application infrastructure; Apps, Portals, DBMSs
  • Application Landscape; SOA, EDA
  • Bushiness Processes; BPM

Jack uses the term "tier" for layers within the same level of abstraction. For instance, he gives the following examples:

E.g. the layer of business services may be arranged in the tiers: front-office, mid-office and back-office. At the next lower layer, the application layer, services may be arranged in the tiers: UI, business logic and data persistency. The interaction of services between two tiers may be bidirectional (but may also be constrained to unidirectional).
The perspective I have (or at least try to maintain in this blog) is the solution/product line architecture -- basically living within Jack's application layers. So in my view I want to know and differentiate between the difference of having a UI and business logic live on the same machine vs. having them distributed in the world. So I guess in the end both perspectives need to have their place and the problem is (like often is the case) overloaded terms. ]]>
SOA Patterns Book: Status Update 2008-03-05T14:40:36Z 2008-03-04T05:08:28Z tag:,2008:/46.30989 2008-03-04T05:08:28Z Great news. Two of my friends and fellow Dr. Dobb's bloggers, Eric Bruno and Udi Dahan, are participating in my (now "our's") SOA Patterns book, which will be published by Manning.... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Great news. Two of my friends and fellow Dr. Dobb's bloggers, Eric Bruno and Udi Dahan, are participating in my (now "our's") SOA Patterns book, which will be published by Manning.

]]> Both Udi and Eric are competent and experienced architects in designing SOAs . On the technology side, Udi ("The software simplest") specializes in .NET development; e.g., his nServiceBus framework is a very good example of an endpoint-ware ServiceBus (vs. middleware ServiceBuses which is what most ESBs do). For his part, Eric is a Java and C++ expert and author of Java Messaging (one of the best books on JMS and web services ) and has also has lots of experience in financial systems. Together, the three of us bring a
lot of real-life experience of building large and complicated system into this project.

The current game plan is for Eric to focus on the SOA pitfalls ("anti-patterns") part of the book, Udi to provide a "putting-it-all-together" chapter , and for me to cover what’s left. I am sure however, that their experience and insight will also help make the other parts of the book (even? ) better.

If you are not familiar with the book, you may want to take a look at the first chapter and/or some of the published patterns like Saga, Service Firewall, Gridable Service, Edge Component and (a very early draft of) Aggregated Reporting pattern. Also you can take a look at the slides from my "SOA Patterns" presentation at Dr. Dobb's Architecture & Design world last year, which illustrates some additional patterns.


]]>
Layers and SOA 2008-02-27T13:58:36Z 2008-02-26T20:32:48Z tag:,2008:/46.30773 2008-02-26T20:32:48Z I've been a little quiet, what with a visit to Barcelona (GSM World Congress), and then some pressure at work (making up for the lost time :) ). Hopefully I can now get back to regular blogging.... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog I've been a little quiet, what with a visit to Barcelona (GSM World Congress), and then some pressure at work (making up for the lost time :) ). Hopefully I can now get back to regular blogging.

]]> In the previous post, I mentioned a couple of questions on SOA and layers Udi left on an older post I made:

1. How does this [layers - ARGO] play with two services talking with each other? One pubs to the other's subs?The other requests to the first's response?

2. How valuable is the layered abstraction?

1. As I explained in the previous post. Layers does not necessarily mean unidirectional relation from a top layer to a lower level one -- it does mean that a layer can only know a layer that is diretly above or below
it. In other words, the bidirectional interaction between two services -- i.e., the request, reactions, events, etc. flowing between them -- do not violate the layered style constraints.

2. So, how valuable is the layered abstraction to SOA? The short answer is -- very :). Again, as I mentioned in the previous post, the main reason layers don't seem that valuable is because they've been misrepresented and misused. Layers bring added flexibility to SOA. The fact that a service or any other SOA component cannot see beyond the next layer enables things like the ServiceBus, Edge Component, Service Firewall, etc. Without layers it would be harder to have autonomous services as other services could (potentially) have access to the innards of the
service adding more coupling and preventing independence.


]]>
The Layered Architecture Style 2008-02-08T15:42:09Z 2008-02-08T06:27:10Z tag:,2008:/46.30223 2008-02-08T06:27:10Z Following the third part of my "Defining SOA" posts, Udi Dahan asked the following questions:... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Following the third part of my "Defining SOA" posts, Udi Dahan asked the following questions:

]]> How does this [layers - ARGO] play with two services talking with each other? One pubs to the other's subs?The other requests to the first's response? How valuable is the layered abstraction?

Udi and I usually see things eye-to-eye. So I guess that if I managed to get him confused, more clarification is warranted :) I'll do that in two posts, this one which will explain the concept of layers and the next which will explain why it is paramount to SOA (and answer the two questions).

Usually when I review an architecture, one of the first (sometimes the only) architectural artifacts I am shown is a "layered diagram" of the architecture; e.g., something like the following:

These sort of half layers/half block diagrams with or without the common three layers (which also appear in the diagram above) of "UI" "Business" and "Data" give the whole idea of layers a bad name.

The key differentiator between layers and just a bunch of blocks is the limitations on the allowed communication paths between the components (layers vs. blocks). In the previous post I quoted an old (2005) definition I had for layers where I said the following:

Typically a layered is allowed to call only the layer below it and be called only by the layer above it (but there are variants e.g., a layer can call to any layer below it; vertical layers that can call multiple layers; etc. -- all is fine as long as the layers communication paths are limited by some rules).

Alas, I was too quick on the copy/past and everything in the brackets (bold) is wrong -- it should actually say -- "but there's another variant where layers are allowed to call the layer above it or below it". The other variants (like a layer that can all any below it) just muddy the water, makes it hard to distinguish between layers and regular components and thus make layers seem unimportant. consider the following diagram:

So, in the above diagram, the relations are the Component D and Component C know each other. Component D is made of two layers (A and B). Note that a more proper representation should also explain the relations allowed between the layers, i.e., is it unidirectional or bidirectional (unless there's a common convention in the project).

Why is the distinction between layers and other type of components important? Because Layering gives you some benefits which "just components" don't:

  1. Layers allow information hiding. Since we don't know the inner working of what's beyond the layer.
  2. Layers allow separation. Things beyond the immediate layer are hidden from each other. This means that things which are beyond the layers are loosely coupled in a way that allows for flexibility and the addition of capabilities. for instance adding a firewall between your computer and the Internet.
  3. Layers allows changing the abstraction level. Since layers are hierarchical in nature, moving through the layer "stack" you can increase or decrease the level of abstraction you use. This allows expressing complex ideas with simple building blocks. The best known example for this is the TCP/IP stack moving from an abstraction level close to the hardware of the network interface layer to the application level protocols such as HTTP.

On the downside, layers hurt performance by adding latency. Also, too many layers introduce added complexity to the overall solution (e.g., it is harder to debug).

It it interesting to note that Interfaces are in fact leaky layer abstractions (versus, for example, SOA contracts which are not leaky), since when you use an interface you still need to instantiate the object which is otherwise hidden behind the "layer" (interface). This is basically the reason we want something like dependency injection (DI) -- to help make the abstraction complete and why languages like Ruby where the contract abstraction is complete - you don't need DI (I discussed Ruby and DI in another post)

Another issue which I mentioned here is the difference between logical layers and physical (or potentially physical) layers. I usually call the first kind layers and the latter tiers. logical layers are local and can assume a lot about their neighboring layers. Tiers or physical layers can be distributed, which carries a lot of implications (something I discussed here recently in relation to Microsoft Volta).

]]>
Microhoo or Yahoosoft? 2008-02-04T01:35:52Z 2008-02-03T20:54:39Z tag:,2008:/46.30105 2008-02-03T20:54:39Z Unless you've been living under a rock, you've probably heard about the Microsoft offer to acquire Yahoo. While it is Microsoft who is poised to acquire Yahoo (Microhoo?), it seems that it is part of the greater move of Microsoft... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog Unless you've been living under a rock, you've probably heard about the Microsoft offer to acquire Yahoo. While it is Microsoft who is poised to acquire Yahoo (Microhoo?), it seems that it is part of the greater move of Microsoft towards moving into Internet-based service -- all the "live" initiatives along with the "Software + Services" moniker.

]]> I tend to agree with Nicholas Carr who published an article in the Financial Times in which he talks about how Bill Gates leaving Microsoft marks the end of the desktop era. In fact, looking for the above mentioned reference I saw another article Carr wrote for Forbes where he says it even more bluntly:

One important message is this: Software is becoming a media business. The Net is not only a universal medium, a distribution channel for words, sounds and images. It is also turning into a universal computer -- the machine we use to run software and store data.

You might also want to check out a presentation a few of my colleagues and myself prepared about half a year ago where we talked about the same phenomena; see Future of Home Computing (5.5Mb).

In this sense the Microsoft-Yahoo merger (if it will follow through) will result in a company which is focused more on the Internet aspects (Yahoosoft?) rather than the more traditional (some would say legacy) desktop aspects of Microsoft.

It is also interesting to note in this sense that while winning the web search (and the related ad-revenue) is something Microsoft is very interested in. The eyes of Microsoft (and Google for that matter) are on the next battlefield -- mobile search. While there are something like 305 million broadband subscribers worldwide, the number of mobile phones sold just in the last quarter of 2007 -- 334 million -- is far greater, and the total of mobile phones worldwide is in the billions. An added bonus here is that Google is yet to take over this market (al though it is moving in that direction with things like the Android platform and location-based search and services).


]]>
MapReduce II 2008-02-01T13:53:14Z 2008-02-01T20:55:45Z tag:,2008:/46.29878 2008-02-01T20:55:45Z David J. DeWitt and Michael Stonebraker are at it again. There was a lot of buzz on the Internet after their previous post. (Here is what I had to say about it).... arnon https://i.cmpnet.com/ddj/images/headshots/arnon.jpg arnon@rgoarchitects.com Freelancer Blog David J. DeWitt and Michael Stonebraker are at it again. There was a lot of buzz on the Internet after their previous post. (Here is what I had to say about it).

]]> Their first point on the new post tries to counter the claim that MapReduce is not a database so it shouldn't be judged as one. They claim that it isn't a matter of apples and oranges, but rather:

We are judging two approaches to analyzing massive amounts of information, even for less structured information.

The problem with that from there they continue to define a problem in database terms, then show how MapReduce will not be as good as a database in solving it. Well, duh.

The fact that isolated queries may run better in a pre-indexed database should come as no great surprise. As I noted in the previous post on the subject, MapReduce can be used to create the appropriate index or
partition the data into smaller chunks that would be easier to use to answer the type of queries David and Michael mention.

As Mark Chu-Carroll explains Map/Reduce and databases don't solve the same kind of problems.

Also what happens when the database is constantly updated?! I don't mind how scientifically accurate are the measurements that say database scale like no other things. I am more comfortable with the empiric
experience by companies like Amazon, Diggs, Google , and eBay who found they have to shard their data to support their scalability needs and not use distributed transactions/distributed databases.

]]>