November 2005 - Posts

Applications and Solutions 2: The best architecture

What is the best architecture? It really is a silly question, especially when asked completely out of context. Yet, for some reason many in our industry feel a need to discuss architecture as if on a quest for the best architecture as a singularity; almost as if architecture itself was a concrete object that could be created and given from one person to another. I think there are some that hope once the best architecture is defined, they will be able to give it to the masses (for a nominal hidden fee), as if it was a thing, and say "here, behold the best architecture, use it to build truly excellent system. Your systems will taste great and be less filling!"

It is well known that our industry tends to be very trendy. If you are trying to sell a software solution today, and you aren’t using today’s buzzwords in your marketing it becomes a difficult sales job. The decision makers (who ultimately choose to buy software products) are just as caught up in the trends as the people building the software. For example:

  • prospective client: "Are you using SCNA (Some Cool New Architecture)"
  • software development firm: "Yes, we are leaders in SCNA"
  • prospective client: "Good! Because we have a commitment going forward to only purchase software which adheres to the core principals of SCNA"
  • software development firm: "Great! We are the man when it comes SCNA"
  • software development firm to newly contracted consultants: "We need you to put an SCNA wrapper around our YCNA (Yesterday’s Cool New Architecture)"

The general reason for most of this is people getting all caught up in "What is the best architecture" instead of architecting the right solution.

Putting a wrapper around something is an abstraction, and it’s a fundamental software engineering practice. There is nothing wrong with making one thing adapt to another via some level of abstractions. The abstractions alone don’t describe an overall architecture but may allow things built with different objects, components, services, architectural styles, platforms, etc. to all get along. The satire above is not an attempt to be cynical about abstractions, just nonsensical approaches towards architectural decisions.

Architecture has obviously been around a lot longer then software development. A quick search on its definition returns 1) "The art or science of building". I’m sure there are many more complicated definitions then these to be found in architecture textbooks. It is interesting to note that even in the results of the dictionary definition there is an adaptation for the computer generation in definition 5) "The manner in which the components of a computer or computer system are organized and integrated" The commonality that I take from this, is that we are talking about the art, science and manner of building, organizing and integrating stuff. So architecture is an abstract noun and not a concrete noun. I don’t think person A can give person B an architecture, and say here, go use this, any more then person A can give person B an art, science or manner. Yes, there are certain styles of architecture that can be identified, and these styles can be applied to the art or science of new buildings or the manner in which computer system components are integrated. We can look at a finished building and see traces of one architectural style or another, just as we can look at a software solution and see traces of one architectural style or another. Additionally, as we look at buildings erected during specific time periods and geographical locations we can see common traces of certain art and science styles and we can identify these commonalities as an "Architectural Style". Similarly, we can look out at our relatively short history of software engineering and see repeatable styles of manner in which computer systems are organized and integrated.

Let’s not confuse software architecture, with software frameworks. Because, there are indeed frameworks that are real things that person A can give person B and say here, go use this to build a system. These frameworks can be designed and built with an architectural style in mind and they can promote and enhance the use one particular style over another. However, even frameworks do not guarantee that an overall solution will be organized and integrated in the manner of the style intended by the creator of the framework. Using a framework can drastically reduce the amount of plumbing code required to organize and integrate the parts of an overall computer system solution associated with a particular style or manner; but just can’t guarantee that the end result will be considered by all observers to be strictly speaking "of a particular manner" or architecture style. So architecture is an abstract noun in the sense that it is the art, science and manner of constructing things. But, its not a concrete noun like rocks, dogs and trees.

