My Notes From Vaughn Vernon’s Implementing Domain Driven Design (IDDD) Workshop

Today I have completed Vaughn Vernon‘s 3-day advanced IDDD Workshop. That was definitely an interesting experience. Designed to be an advanced workshop, it brought some appreciated validation to some of the approaches I prefer to development, complemented my informal knowledge of DDD, and added several new approaches and perspectives to my thought process around creating complex software projects.

In this post I share with you the notes I took during the workshop. This is my and what I captured during attending it, so, it may be useful for as food-for thought only. If you disagree with something in the notes, it’s likely something I have got wrong in the first place. If the notes get you excited about attending the workshop, you may want to check for Vaughn’s upcoming workshops as well.

Read my notes here

[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,

Which ORM? LINQ To SQL, Entity Framework? LLBLGen? NHibernate?…?

While I was planning to write about the same topic and have the draft ready in my Windows Live Writer waiting to complete, I found an interesting question in StackOVerflow and couldn’t just resist to answer:

ORM/Persistence layer AdviceORM

The question starts with:

I’m starting a new project and I’m looking around for either a very good ORM or for a non-SQL-based persistence layer.

Then follows up with a REALLY GOOD summary of what he believes about each known ORM he knew out of his own findings and search. I advice you to go read it.

However, all this investigation didn’t get him to a single choice answer. And I can’t blame him. This is one fo the questions that will remain for so long without a single answer, or maybe having the popular “It depends” answer.

I have had a LONG research in this topic as well. I have read for so long (and watched videos/casts) to make sure of the best usage of many ORMs and then used them sometimes in test projects sometimes in production, and I wanted to share my thoughts based on this. I posted a long answer there on the question in StackOverflow, and I want to share this answer with you here. I may also have a second part of this post based on my existing Windows Live Writer draft, but, based on my previous times, I think I won’t!

Let me first quote some parts from the question itself:

I also want to avoid at all cost having to mess with string-based queries so tools supporting LINQ or otherwise intuitive and possibly strongly typed queries get a big bonus.
Finally working with POCO objects is another thing I’d really want to do
Here’s a list of products I’ve evaluated and why they don’t fit, just so that I don’t see any advice about using those:

  • NHibernate: crazy xml stuff, too much set up, high maintenance complexity and cost for model changes, session factories are messy and don’t fit well with my needs
  • Castle ActiveRecord: NHibernate based, little documentation plus some problems related to NHibernate still apply. Furthermore, to get decent models it takes so many attributes that one is better off creating the schema manually, and the way relations are handled is a shame.
  • Linq To SQL: missing POCO objects and according to MS it won’t improve much overtime (EF is what they’re committed to)
  • Entity Framweork: although in v4 POCO objects are possible, they’re still pretty hacky and force you into doing too much manual work to set things up. Besides, v4 is just a beta
  • LLBLGen Pro: good, especially with SelfServicing adapters, but not POCO. Also, the LINQ provider isn’t perfect yet. Finally, deleting a group of objects is not possible via LINQ which results in mixing APIs (one of which is far from intuitive) and that I don’t like.
  • SubSonic SimpleRepository: for a few minutes I thought I was dreaming. The deam came to an end as I figured out how the thing didn’t handle relationships
  • Here was my answer:

    If you can afford LLBLGen license, go for it.

    I seriously don’t like LINQ query-syntax the more I work with it (although I LOVE the language features related to it like Extension Methods and Expression Trees).

    I loved it at first like everybody else, but being uncertain whether [[ where employee.Name.StartsWith(“John Smit”) ]] in that XYZ LINQ provider will be done in SQL statement or in LINQ to Objects (after the SQL returns all results), and whether [[ user.Roles.Contains(role) ]] will at all work or not is a big step behind.

    LLBLGen can make deleting all items without loading them as easy as

    This is pretty simple and I like it. You get lazy loading and you set eager/deep loading by default and/or per query using Prefetch API. You can compose and construct dynamically (and easily) any filter/sort/loading at infinite levels. It’s very nice.

    There are only two problems about LLBLGen: first, it’s price not all companies would love to pay especially given the hype Microsoft alternatives have. Second, the naming convention although standard in RDBMS theories) like PredicateFactory instead of “where” or “filter” and Prefetch instead of deep loading and even SortExpression instead of orderby, those all are a little scary to a developer working with it for the first times, but soon you learn to love them, given the power and ease they give. There are talks about POCO support in LLBLGen 3.0. I cannot tell about it because I don’t know.

    Now given I no longer work in a company that uses LLBLGen, the company uses LINQ to SQL mainly because it’s “proven” in so many projects without big failures (unlike EF 1, which is lacking even LINQ features in LINQ to SQL and has very bad performance and can be quite limiting in advanced mapping – which it should have been best for!). This website StackOVerflow itself runs on top of it!!! I used both in this company (EF after L2S) and hated both. The decision for new projects remained LINQ to SQL, and doing all we can to overcome it’s limitations. You can work around it to do SEMI-POCO (you still need to use some L2S related types when it comes to associations).

    I also do some small projects at home. Since I nolonger have LLBLGen license, I decided to learn NHibernate and use it along with Fluent NHibernate and LINQ To NHibernate. I have learned through this that NHibernate is VERY strong. It changed how I work by some features like updating DB schema automatically (I never touched the DB almost when using it). LINQ provider (in NHibernate Contrib project) is quite lacking sometimes but there is the unreleased source code of NHibernate itself contains a better LINQ provider (haven’t tried it yet). The “Session” in NHibernate has problems when you are doing web development similar to those related to DataContext in L2S or ObjectContext in EF (LLBLGen doesn’t suffer from those thanks to self tracking entities).

    The biggest problems I had with NHibernate though was ability to find information. Too many pieces that should be put together in certain way and not much guidance can include advanced information for both mapping and querying. If not I had a friend (Tuna Toksoz , @tehlike on twitter) who happended to be a committer in NHibernate project source code, I’d really be in serious trouble.

    The moral I learned was: If you want something that just works and a bit basic use Linq To Sql or SubSonic, if you want something in the middle and your production environment can afford BETA .NET version (given golive exists) use Entity Framework 4.0, if you want something very powerful and can afford the hard learning process go to NHibernate, AND, BEST OF ALL, if you can afford LLBLGen, USE IT.

    Let me know your own thoughts on the topic.

    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 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 (, 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:

    Or for internal use:
      Shop Repository:


    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:


    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….