[Link List]Microsoft Application Architecture Guide, 2nd Edition is now complete (Ebook, Print)


Microsoft has released a final version of its book “Microsoft Application Architecture Guide, 2nd Edition”.
The book is described as:

imageThis guide is available online here in the MSDN Library and will be available in the Fall of 2009 as a Microsoft Press book, ISBN# 9780735627109, that you can purchase through local and online booksellers.

The guide is intended to help developers and solution architects design and build effective, high quality applications using the Microsoft platform and the .NET Framework more quickly and with less risk; it provides guidance for using architecture principles, design principles, and patterns that are tried and trusted. The guidance is presented in sections that correspond to major architecture and design focus points. It is designed to be used as a reference resource or to be read from beginning to end.

The guide helps you to:

  • Understand the underlying architecture and design principles and patterns for developing successful solutions on the Microsoft platform and the .NET Framework.
  • Identify appropriate strategies and design patterns that will help you design your solution’s layers, components, and services.
  • Identify and address the key engineering decision points for your solution.
  • Identify and address the key quality attributes and crosscutting concerns for your solution.
  • Create a candidate baseline architecture for your solution.
  • Choose the right technologies for your solution.
  • Identify patterns & practices solution assets and further guidance that will help you to implement your solution.

More information about the book in this blog post:


The book is:

Available for online reading at:


Available for free download (PDF Format) at:


Available in print (to buy hard copy) from Amazon at:


Have fun reading,

Re: Should the team be allowed to drop the retrospective?

Few minutes ago, I saw @mShady, my dear friend (Real life friend, not just on twitter) tweeting:

RT @ASGEgypt: RT @scrum_coach: Should the team be allowed to drop the retrospective? http://bit.ly/bkOgv #scrum #agile #lean #xp #kanban

I checked the post and found the options are:

  1. Yes, It’s their process why not?
  2. No, explain to them and work through why the retrospective is so important.
  3. Maybe, if they are no longer a team then why continue with Scrum?
  4. Only do retrospectives once a quarter and build up a good list of things to change.
  5. Yes, the process will take care of itself we don’t need to watch it that closely. After all it’s common sense!

Interesting question! Not the most important topic in Scrum but like the way Agile works in general, if you play with it wrong, it is an indicator you have something else wrong as well before that, so, it gives you an alert.

See the rest of the blog post. I find the options my main interest, and wanted to share with you here how I answered this question:

I’d say have a really short one if the team members have been working together for sometime it can go really quick (an hour or so) just before the planning for the next sprint. We used to do so in a previous company and it was pretty successful.
It was like it’s one meeting divided into 2, one hour or so for previous sprint retrospective, and probably rest of the day (or most of it) for the planning for next sprint.

If they cannot have a quick meeting like this quickly then something else is wrong and they need to work on their team skills. Time boxing would be one option: The meeting will be needed “more” if they do not communicate well, Time box it to 2 hours or so and make it clear and strict since beginning, and consider investigating (assuming you are scrum master or team leader) what other issues the team may be suffering from.

However, I find myself going with (1) and (5) at the same time, “it’s their process” and “After all it’s common sense!”.

What do you think??

Videos from NDC 2009: SOLID Principles, Legacy Code, WCF, Software Design,…

Here’s another email from the internal mailing list of Injazat .NET Ninjas (Ninjazat, AKA  as we call ourselves), that I’m sharing with blog readers as well.

Just a place holder, until I move one of my 18 (just discovered the number now – terrifying!) drafts in my Windows Live Writer into a published post, or delete them all!

Subject: [Learning] Some very interesting videos

Some videos from NDC 2009 event (Norwegian Developers Conference 2009) – about software design and related issues:

· NDC Video – Robert Martin – S.O.L.I.D Principles of OO class design

· NDC Video – Robert Martin – Craftsmanship and Ethics

· NDC Video – Robert Martin – Component Principles

· NDC Video – Robert Martin – Clean Code III – Functions

· NDC Video – Michael Feathers – Working Effectively with Legacy Code

· NDC Video – Jeremy D. Miller – Convention Over Configuration

· NDC Video – Michael Feathers – Seven Blind Alleys in Software Design

· NDC Video – Ted Neward – WCF Patterns

· NDC Video: Michael Feathers – Design Sense

For the complete list of videos from this event check videos from:

· Day 1

· Day 2

· Day 3

My favorite topics are (recommendations):

· NDC Video – Robert Martin – S.O.L.I.D Principles of OO class design

· NDC Video – Michael Feathers – Working Effectively with Legacy Code

