August 2008 - Posts

dotNETwork, the most active offline user group in Egypt is having its 7th gathering next Saturday, August 30, which will have two parallel tracks for the first time in the group gathering. BizTalk Introduction, and C# 3.0 Design Patterns, which I will be delivering!

Facebook Event

If I were you to attend the event, it would have been a hard choice too (unless you go simply for BizTalk) ! BizTalk beginner introduction as a topic was not delivered in public sessions before. The only BiTalk sessions I know of were either advanced ones or introducing newer version to those familiar with old version. If you are my friend or you are pretty much into patterns, you may want to give what I have to say a look.

The session parts were primarily intended to be in a couple of dotNETwork gatherings. Now that dotNETwork decided to try out the parallel tracks model having two sessions in the same topic in each track (which is a decision I really like, except that I'd love more distinction between the topics), it was logical to have them in the same gathering / track. I have been thinking whether this should go for the simplest level possible ever, then, decided to stick to the original plan, and even use the long time available for the presentation (1:30h for each part) to go say more about related topics, as I have so much interest in delivering this in certain way for long time now.

About the Session

I'm still messing around with the agenda / exact sequence of the components to be delivered in the session, but I'm going for making an intro to so many topics. The session is meant to target a very wide range of developers. Pretty much anyone who knows a little about C# 2.0+. I'll start by identifying what a "pattern" means, and then go talking about different object oriented design principles, meaning things like OCP "Open Closed Principle", not "what's the different between class and interface?" or "what are abstraction, polymorphism ?" stuff) assuming basic knowledge of the latter but still going through it.

I'll present around 2 examples of each category of the gang of four object oriented design patterns, and probably a couple more from other sources, highlighting few C# 3.0 features using examples from O'reilly "C# 3.0 Design Patterns" book. Building on the object oriented patterns and principles, I'll go introducing some enterprise patterns (yeah, pretty much Martin Fowler work), and end with a small introduction to "Domain Driven Design", which I plan to deliver in a long session (may another two part one, with dotNETwork or maybe ITWorx CuttingEdge Club or public SilverKey DemoDay - if any) with respect to ASP.NET MVC framework in similar manner to Rob Conrey's StoreFront series.

This can move the range of fresh and classic developers knowing just the basic language features and getting that to work in small project to see the trends in the software industry world wide, and in the same time provide some exciting topics for the experienced developers willing to know more about the rarely discussed topics in Egypt developers community. Needless to say, the key to the session is audience interactivity. I'm dying for questions and discussions from now already.

Of course this is not going to be fully covering any of the topics. After all, this is still a presentation, not a course!

About the Day

The event will be next Saturday, August 30th at the Canadian International College, in "El-Tagamo3 El-5ames".
There will be buses at Nady El-Sekka (11:00 AM - 11:30 AM)
Remember, this is a FREE event.

Agenda:

12:00 - 13:30

Tec-Talk Wiz BizTalk (Part 1)
Tamer Mohammad Fathy AL-Khouly,
Mohammad Yousri El-Farsi.

Design Patterns via C# 3 (Part 1)
Mohamed Ahmed Meligy.

13:30 - 14:00

Break

14:00 - 15:30

Tec-Talk Wiz BizTalk (Part 2)
Tamer Mohammad Fathy AL-Khouly,
Mohammad Yousri El-Farsi.

Design Patterns via C# 3 (Part 2)
Mohamed Ahmed Meligy.

Sessions will be video recorded. Good that I'm not missing the BizTalk track completely :).

Related Links

Note

Please drop me a comment here or email via blog contact page if you intend to come and have certain tip / suggestion for the session.

Mostafa Murad, a great UI designer whom I've worked with in two companies, was having a BIG dish party yesterday. Maybe in the occasion of himself recently becoming a team leader in ITWorx or just out of hospitality. He put few simple rules (I'm quoting him here):

    • It is not solely barbecue anymore, you are free to bring whatever food you like.
    • You are free to invite your friends or family members. Many people will bring their spouses and children. There is a big clean garden which is very suitable for children.
    • We'll have football competitions etc

He made a Google Spreadsheet Guest book, where you put your name, your favorite food, whether you have a car or not, how many friends/family members you are getting with you, and, how many kids are coming with you as well.

It was GREAT. The garden was SO BIG. There were over 50+ guys out there: .NET/Flash developers, graphic/web/UI designers, QA, Project Managers, and many other roles, from a number of well known software companies in Egypt, like ITWorx, LinkDev, ITS, SilverKey (myself), and other companies I guess.

