Architecture Analysis Practices with VS2010 Direct Graphs and Layer Diagrams

Been using the direct graph [DGML] and layer diagram capabilities from VS2010 for a while now. Used them on many different projects with a wide spread of architectures, different quality levels and with many questions to answer about it. And I recognized a common way of working when using the tools…

It looks something like this:

Zoom OutRecognize - Zoom InAnalyze - Zoom Out or Zoom InGroupZoom Out

and can been done in a different order…

Some examples will explain the analysis process better.
Chaos Example. First the question, the question what to analyze is the starting point and actually the key driver of the success factor of your analysis. The funny thing most project teams don’t know what to ask, they mostly cry for help. The same counts for a project like this. The project team was targeting a very basic architecture with a UI, business, data and infrastructure layer. To bad the team didn’t managed to stay in control and when you do an high level analysis, “Zoom Out”. [ Architecture –> Generate Dependency Graph –> By Assembly or Namespace, most of the time they are the same]menu

You get a direct graph, which probably makes everybody starts to cry or run a way “Recognize”… many connections, many dependencies which don’t belong there.

1

Although the funny thing is, when you us the default analyzers on this diagram, you won’t get any warnings….

analysers

Analyze” There are no circular references, a trigger for tight coupling. There is one unreferenced node, for sure the outside pointing assembly [the UI] not strange. And, two assemblies are hubs, the data  specific assemblies. This could be a trigger that these assemblies have too much responsibility.

2

Now at this stage of our analysis it’s interesting to take a look at the question… where are we looking for? it seems chaos, with the analyzers it looks like a kind of ok…. but it smells very bad.
The patterns and practices architecture guidance has a nice collection of:

It helps a lot when having these in our mind when executing an architectural analysis of a system… just to mention several:

  • Separation of concerns.
  • Single Responsibility principle
  • Principle of Least Knowledge
  • Don’t repeat yourself (DRY)
  • Minimize upfront design
  • Keep design patterns consistent within each layer.
  • Do not duplicate functionality within an application.
  • Prefer composition to inheritance
  • Establish a coding style and naming convention for development
  • Use abstraction to implement loose coupling between layers.
  • Be explicit about how layers communicate with each other
  • Do not mix different types of components in the same logical layer
  • Keep crosscutting code abstracted from the application business logic as far as possible

Not all principles can be analyzed with Direct Graphs or Layer diagrams, but you can use some… the most important thing is that you know where you are looking for.

Now, lets zoom out… this direct graph we got gave us too much information to start our analysis with. It smells bad but what is wrong? sure, too much dependencies. Probably no good “Separation of concerns” and not been “explicit about how layers communicate with each other”… Start grouping assemblies [or namespace based on their parent namespace ] together.

Select the nodes which belong to each other and group them…

4

The Direct Graph we get now gives us much more information… 
The UI talks with every single layer [assembly] in the system, but the thickness of the line tells us… the UI talks heavy to the business piece, sounds good… a lot to the framework and security assemblies, don’t know yet what their responsibilities are but the names are a kind of descriptive…

3

This is actually a funny part of the whole analysis thing, you really lean on the names used. A developer could call the UI layer data access, that would mess up my complete analysis. 

Anyway, the problem is between the data access part and the business part. They are really tight coupled… the Web UI uses a bit of the data access, maybe some databound listbox “Recognize”. Not that important… Zooming in on this one “Zoom In” and selecting the dependency line between the data access and web component tells us…

5

.. that it is indeed a method… [only interested in methods]

6

… which does a data binding with a grid. [we will mark it needs some investigation]. Context menu item “Show Context” will jump to the code…

7

The tight coupling between data and business is a bigger challenge, when looking at the very very thick lines… they are really tight connected. Diving in these nodes “Zoom In” and looking at the different nodes, tells us… everyone from the data group points to “company.business.datasets”. that one isn’t a business component it contains real dataset [don’t know why its has “business” in the name..?]. Diving in the code shows something what we expect… generated datasets.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30128.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Moving the  “company.business.datasets” to the data access group makes the dependency graph more clear… “Group

8

The thing we still got in this system, is the connection between UI/ Web and the Data pieces… when zooming in on the Company.Web.Application you will see that about 50% of the types use the Business.DataSets… [context menu item on the DataSets node and select “all incoming”].

9

Probably all data binding stuff… now we have to make a decision. Refactoring the name of the Business.Datasets to DataAccess.DataSets would be useful. We can recommend that all UI binding should go through the business layer, than we need to start a big refactoring effort. We also could decide to binding of the UI with the datasets is fine [kind of Table Adapter Pattern]. It’s up to the architect. The thing dependencies which definitely have to remove are the ones with the dataacces assembly, there are just two calls. Create a dataset a bind it to those or create business entities.

So finally we come to some very specific recommendations how to improve this architecture… now it’s time to create a Layer Diagram. What I always do, is just drag and drop the different projects on the Layer diagram design surface and let it generate the dependencies…. again you get the scary one ;-)

10 

Start group components together in layers and draw the dependencies as decided with the project lead and architect… till you get to the result you wanted, for your architecture…. 

11