Of course the other topics are interesting as well.



See you all in dotNETwork May 09 Gathering in Egypt, Lesser known .NET Enterprise Patterns & Practices




There was a sudden last-minutes issue with the transportation / flights configuration that prevented me from making it to Cairo. I’ll be unfortunately missing out this event. M. Smay my friend will be a great backup with all the additional details he has to provide about his session content as well as an open session for the convenience of all of you.

Sorry for missing out. I had to. I’m working with dotNETwork to re-organize my session as part of June 2009 gathering, but this is gonna be another story!


Most of you already know I have moved recently from Cairo to Abu Dhabi. What only a selected set of you are aware of, is that I am still having my heart all set for the developer community in Egypt and still communicating with many of them via Twitter; not only that developers in Abu Dhabi are not into spending time in gatherings or anything than doing work and surviving, but also because I have made the only long lasting and fulfilling friends relationships with the key persons that I see in the different communities, especially my old friends from Microsoft MDC and ArabTeam2000, Demo Day attendees (who still talk to me since 2007), and – of course – dotNETwork, admins, speakers, and participants (who are much more than just attendees).

Fridays City Stars 23rd of May 10:00 AM – 01:00 PM

This Saturday isA I’ll be giving a session that relates to one of my beloved topics in development. Here is the information of the session:

Session Title

Lesser known .NET Enterprise Patterns & Practices

Tag Line

Is your mind ready? Booting up journey in enterprise patterns & practices in .NET

Session Summary

Through an illustration and a thoughtful discussion we are going to see how to go with our applications to the next level, leveraging ease of maintenance, integration points, and scalability out of the box; showing sample enterprise patterns and best practices that are very popular in many development platforms but are rarely used or even known for typical .NET developers

The session will be like April’s session in Fridays City Stars, Nasr City. If you want to know what that is, this is because the Canadian University in Egypt  has stopped all activities in Saturday temporarily for reducing cost; you know, the crisis!


Agenda, date and location

  • Lesser known .NET Enterprise Patterns & Practices
    by Mohamed Meligy – Information Analyst, .NET Technologies – (Injazat Data Systems, Abu Dhabi)

  • A lap around Visual Studio 2010
    by Mohamed Samy – Technical Architect (iSource Egypt)

Fridays City Stars 23rd of May 10:00 AM – 01:00 PM


Have you noticed something? Yes, my closest friend and one of the most lasting / oldest friend in this life, and in the field of course, Mohamed Samy, will be giving a session the same day. HE is such a true guru, and I fear everything ‘m going to say may look very pale compared to what he has to say about VS 2010.


By the way, the attendance will require you to only pay 19 EGP or so– for a sandwich or meal that YOU eat (they have discounts for attendees). This is the host requirement and dotNETwork has NOTHING to do with it. After all, the only available host is now a commercial place. If you can help dotNETwork host the sessions in a completely free place, please contact anyone from dotNETwork and help get that done. PLEASE.

Anyway, I think 20 EGP for something YOU get within the day is not very little but not much also. I saw guys paying the same to the cafe near the University when it was hosted there.


Please be there. I know everybody was too busy to do right publicity of this event, and I myself am writing this very shortly before the event day, but, I’ll not be able to come back to Egypt even every few months, so, this time is very rare for me. Please let me meet the most of you who can make it. This is a personal request, to my true friends. period


Related Sites


dotNETwork CodeCamp ‘09: Framework Design Guidelines & Managed Extensibility Framework (MEF) Slides Available

First off, thank you all so much who have attended the very special gathering of dotNETwork user group, Code Camp ‘09, that took place in the British University in Cairo (BUE) during last Thursday and Friday. This has been one of the biggest events I have been talking in, and that was a great honor.

You can find the slides for the sessions I have been giving below:

Framework Design Guidelines

Download (PPTX File):

Managed Extensibility Framework(MEF)

Download (PPTX File):

(Note: Links to the source code are in the last slide)

Notes On The Event

The speakers and dotNETwork Team

The event went with a similar theme to Microsoft Middle east Developer’s Conference, MDC, which became Egyptian Developers Conference, EDC, which used to take place annually in the beginning of February, but, is yet to happen this year. I’m not sure whether I should be happy or sad for the fact that many attendees came to the event thinking it’s organized by Microsoft as another replacement to MDC/EDC. To make this clear, Code Camp is organized by an independent user group of 11 organizers, known as dotNETwork group (I mentioned a lot in my blog), and was sponsored by Microsoft Egypt, and number of international companies (sponsoring foreign speakers transportation), and the British University in Egypt (BUE, hosting the event). All speakers (foreigners and Egyptians) are volunteers.