All the guys were very cool. The day started with all cars meeting in 2 queues at start place from 10 to 11 AM to pick the guys with no cars (like me) and move together.  The queue I joined consisted of around 4+ cars.The guys I joined had good taste in music that I enjoyed selective choices for Mohamed Mounir and Fayrouz along the way to the farm where the party did go. The way itself was pretty interesting and unfamiliar to number of us!

Mostafa Murad, Osama Murad (my ex-team leader in GNS, currently working in LinkDev), and some kind family lady did a superior job in hospitalizing the crud. We had around 5 kinds of breakfast food, then, went to Friday Prayer (Gomaa) in the near mosque, coming back to play word games, some moved better than the rest to play football and Tennis, afterwards, grilling around 4 kinds of meat and 2 or more kinds of flies, while the family ladies were working on some other 4+ other kinds of dishes. It was AMAZING. You can see a bunch of the the hungry near the END of distorting all the food!

n529421368_1257726_1520

After the food, we managed to take care of around 6 kinds of drinks (apart from tea and coffee, those were available all day long), and around 6 kinds of fruit and later some huge amount of oriental sweets and some tasty cake. It's funny to see that we are the same guys who were praying Aasr just before the attack!

n529421368_1257714_2993

Of course this is not all of us. There was number of Christians, number of girls, women and children, and other Muslims who didn't catch this line by the time of the picture.

As I mentioned, we had much fun. We just went mad all over figuring out something to play, playing with each other either word games or sports, and playing with the VERY CUTE little kids that were there (especially Yasine, this little hero rocks!). We had different talks about general stuff in Egypt, and -of course- our software industry and career talk and stuff. It was hard to resist the idea of going in starting our own company having people of all needed roles there already. Some guys suggested that we can call it "El Mazra'a" (the farm) company!

n529421368_1257734_2641

The farm itself was sooo great place to rest in. Very comfortable. I do not know how this can be described, but, they say a picture is worth thousand words:

n529421368_1257806_4712

I think I fell asleep sometime near by "El Maghreb" prayer! It was very great to find this great place to just forget about everything and have some true rest.

Actually, the whole thing was pretty new to me. This is a little near the number of guys we had in the first SilverKey Public DemoDay event. It really felt like an event to me, not only including certain category of people (developers, designers, ..), but, all over the various industry roles. I tend to believe that hardly any other person than Mostafa Murad and his fame (with the great aid of Osama Murad and other Murad family members) would be able to gather all this amount of people in one place. This is such a TRUE community activity going around, and a HUGE step that any community activity in Egypt should consider.

 

Thanks a lot Mostafa and Osama for this great day and the great hospitality. It was a great day and a very nice move from you all.

Very Quick Note: Visual Studio 2008 Service Pack 1 was released finally (in combination with .NET Framework 3.5 Service Pack 1 of course).

To sum up for some people, note that VS 2008 SP1 includes ADO.NET Entity framework (and its designer) as well as ADO.NET Data Services, but NOT ASP.NEt MVC framework (but does include ASP.NET Dynamic Data & ASP.NET AJAX history control and script combining). It also includes some WCF enhancements as well as major VS performance and scalability fixes.

 

P.S.

SQL Server 2008 also was released earlier last week.

See official page for SQL Server 2008: http://www.microsoft.com/sqlserver/2008/en/us/default.aspx

 

Background (skip if you know Web Application Projects)

In VS 2002/2003, the web project model for a website was similar to "class library" projects, where you have a .CSPROJ or .VBPROJ file that keeps track of files "included" in the project, and compiles all the pages and controls code behind to a single assembly under "\bin". Each page/control has an automatically generated .DESIGNER.CS or .DESIGNER.VB file, which contains objects mapping to the server controls in the page/control markup (the generation of those files was not always in synch with markup, and that was problematic).

With VS 2005, there was a new "website" model for web projects that compiles each page/control individually as a separate assembly (or each folder, depending on optimization features), and applies this to all files in a given directory and its sub folders. This was a total mess in most "real world" projects, as VS takes so long to build the entire website, and even at deployment, you get sometimes many problems when you have pages that "reference" other pages/controls when IIS it trying to dynamically load the right assemblies to reference, and many other problems.

So, Microsoft came with a new add in to VS 2005 called "Web Application Projects". This is typically the same old VS 2002/2003 project model with no problems in generating DESIGNER files and with integration with both IIS and ASP.NET development server that comes embedded in VS 2005/2008. It was later merged with VS 2005 SP1, and shipped as part of VS 2008 (without removing the "website" model). Note that most stuff that has to do with Microsoft like ASP.NET AJAX Toolkit Sample website and so are actually "web applications" not "websites".

The problem