When one sets out to erect a building, usually one employs the talents of a building architect. I really don’t know anything about true building architecture save what any common person learns by observing things. However, when constructing a building, I imagine there are some common questions asked about the building’s purpose; is it a bank, a house, a church, a factory, a castle, a hotel, a whole town or village, etc.? I would imagine there are some environmental climate questions; is it in a cold climate, tropical climate, or dessert? I would imagine there are some environmental geography questions; is it on a mountainside, is it by the ocean, is it by a river, is it part of some larger preexisting complex? Does the client have a particularly favorite time period or style; such as Gothic, Roman, Victorian, 21’st Century Modern, High Tech? I would imagine that by asking these questions the architect would start to get a feel for the best type of building materials; brick, steel, wood, concrete, glass, etc. I would imagine the architect would start thinking about some common building elements; columns, stairways, domes, arches, etc. I imagine the architect might start thinking about how to best integrate some environmental resources; like daylight, hillsides, or local rock formations. Additionally, I would imagine that the individual architect is going to have some special uniqueness and artistic abilities that set them apart from other architects.

There are so many combinations of things that seldom do two building structures end up identical unless it is purposely a cookie cutter design choice. Additionally, it’s almost impossible to say what the best architecture is. From a technical point, when erecting a building, the best architecture might be the one that best integrates all these various interest (environmental contexts, styles, purposes) into a common structure. But with building architecture, there is also an aesthetic component, and the aesthetic component can sometimes be more about art and expression. In the end, I don’t know if it so much a quest for the best architecture, as it is a quest for the right architecture.

It seems to me that in some respect software architecture should be more similar. How can we talk about what the best architecture is, if that talk transcends a given project, application or solution?

Already in the relatively short life of software architecture there are various identifiable architectural styles, time periods, building elements, and reusable patterns. Our goal as software architects should be to draw upon these learned and proven things and apply our knowledge and unique abilities to architect the right solution. The quest for the best architecture, when it transcends a given project or problem domain, can often cloud our judgments. It becomes difficult to architect the right solution, if you enter a project or problem with what you believe to be the best architecture before you’ve even started.

Similar to a building architect, we should be asking many questions. What type of application is this? Is it a game, a hardware driver, a business automation system, a data entry / data collection system, a business service, or an enterprise solution that might be made up of a bunch of business applications? Who will use the solution and how? How will the solution or the applications in the solution interact with the environment; i.e. what type of other cooperating systems, databases, file storage, networks, etc. will there be interaction. What system quality metrics will be the most important; security, performance, scalability, availability, usability etc.? Additionally the architect should be thinking about how this solution may evolve in the future and what type of minimal extensibility needs to be core to the design.

Does this mean that it is wrong to talk about and dissect architectural styles outside the scope of a specific project, application or solution? No. Does this mean that it’s wrong to talk about Object Oriented concepts, outside the scope of a specific project, application or solution? No. Does this mean that it’s wrong to talk about Service Oriented concepts outside the scope of a specific project, application or solution? No. Is it possible to judge either of these concepts as "better" on it’s own, outside the scope of a given solution or problem domain? I’d say no. So Object Oriented concepts or styles can be used when architecting a solution, and Service Oriented concepts or style can be used when architecting a solution. Can both of these concept or styles be used when architecting a software solution or are they mutually exclusive? I’d say yes, both can be used when architecting a solution and no, they are not mutually exclusive. I’d say that they both answer different problems and concerns and provide different value to the overall solution, but at different scales. I’d also suggest that when viewing a large solution from various scales of magnification, you might see only Object Oriented concepts being applied, or only Service Oriented concepts and not even realize that both are playing an important part at each various scale. It can almost become an example of the fractal geometry of nature*. This isn’t always the case, but can be part of the overall art, science or manner in which the right solution for a problem has been organized, built and integrated; i.e. the architecture.

So, lets forget about the quest for the best architecture, or the assumption that we have already found it. Let’s continue to recognize repeatable software architecture styles, patterns and practices. Let’s continue our quest to use out art, science and manner of organizing, building and integrating to build the right solution to today’s problems, and creatively solve the problems of tomorrow. As we do, new repeatable patterns in our work will be recognized which solve new problems and some will be important enough that they become known as new architectural styles. And still others will build upon these. Architecture is an art, a science, a manner of building things, but it’s not a concrete product and there isn’t a single best.