Within tow days, with over 300 attendees, and over 10 speakers from both Egypt and world wide, and a great variety in topics, dotNETwork has excelled to make this a GREAT experience for everybody. This is one of the best events I have attended ever in general, which  compares with great improvement to the other best events/sessions I have ever attended/delivered: MDC 2005 (if you skip the Bill Gates pat!) and SilverKey Demo Day II.

Thank you very much dotNETwork and great attendance for the true nice time!

PS. I have notes from the other sessions I have been to as an attendee not as a speaker. Those will be available by the ened of the week or beginning next week (God Willing). Hopefully this time I’ll make it in schedule.

Related Sites

dotNETwork 10th: Architecture Speaking for Itself (DI / AOP)

As ever, there’s

The usual intro …

The .NETwork day for December that took place this Saturday as the 10th group gathering/event was pretty much worth being the day that makes a whole year for .NETwork group, which started December 2007. The day was pretty much different than usual, maybe similar to the very first gathering in organization, and some other days in topic, but the style and taste was a bit different. Pretty much concentrated, although on a variety of topics.

The day was just a couple of sessions. Love it or hate it, no parallelism there. The sessions were given by a single speaker, Omar Besiso, a half Egyptian senior Architect living in Australia, a consultant, Tech Ed presenter, book editor and reviewer – a very great guy as I’ll explain later :).

Actually I really enjoyed the first session. Really want to attend / give many similar sessions in the future.


I have not been very honest while writing this! Since I have a similar interest in the topics discussed during the session, I have written some parts of the post that were not said during the presentation the same way,a and provided some examples and such that represent my own understanding which may or may not be the same as Omar’s.


Lets give it a strong start :-) …

… On Architecture

“Who here is an architect, or works as an architect?”

Having a very quick meal just before entering getting us exactly a minute late (me and Mohamed Samy, my dear friend, without getting lost in the way this time), and before we finish plugging in our laptops and firing OneNote, we were hit by the question as the true start of the session.

Of course I and M. Samy stood for it. This led us to talking about what an architect does exactly. the short answer is “everything”. He designs applications, interfacing between those applications. He meets customer. He still writes code and maybe Prototype or Proof of Concept. But there are types of software architects:

  • Solution Architect: Close to the team decided to work on the solution, performs architecture for a specific solution.
  • Enterprise Architect: This is the one that does everything communications to the office boy and to the CEO. In other words, he handles the solution from the very beginning of whether to have a single solution or series of connected ones.

That talk was before Omar introduces his work-in-progress book “Reactive Programming & Domain Driven Design”, speaking on himself as a “Not technologist.,, but very low Java IQ” (It was interesting to know such exists!). This means that he has no special feeling about any specific .NET technology, or a language, and this is very important, to be able to mentally choose the right technology for the right situation (he made another statement that he uses SharePoint whenever the budget allows, plain ASP.NET only otherwise, which is another interesting topic). However, this is all on top of the .NET platform, as “The technology-Independent architecture that we heard of in the 90s is no longer a fact”.

… On Architecture Myths and Data Driven Architecture

Those are the things most people believe in and do, while are no longer relevant to today’s and future architecture.

  • Myth No.1: 3 Tier Architecture
    • You know this  UI –> Business -> Data thingy!
    • Of course we today know we need other layers
    • How about logging, where does it fit here. Object Pooling, etc…
  • Myth No.2: N Tier Architecture
    • There are so many styles, but usually that’s what it ends to: UI -> External Service –> Business –> Internal Service –> Data
    • The point is, as in the next myth, that is all goes in circles around data.
  • Myth No.3: Data Driven Architecture
    • Bring the DB, fire up the DAL generator, build some “business” that just calls this and bake some UI for it.
    • The argument here was: what if you do not have exactly a database. How about things like Office or Photoshop or so.
    • “We use CodeSmith/.NETTiers as our architecture” What a statement. Is code generation exactly an architecture?
  • Myth No.4: Architecture and design are an overhead
    • Architecture is like an investment. Omar quotes: “If every investment is an overhead, it’s time to sell your assets”. To be fair, I mention he has been working with big projects of hundreds of developers still in one project.
    • The point is about maintenance and updates that takes most of the real time of a project. It’s about responding to change, and the time it takes to actually do respond to that change.
      • For example, for an interest rate value to change, this may be as easy in your design as changing a configuration value, but, how about changing the way this interest rate value is used or the interest way of calculation?
    • Side Arguments:
      • A bad architecture can cost an entire rewrite of the whole solution from scratch not even parts of it. Sometimes if things go bad such a decision is the right one to have.
      • No university on earth teaches the “right” software engineering! Even MIT has hundreds of methodologies, that you don;t know which to follow.
      • “Do not let a software engineer build your house”, you cannot afford a bug or rebuild in there ;).