And now, we can run the validation... the errors which show up are the code pieces you need to fix. When your ready fixing those, maybe you want to clean/ refractor the architecture even more, maybe remove the datasets and talk only through the businesslayer… change the dependency rules and validate again… in this way the errors which show up are more in control and you can do the refactoring step by step.

It was a fun journey ;-)
Zoom OutRecognize - Zoom InAnalyze - Zoom Out or Zoom InGroupZoom Out and finally VALIDATE

Comments (45) -

Fine information, many thanks to the author. It is puzzling to me now, but in general, the usefulness and significance is overwhelming. Very much thanks again and  best of luck!

Took me time to read all the comments, but I really love the article. It proved to be very useful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also entertained! I'm sure you had fun writing this article.

Hey webmaster, many thanks for sharing this stuff.. I found it outstanding. Take care,  !!!!

Thank you for helping !

u have a real useful web log ive been here reading for half an hour.

Many thanks for your brilliant posting! I found your post very interesting, you are a brilliant author.  I actually added your blog to my favorites and come back again. I want to encourage you to continue that great work, have a great day!

This clause passes the light that we can watch the reality. this is very fine one and holds indepth data. thank you for this decent clause

Rather superb entry, definitely useful stuff. Never ever considered I'd find the facts I need right here. I have been looking everywhere in the internet for some time now and had been starting to get discouraged. Fortunately, I happened across your blog and received precisely what I was searching for.

Substantially, the article is in reality the greatest on this precious topic. I agree with your conclusions and will thirstily look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c clarity in your writing. I will directly grab your rss feed to stay privy of any updates. Authentic work and much success in your business efforts!

This is a nice blogging platform. Which is it?

Your blog has a really cool design. That being said the information here is free and is of high-quality. I am subscribing to your feed right now.

Terrific post, many fascinating points. I remember 7 of days ago, I have discovered a similar article.

This is a really good read for me. Must admit that you are one of the coolest bloggers I ever saw. Thanks for posting this useful article.

I like the blog, but could not find how to subscribe to receive the updates by email. Can you please let me know?

When do  you think you can update with a new entry corresponding to this. I feel that whole subject of indie music needs to get noticed more.

It’s hard to find sharp writers on this topic, but you sound like you know what you’re talking about! Thanks.

What I love about blogs is that they spark a thought in my mind. When that happens, I feel like I must respond wishing it can be valuable to some people.distinctnot to mention I find myself coming back to to your blog simply because you have plenty of really good insightsvery long time, that is very inspiring.

You have a very jucy blog. I still have one more question How do you deal with the raising amount of Spam in your blog comments? I really hate it, It wastes lots of my time and I really hate messing around with this every single day.

I like the blog, but could not find how to subscribe to receive the updates by email. Can you please let me know?

My husband and I have been looking for this info.  Wondering if you know of anyway to make bulk emails anonymous?

Looks like the post is gone can anyone provide a re upload? Thanks!

Easily, the post is really the freshest on this noteworthy topic. I concur with your conclusions and will eagerly look forward to your future updates. Saying thanks will not just be sufficient, for the great clarity in your writing. I will instantly grab your rss feed to stay abreast of any updates. Authentic work and much success in your business enterprize!

Hey man, thanks for providing such a valuable resource for free! It is really great to see that such information is written for free.

Man, I been a fan of "LOST" since the begining. Very, sad to see it come to an end.

I am surprised at the things I overlooked before I read this post. Thanks for the good information.

Couldn't be written any better. Reading this post reminds me of my old room mate in school! He is always talking about this. I will forward this article to him. I'm sure he will enjoy reading it. Thanks for sharing!

I like the blog, but could not find how to subscribe to receive the updates by email.

You are 100% on the money! Most people I see view things in the short run and try to take every opportunity to promote or hype themselves instead of building credibility by helping others achieve their goals.

I like the blog, but could not find how to subscribe to receive the updates by email.

I adore Turkey guys. They are sooo cute! X

Every time I see blogs as good as this I KNOW I should stop surfing and start working on mine!

We are a group of volunteers and starting a new scheme in our neighborhood. Your site provided us with valuable information to help us get started|.You have done a marvellous job!

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don't know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

Finally, Finally…I’ve been looking for this information for a long time. Thanks

Took me time to read all the comments, but I really love the article. It proved to be very helpful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also entertained! I'm sure you had fun writing this article.

This was refreshing. I wished I could read every post, but i have to go back to work now... But I'll return.

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.

This is a really good read for me. Must agree that you are one of the coolest bloggers I ever saw. Thanks for posting this informative article.

Form one reason only one-half of the site is being showed. Is this my web browser causing it or is it the site?

Hey, I like you blog, I'd really love to write an article if I could, hit me up at Hulon3474@hotmail.com

Hello I am so delighted I found your blog, I really found you by mistake, while I was looking on Yahoo for something else, Anyways I am here now and would just like to say thanks for a tremendous post and a all round entertaining blog (I also love the theme/design), I don’t have time to read it all at the moment but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the great work.

There are certainly many more details to take into consideration, but thanks for sharing this post.

Add comment


Şarkı Sozleri