Note: I don’t know too much about building architecture. More accurately stated, I don’t know anything about building architecture at all, save what any common person learns by casual observations. Oh yeah, and a few years ago I read Ayn Rand’s "The Fountainhead", in which I think I learnt a little about objectivism with a dashing of architecture :-)

* By comparing the relationship of Object Oriented concepts and Service Oriented concepts coexisting at various scales of measurement in a single software solution to that of the fractal geometry of nature, I was exploiting Mandelbrot’s discussion of Richardson’s work on the research of the length of coastlines; in which Richardson suggested that the measured length of a coastline changes as the unit of measurement changes. Mandelbrot used this concept to help explain how self-similar patterns can be repeated to produce shapes with infinite length but finite volume. I remember this being explained to me years ago by a math teacher with a length of string. You can look at a length of twine from a far distance and see a perfect straight line. Look a little closer, and you might see a rough course grained surface of fibers that make up the twine. Look a little close still and each of these fibers appears to be a straight line, a little close, and you again see a rough course grained surface on the fiber itself, etc.

Homework, cannon balls, and VB Express

There is a running joke in my family about asking dad to help with homework. I love helping my kids with their math and science; unfortunately, I love it a little too much. Every night, during homework hours, I patrol the rooms and ask the haunting question again and again "ANYBODY NEED ANY HELP WITH HOMEWORK." Occasionally, I get a taker.

The running joke in the family is that when you ask me for help, you never know if you will get the long answer or the short answer; and if it is a long answer night, you better get on your pj’s and grab a cup of hot chocolate because we will be in it for the long haul. After hearing their homework question, if I answer with "ah, why don’t you finish everything else first and then we’ll take a look at it", you know it is time to be very afraid. This usually means that I’ll be giving the long answer and want to make sure the rest of your homework is done first. When other family members hear me starting to go into long answer mode, they often run for the hills. Bedroom doors close, pets hide in their crates, and the house becomes silent. Actually, everyone starts cracking up laughing and feeling sorry for the poor child about to get a dad lesson. (Usually the child about to get the dad lesson is laughing too)

A favorite example of a dad lesson that everyone still talks about is the time one of my kids innocently mentioned during homework "gee, I wonder how a calculator works". Before the night was over, we were writing binary math logic and talking about ripple carry on daisy chained half bit adders. It was a particularly fun one that really engaged* the kids and we continue to use it as a barometer to compare to other long version answers.

The kids never know when it will happen, and they think it is completely random. Truth is, I try to only pull this trick very occasionally and only when I know they can afford the time. However, it keeps each night’s "ANYBODY NEED ANY HELP WITH HOMEWORK" yell a little more interesting.

Well tonight was a long answer night for poor unsuspecting Justin. I just couldn’t help myself. It was a physics question and they are learning classic Newtonian mechanics stuff, and I’m sucker for a good Newtonian mechanics problem. He grasped the concept they were covering, but in his work he was getting the Vx and Vy components of his velocity a bit mixed up. It was one of those "A ball is hit at an angle of 60 degrees from the horizon with a velocity of 20 meters/second. How long will the ball travel before it hits the ground? How far will the ball travel? What will its maximum height be?"

The root of his problem was a simple one; he didn’t draw the picture. So, we drew the picture, and talked through why it is so important to always draw the picture before you start plugging in formulas. He agreed, and realized his mistake as soon as he saw the picture drawn in front of him. Justin must have been feeling adventurous tonight because he then asked "can you make up another problem similar to this one, and I’ll see if I get that right" You bet I can! So, I wrote up a question about two battleships a certain distance apart in the ocean. I gave the angle of inclination of a cannon on one battleship and suggested an initial velocity of the cannon ball as it was fired. I then asked, "Will the second ship get hit" I could see by the look in his eyes that he actually found the way I worded the question a bit fun and intriguing. His homework problem just said find the Range, Max Altitude, and Final Time; which sounds too boring. Will ship A blow ship B out of the water or not, is a bit more fun. Sure we had to make some assumptions like pretend the cannon is a sea level, pretend the battleship B has a real tall mast, so as long as you prove the cannon ball doesn’t fall short, you can assume a hit.