Clearly, Omar is against the Database-First approach. I heard the same things many time on ALT.NET threads, and it takes many posts to talk about without much benefit, but anyway, Omar’s main argument is that you heart your model (say the classes you use to represent types of business objects, like “Product”, “Customer”, etc) so much when it is just a representation of your database row.

If you change a column in your database for whatever database performance reason, and the model class is a serializable one, and then you de-serialize an objec serialized before change. How will you manage that? (I actually had the same exact situation before, with an object serialized to be persisted in Windows Workflow and de-serialized after months where the class changed due to coupling to the DB).

… On General Guidance

Here came some general notes on achieving in software. Software NEEDS to be (just as in those old computer science books):

  • Highly Cohesive
  • Loosely Coupled
  • Hardware Independent
    • Not that it works on PC and Mac :)
    • But that it (as much as possible) works on 1-processor single machine to a farm or cloud of servers with so many logical and physical processors in them.
  • Reliable
  • Performing
    • Concepts have changed here. People now no longer apply a rule like “reflection is too expensive to use in our applications” (and many great things we see today use reflection heavily in their core)
    • Odd enough but works: In many situations, when you have issues with performance, you just put more RAM (Hardware in general) into it until later you fix/re-factor. Hardware is cheaper than programmers.
  • Maintainable
    • This is what today’s designs and patterns focus on most.

In general, software is developed to fulfill certain needs. It need to be architected and planned to fulfill those needs. Software needs to be:

  1. Envisioned
  2. Planned
  3. Executed
  4. Adapted

… On Layering With Recent Architecture

Then Omar went on talking about architecture in a bit weird way. He went through architecture of the future, and afterwards, of today.

Here’s how he sees architecture of the future:

  • Subsequent of the past
    • New Tools, Old Patterns
      • Design patterns have been there for years.
      • The best way to describe Service Oriented Architecture (SOA) is in terms of component oriented design, the same concepts of the old COM+.
      • Service Locator and Dependency Injection are just glorified factory patterns.
  • Destruction of religious discussions
    • Religious Discussions
      • Dynamic Queries vs Stored Procedures
      • C# vs VB
      • Plain ASP.NET vs SharePoint
      • …..
    • As mentioned before, do not special feelings about a certain technology.

To reach this, that’s how an “Architecture of the Present” consists of for Omar:

  • Consumer
    • ASP.NET, WPF, …
      • Note that a WCF service that depends on another service or solution is also a consumer of that
    • Needs to talk to black box that has the engine
      • Knows nothing about implementation, just a contract
      • Normally you should be easily swapping implementations (contents of the black box) while keeping the interface(AKA, the box).
      • Black box is only DLLs, with no tech, not It’s not SharePoint not anything, the only dependency for it is .NET framework.
        • I asked Omar how do you test and mock work that you do in MOSS (SharePoint), he said that it’s usually just dump code that calls WCF services that are actually the front faces of all the real operations.
  • Domain
    • Entities and Services
      • Entities are the model, again, the “Product”, “Customer”, etc. To explain I tell you they do NOT contain anything except their own knowledge. No persistence or such.
      • Service are:
        • Data Services (“UpdateCustomerRecord”)
        • Business Services (“CalculateDailyReport”)
  • Core
    • The very basic entities and interfaces for the services
    • The contracts live here, the implementation goes to the domain.
    • Say this is a VS Class Library Project. Then this will be the only Project that does NOT depend on other Projects in the Solution, and mostly all other Projects will be depending on it.
  • Aspects
    • Cross Cutting Concerns, the things you perform/need for almost every solution
      • Validation
      • Security
      • Logging
    • They should be implemented in a way that provides consistency path. So that developers are not confused when writing it.
    • Omar says those should be injected. We’ll see how next.
  • Only now after defining those, Omar tends to create the database.
  • Then comes the actual service implementation.
    • He uses dependency injection to makes the consumer just calls the domain via the contracts (interfaces) to and then the implementation gets injected.
    • For Aspects, he uses Aspect Oriented Programming (AOP) / Policy Injection to save the developer from writing those for every method / property.

… On Dependency Injection