Typically, when you are converting any project from VS 2003 to VS 2005 SP1, it converts as "web application" not "website". You can also convert a "website" to a "web application". There's an option "Convert to web application" to look for.

In my company, all our web projects are "web applications", well, except that other web project I was code reviewing and helping with its deployment! After spending number of days with the brilliant team and not finding as many items to code review and getting sick of some problems at sometime in deployment, I cried to them to convert it to to "web application" (maybe I was looking for some job to be doing :D). Very confidently, I said, " remember the option exists and I did conversion before in VS 2005. All it takes is a right click on the 'website' root node in solution explorer in VS 2008 and 'Convert to web application'. It almost never causes any problems, and we have our source control anyway".

They believed they had time to do it, so, they went to look for that menu item  "Convert to web application" and guess what ? They didn't find it! They tried resetting VS 2008 settings and everything, and still, nothing there!!! Yeah, it was embarrassing :D :D :D

Workaround, or, how to convert a "website" to "web application" in VS 2008

Well, it turns out that the option "Convert to web application" does NOT exist for "websites". The option "Convert to web application" does exist only for "web applications" !!!!

So, here's the deal, to do the conversion, you need to:

  • Add a new "Web Application" to your VS 2008 solution (File->Add->New Project->C#->Web->ASP.NET Web Application).
  • Afterwards, you copy all the files in the old "website" to your newly created "web application", and override any files created in it by default
  • The next step is the most ugly, you need to "manually" add the references in your "website" to the new "web application". I thought the VS 2008 PowerCommands toy would do this for me as it does copy references from other project types, but it didn't. You have to do it by yourself, manually, and you have to be cautious in this step if you have multiple versions of the same assembly (like AJAXToolkit in my case) or assemblies that have both GAC and local versions or so.
  • Keep repeating the last step and trying to build the "web application". You'll keep getting errors like " '....' is unknown namespace. Are you missing an assembly reference? ". Make sure you have none of those except the ones where '....' is replaced by the IDs of the server controls you use. In other words, keep adding references and building the project until only the errors that exist because of missing .DESIGNER.CS or .DESIGNER.VB files.
  • Afterwards, go to the "web application" root project node in VS 2008 solution explorer, and right click it, then you WILL find the option "Convert to web application". What this option does is actually making small changes to the "@Page" and "@Control" directives of pages and controls, and creating the required .DESIGNER.CS or .DESIGNER.VB files.
  • Try building the "web application" again. If you get errors, see what references may be missing and/or go click the "Convert to web application" again. Sometimes, if there's any error other than those caused of missing DESIGNER files, not all the pages/controls will have those DESIGNER files created for them. Fixing the non DESIGNER problem and clicking "Convert to web application" again should do the job for this.
  • Once you are done successful VS build, you should be ready to go. Start testing your web application. Optionally, you can right click the "web application" root project node in VS 2008 Solution Explorer and click "Properties" then go to the tab "Web" to set the "web application" to a virtual folder in IIS (you can create new virtual directory from there in VS). If you want to use the IIS virtual directory that the old "website" used, you need to remove that from IIS first.
  • Update: When testing your pages, pay MOST ATTENTION to classes in "App_Code" folder, especially those with NO NAMESPACE. Those can be a big trap. We had a problem with two extension method overloads in the same static class that had no namespace,one extends DateTime? (Nullable<DateTime>) and calls another overload that extends DateTime itself. Calling the other overload as extension method passed VS 2008 compilation and gave us a compilation error ONLY IN RUNTIME (With IIS). Changing the call to the other overload from calling it as extension method to calling it as normal static method (only changing the call in the same class, calls from other classes remained extension method calls) did solve this one, but clearly, it's not as safe as it used to be in VS 2005. Especially with classes with no namespaces.
  • Update2: During the conversion, VS 2008 renames your "App_Code" to "Old_App_Code". This new name sounds ugly, but DO NOT RENAME IT BACK. In the "web application" model, all code will be in one assembly. In runtime, the web server does not know what web project type you are using. It does take all code in "App_Code" folder and create a new assembly for it. This way, if you have code in folder named "App_Code", you'll end up with RUNTIME compilation errors that the same types exist in two assemblies, the one created by VS, and the one created by IIS / ASP.NET Development Server. To avoid that. leave the "Old_App_Code" with the same name, or rename it to ANYTHING EXCEPT: "App_Code". Do not place any code in such "App_Code" folder and prefereably do NOT have a folder with such name in your "web application" at all.
    I know this since before but forgot it now as I have not used "website" model for long :(.

I hope this helps anyone to avoid my embarrassment, and still get rid of the weird errors of "website" model :).

More Posts