As he worked out the problem, I could see that he was actually having fun with it. I knew then that I had him hooked for the long haul tonight. He finished, and asked "did I get it right?" My answer was "I have no idea. We haven’t written the computer program yet called Cannon Attack and so we have no way to plug in the values and check them" Ah, I had him good. You see, while he was working out the problem I was strategizing. I knew that VB Express was available for us to download on one of the home computers and thought we could have a little fun. He finished up the rest of his work while I got VB Express installed. Then the fun really began.

For tonight, we just got the basics in place. We created functions for each of his formulas. I made a few typo errors when he was pulling the formulas out of his memory to see if he was paying attention, and he caught every mistake I made. I really knew that I had him good if he was paying close enough attention to catch my errors. I was also impressed that he pulled the formulas from his head instead of looking them up. We then added some text boxes to a Form to allow for each of the battleships logistics to be entered; latitude, longitude, cannon angle and cannon ball velocity, and then added a "Fire" button. We added a Hit or Miss label and also a status panel that contained the homework metrics Range, Max Altitude, and Total time. We wired everything up, pressed the fire button, and noticed a negative elapsed time. This was wrong, but very cool because now he got to see some debugging in action. We stepped through the code and noticed that our value for Sin(x) didn’t correspond to what he had gotten when he did the problem on paper. Justin blew me away at this point; he suggested that perhaps it had to do with degrees versus radians. Bam, he was right on. We converted our degree to a radian double and all was good. We fired up the app, he plugged in some coordinates and had some fun; miss, miss, miss, HIT!

Who knows, maybe before the school year ends we can rework Cannon Attack and introduce some Direct X and get some real battleship graphics going on too! Overall it was another fun night of homework. A few times during the fun my wife walked by us saying "poor Justin, you had to go and ask dad a physics question." Man, I really do love math and science homework questions. The kids might kick and scream a bit when I offer my help, but I know they are really having some fun :-)

Engaged* = bored them to death, but leaves them in stitches laughing when ever talked about it

TVUG with John Papa and System.Transaction thoughts

John Papa presented at the TVUG last night; his topics were ado.net 2.0 and system.transaction. Johnny did a great job and it was good to see him again.

I’ve been excited about system.transaction since first trying it out in beta 1,and blogged a little about system.transaction and talked about a Data Points article that Johnny wrote covering the topic back at the beginning of the year.

There is a lot to like about system.transaction. One of my favorites is the good granular control over the scope of your transaction. Yes, it is really slick how a lightweight transaction can get promoted to a full distributed transaction all dynamically at runtime, simply based on if it is needed or not. Everyone seems to talk about this and it is indeed very cool. However, one of my personal favorites about system.transaction, is that you no longer have to make the transaction decision at the class level!

In 1.x, in order to play with DTC, you inherited from System.EnterpriseServices. But here is the killer: you had to decide if a given class was going to require, require new, support, or not support transactions; at the class level! All you could do in a method was vote on it, either implicitly with AutoComplete(true) or explicitly using SetCommit/SetAbort.

So, if you had a single class that was going to do some db work, you had to either allow your select stuff to take part in transactions (silly), or create 2 types of the class; one to do the non-transactional work, and another to do the transaction work. What I had been dying for was the ability to make that decision at the method level; method A requires a transaction, method B does not. Then you could create the one class to do this DB work and not worry about the "select only" methods creating a transaction. Well now we got it!

With System.Transaction, the scope of the transaction is completely at your control and it is no longer a class level decision. So, yes the auto promotion stuff is really cool and it is going to get the ooh’s and the ah’s, and rightfully so. But, in my mind it’s icing on the cake to the granular control of the transaction scope.