Dependency is about interface oriented programming:

  • The Core will have its IService interface
  • The domain will have its ServiceImplementation class that implements the interfacen.
  • The consumer will NOT reference the domain directly. It’ll call “something” called Dependency Container that returns an instance of that interface.
  • The container is then configured to return an instance of ServiceImplementation whenever it’s asked for an IService.
  • Normally you wouldn’t have interfaces for entities (just the services).
    • So, you might not have IProduct interface, but most likely you have an IProductRepository (a data service for Product).

Think of contracts for your day-to-day services. Say a Plane Ticket. This is an API, an interface. It has Date, class of food provided, flight no., etc…, but it knows nothing about the exact physical plane that will hold this number, how it works, or the name of its captain, because this is all implementation detail.

This guarantees ease of changing the implementation (say replacing the plane itself). Services need to be designed by the architect. Of course they all reference the core (which holds the contracts), hence you can easily have other service implementations later.Note that the entities implementations are just testable unit/implementations on their own with no special dependency/reference

Again, the cores references nothing,and most other layers reference it. That’s why internal dependencies need to be defined. This is what products like NDepend provide today and what VS 2010 is going to have built-in.

… … The Service Locator

This is just a factory. It’s job is to locate the service implementation (I’d ask you to imagine a GetProductService function with return of type an IProductService as a service locator). That’s how the consumer never talks to the domain. It calls a Service Locator to get a reference to the service without knowing anything about the service except its interface that lives in the core.

There’re two ways the locator can locate and return the desired service. The service type may be written down in some configuration file and it uses reflection or so to get it, or it can perform some other code logic to get the service (which can be as easy as loading some service assembly and getting a specific class from it).

There is no standard for implementing the locators. You may want to provide a singleton object (have a single ProductService and return it every time an IProductService is requested rather than creating a new object for every call). You may want to cache the object for a certain period.So, implementation does differ.

… … The Dependency Injection

What dependency injection adds to implementing a service is:

  • Standard
    • You have a certain library that you call to get the dependency (service). You configure this library for your specific needs.
  • Turns Service Locator into Glorified Smart Factory
    • It can do more functionality, and it has been tried.
  • It can crate an entire chain of objects, not just one.
    • What if you have (and this is not an accurate example or best-to-do) an IOrderService that has one property of type IShippingService, and you want to create the order service and the dependencies of Order service itself. A dependency container library should provide you with a way to define in the same place what order service to use, and what shipping service to use with this specific order service.
  • There’re main libraries for it
    • Castle (Windsor)
    • Structure Map
    • Spring.NET
    • Enterprise Library (Unity)
  • The style is simple, you have a component (any kind of consumer code), it calls a configured dependency container, and this container returns a ready-to-use instance.

To demonstrate this, Omar presented a demo of an IProcessor interface with only a single method: ProcessMessage and a single property SubProcessor of type ISubProcessor, ISubProcessor also has a single method ProcessToConsole. Each of the methods takes a single parameter “”Message” to process.

Now the service factory is easy to create. Using Unity, that’s just a few lines of configuration copied from documentation. The implementation is pretty easy too. Just write the classes Implementation1,Implementation2 that indicate (by simple writing to Console) they were created and called and then pass the message to the sub processors, SubImplementation1, SubImplementation2 that also just indicate they were created and called.

The console program that acts as a consumer was also easy. It has some code like:

IProcessor processor = ServiceFactory.GetProcessor();

processor.ProcessMessage(“The message”);

So, hrere you seethe consumer just talks to the service locator. In the app.config file we tell what implementation to call when asked for IProcessor and when defining that tell it also what to return for ISubPorocessor. To demonstrate, Omar showed calling Implementation1 with SubImplementation2, Implementation2 with SubImplementation2, and even showed that Implementation1 with SubImplementation2 would just work. And run this on the console to see it actually did work.

… On Policy Injection

As mentioned earlier, the policy injection is a pattern that handles cross cutting concerns, the normal things in all projects. Exception Handling, Logging, and Exception Handling would make it for great examples. They’re things shat we shouldn’t be writing code for them everyday!

The way you do this is by using a global handlers that you inject them (say as you do in dependency injection or by putting Attributes on the thing you want to inject into, which is [in OVERLY simplified manner] Aspect Oriented Oriented Programming). Then have then create events that you implement handlers for. Those handlers become the single place to write your policy code (the logging, exception handling, authorization check, etc..).

There are of course frameworks that help you doing this:

  • Castle (Windsor)
  • PostSharp (Code Contracts in .NET 4)
  • Enterprise Library (Policy Injection Block)

The idea of using is similar. The consumer creates object from a factory, then this instance gets a proxy class created around it (similar to the proxy class that gets created when you have a plain old ASMX web service, anyway, it depending on the library and whether it works in runtime or compile time) around the object, and have events in every property/method in that proxy, then others can subscribe to those events later to inject their policies.

To illustrate, Omar presented another demo. He had a Calculator class (that of course implements an ICalculator) with one method SubtractTwo(number) that just does as its name says (subtract 2 from the given parameter), and showed how to use the Enterprise Library Policy Injection to put a logging handler for it that was set in conifg for all objects of type ICalculator. That’s how the policy is applied to all objects from configuration while the consumer got the ICalculator object itself normally by asking a service factory to create it.

So, as per Omar, that’s how you would do it (like other parts in the post, made longer to illustrate more):

  • Configure what implementation to attach for the specified contract
  • Configure what aspects to to have along with entities and services that implement this contract
  • Create the the actual implementation of the attached service
  • Wrap it with the chosen aspects.

Omar also showed another demo. A real life code from a real customer (one of the big customers he has been working with). We saw the –now– normal stuff, the core that references no one (with interfaces, aggregates, and service contracts in it) , the services either business (which We things like SomethingEngine or SomethingManager,…), or data (which were called Repositories – as usual in similar architectures).

… On Summing up

On summing up,Omer emphasized:

  • Do not code logging (and such) over and over again
  • Watch for performance, moderately
  • Go for standards
    • Use Standard Frameworks, not no name ones (DISCLAIMER, that’s Omer speaking).
    • Standardize your own frameworks.

I have the feeling that I didn’t include everything here, especially some side talks that were worth noting (some are noted). It was a great session with some discussions that are rarely there except in very small groups. Again, I really want to bring similar discussions, either as a speaker or an attendee.

Then came the open sesion …

Well, This one was an open session. I haven’t seen a “bad” open session in Egypt, but also never saw one that would meet my standards for “Successful”, “effective” or such …

There wasn’t much audience this time (Which is really funny and always happened! Seeing that a vast majority of the attendees are students, when the sessions are prepared to meet this level, the audience that attends happens to include many high rank developers. As you may have guessed, when the sessions are prepared to meet this advanced level …. Yeah, only the junior ones are there. This is another post on its own!).

This time the audience was ready for the session but much fewer than it should have. The open talk session didn’t have much talk then more than a demo that shows Tech ED domo on how to use the MS Reporting Services 2008 Report Viewer to create a report from scratch, publish it to your server, and export it to MS Word n less than 5 minutes. Not something that would impress me personally when it has the “less than 5 minutes” in it and Omar himself said a simple report in reality would take around half an hour to design.

The other talks were all like “”What do you think about using the X… technology in Y…. situations”. It was limited to one-hour session anyway due to accidently tight buses seclude.

Some things that are good for example are mentioning the models of doing software in/outside the cloud (topic brought by Mohamed Samy).Omar said those are the common themes:

  • I build software and build data
  • The two at Microsoft (or whatever provider)
  • Data is here but the software is by another provider
  • Data by vendor and he’s liable to it
    • By looking at the terms and statements of Windows Azure, Omar says he found nothing that expresses liability from Microsoft’s side.

Also, when someone asked him whether to use WPF or Win Forms for desktop “Business” applications. He said he uses WPF for all his applications, for business applications he has a WPF theme that looks just like Win Forms. He explains why he does it this way:

  • WPF works directly on the GPU.
  • XAML is a great language, same like HTML but without all the browsers headache and even better syntax.
  • Basically a business application does not have complex UI requirements, but, if some are requested, a WPF application is ready.

He also mentioned the best way to learn .NET is to open reflector, browse the namespaces and see the code for anything whose name grabs your attention. An example is how Serializable attribute is implemented, it’s just an enum :). another example is how to implement an Object Pool. So that for example whenever an object is requested, no more than say 5 instances are created and reused in later requests. Before you think about the implementation, it’s just there in the BCL,in System.EnterpriseServices.ObjectPool. Just have an ObjectPool with Max set to 5 and you are done with it :) :).

It was a really great day. Thanks a lot, Omar.


In Search For Agile Domain Driven Design … Hopefully Part 1 of N

The Useless Introduction You Used To :)

This post has taken so long to be started in writing. I’ve been busy with many events in my life lately. Suffering from frequent limited internet access lately, and, all this moving between companies thing has been eating me. And yes, I admit, I’ have been as tired and more honestly lazy as you expected me to be!

Hey, there’s a little warning. This post is not exactly for my usual audience. I’m sorry, but introducing Domain Driven Design is not one of the goals for this post. There’re many interesting resources and books (even FREE: InfoQ, Domain Driven Design Quickly) on the topic. However, if you leave me a comment telling me to make a write-up on the topic, of course I will :) :).

One more thing. Another reason I’m working on this is that I’m preparing for an internal session here in Raya about Practical Lightweight Domain Driven Design. This session is truly internal yet. It should be recorded though but I’m not sure whether it’ll be possible to publish the videos (Yeah, I will see how we can have our public sessions of possible sure!). If you have a user group and would like me to give this session in a group meeting, I’ll be glad to do.

Introduction Still: The Messages, The ORM

This post was originally a couple of messages I’ve sent recently to the ALT.NET Yahoo Group. In which I discuss using Domain Driven Design with an ORM, more specifically, my favorite ORM, LLBLGen.

Quoting from the first message:

For now, we’re going towards LLBLGen Pro 2.6 for DAL generation and such (using Self-Serving mode probably). Yes, we’re going for database first design, and not using NHibrernate. I’m hoping that we can keep those two issues for other threads :).

Right now, I’m going for other Domain Driven practices. I want to make sure using POCO classes is worth it, and then see how to have those in LLBLGen (which -LLBLGen main template- is in its internal not much different design than Active Record, which in many times is handy, it’s VERY rare t change DAL when one fits different DB providers with good performance), and what are common patterns to do Domain Driven Design at all when having LLBLGen as DAL (if it makes any difference – again: and if effort to make it encapsulated enough to make no difference is worth it).

Making this choice alone is worth its own article. Maybe should title it “In Search For The Perfect ORM” as well :-D.

UPDATE: Frans Bouma has a nice write-up about what is an ORM and different types on an ORM. It’s quite old (2004), but the concepts themselves are still valid.

My original question was:

So, is anybody here doing DDD and uses LLBLGen as DAL generator ?How does the experience look like ? What are common practices across all projects and what have been pitfalls ? etc… These are the kinds of questions I’d love to see somebody here with something to share about.

Domain Driven Design At Work

This is not really an LLBLGen issue. It is questioning the Domain Driven Design productivity itself. I like DDD. I see it as the natural next step after 3-tier deisgn. This whole separation of concerns, models, repositories, factories, infrastructure, and services paradigm just fits my mentality and view of how the world looks like. However, not all the practices in DDD are similar in terms of return of investment, the customer business value that Agile emphasizes. The trick is to know which are and which aren’t, and how to do the balance.

In the second message, I go through an example of typical usage for DDD that has tried just a little bit to be lightweight in some areas but not others, and my own overview about what needs improvement:


I’ve been on a project that leverages DDD once before myself. The project has been frozen for a while for other priorities, etc…Maybe I start with my own take on the subject!!
We’ve been using the “Adapter” model. I thought it was for seeking some sort of more control/flexibility. Reading Fran Bouma’s blog (http://weblogs.asp.net/fbouma, the creator of LLBLGen), I see how he’s so much of an “Entity Design” guy. Well, makes sense, he owns the best entity design I’ve seen so far having considered EF and CSLA.
Clearly he sees the “Self Servicing” as the core for entity design rather than model design. You know, the “entity.Save();” style. This makes me have two thoughts at a time actually. 1- That “Adapter” model is the right choice for DDD (I’ll get to that just below), 2- That maybe DDD fully is not what I really want (the entity Self Servicing style is so powerful. It has saved my day so many times before).
Looking at the project I’ve been working on, We had something like those namespaces / VS projects (and others … ):
Company.Project.Adt (for models that may be reused in other projects, like Language, Currency, …)
Company.Project.Model (for project business domain specific models)
Company.Project.Data (for LLBLGen stuff, we have also “DataDBSpecific” and such related to Adapter mode)
Company.Project.Repositories (have interfaces and implementations for repositories, let’s put aside why the two in one project for now)
A repository load method could probably look like:
  Category Repository:

<span style="COLOR: #ff8000">public</span> <span style="COLOR: #ff8000">static</span> <span style="COLOR: yellow">ReadOnlyCollection</span><<span style="COLOR: yellow">Category</span>> LoadByShop(<span style="COLOR: yellow">Shop</span> shop, <span style="COLOR: #ff8000">bool</span> includeDisabledCategories)
Or for internal use:
  Shop Repository:
<span style="COLOR: #ff8000">internal</span> <span style="COLOR: #ff8000">static</span> <span style="COLOR: yellow">Shop</span> Load(<span style="COLOR: #2b91af">Guid</span> shopKey, <span style="COLOR: #ff8000">bool</span> loadCategories, <span style="COLOR: #ff8000">bool</span> loadProducts)


What I want to highlight here is the “include…”, “load…” parameters. I’m not sure whether this is the best way to do it.
Also, what really hits me is the mapping. You know, from LLBLGen entities to our domain models. We have been doing this in factories which live in the Repository space. Each factory had methods similar to this:
<span style="COLOR: #ff8000">public</span> <span style="COLOR: #ff8000">static</span> <span style="COLOR: yellow">Shop</span> CreateShopModel(<span style="COLOR: yellow">ShopEntity</span> entity)
<span style="COLOR: #ff8000">public</span> <span style="COLOR: #ff8000">static</span> <span style="COLOR: yellow">ShopEntity</span> CreateShopEntity(<span style="COLOR: yellow">Shop</span> shop
Regardless of the “public” access modifier (this is all very well hidden behind a service layer, but let’s put the whole issue aside as well), the idea of having to go through all the mapping has been just a boring ugly task, that has been there for long.
To be honest, we didn’t get so much benefit of it. It should have good promises, but how good compared to the cost of implementing them for complex object graphs ? That is the question!
Things got just worse when we wanted to implement our service layer. That’s a service in the classic sense of “web” service layer (REST), we wanted to created DTOs that can correspond to XML and JSON responses of our choice, and again, we had to do the mapping from and to the domain models and DTOs. Want more ? The DTOs wouldn’t convert to XML strings automatically (to JSON it would), we had to have another mapping layer from and to the DTOs and the actual XML.
Of course we had much time defining XML specifications and writing so many unit tests for this. I know not every project can go in this direction to this extent, but, I wanted to show where going in this path can take you.
So, even without service layer complications. You still have the model mapping tasks that (and this is what worries me) in many situations does not correspond to a “business” need. Note that I want to be doing Agile as well, and this makes the issue of delivering business value a true concern.
You can talk about automated generation for mapping. This may be something. We know it’ll not be this direct or one to one of course anyway, but it may help.
Would you do Domain Driven Design with “entity” models assuming the developers will stick to calling the repository’s “Persist” method instead of “entity.Save();”? You just can’t do that! How about new developers ? How about inconsistencies ?
Is mapping really that bad and much of an effort ? First look at it, I say it isn’t. But given complex scenarios I’ve been though I have to wonder about things like “complex object graph” and “caching” (in memory, on different levels, etc…).
It’s all about trying to calculate the costs indeed.


That’s what I’m trying to make out of this, the trick for the right cost.

Conclusion: How About YOU ??

Let me repeat the end of those messages:

Anyway, would love to hear your takes and what you have :) :) :).

If you have any thought on the topic, those will be most appreciated. You can comment here or in the topic messages page on ALT.NET Yahoo Group. This is an open discussion area, and I do not expect it to be closed soon.

Same, if you want to hear more ramblings on the topic, or just want me to shut it up all, send me a line.

Would love to see what others have to say about this….

Design Patterns Via C# 3.0 – Presentation Featured on SlideShare!

Slideshare is quickly becoming the defacto standard for sharing presentation slides, just as YouTube for videos, and Flickr for images. I recently got into the habit to share my presentations there and use the embed feature to include it in my weblog, and this was the same for the "Design Patterns Via C# 3.0" session.

This morning I got this email from SlideShare

Hey Mohamed_Meligy!
Your slideshow
Design Patterns Via C# 3.0 has been featured on the SlideShare homepage by our editorial team.
– the SlideShare team

WOW .. I couldn’t believe it until I went to SlideShare.net and saw it myself …

Featured Homepage


Thank you SlideShare. I never expected the slides to be interesting to that extent :D :D :D.

dotNETwork 7th: Design Patterns Via C# 3.0 Slides and Demos

Design Patterns Via C# 3.0

View SlideShare presentation or Upload your own. (tags: design patterns)

Yesterday was my 2 part session about Design Patterns as part of dotNETwork 7th gathering. Thank you all guys for being there, There was so much interesting stuff about the audience. The conversation we all had even before the session starts, the interaction with all parts of the session, and the great questions.

Thank you all.


You can find the slides for the 2 parts combined in single downloadable file.

Download the Presentation Slides

For the code examples/demos, you can find them in single ZIP file as well.

Download the Code Samples


I hope you enjoyed the session.

Related Links