|
|
Wednesday, September 03, 2008
It is a VISUAL STUDIO 2005 PROJECT! Of course we're talking about the Windows version here :). See short note...  More Information Source: CodeProject Lounge Post.
Cross posted from weblogs.asp.net/meligy
Monday, September 01, 2008
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. Cheers, - the SlideShare team WOW .. I couldn't believe it until I went to SlideShare.net and saw it myself ...  Thank you SlideShare. I never expected the slides to be interesting to that extent :D :D :D.
Cross posted from weblogs.asp.net/meligy
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. For the code examples/demos, you can find them in single ZIP file as well. I hope you enjoyed the session. Related Links Technorati Tags: design patterns, patterns, gof, gang of four, oop, object oriented programming, ddd, mvc, C#, C Sharp, C# 3, C Sarp 3, C# 3.0, C Sharp 3.0
Cross posted from weblogs.asp.net/meligy
Saturday, August 23, 2008
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! 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. Technorati Tags: .NETfx3.5, dotNETwork, NET, C# 3.0, Cairo, Egypt, Local Events, Meligy, Design Patterns, OOP, OOD
Cross posted from weblogs.asp.net/meligy
Saturday, August 16, 2008
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! 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! 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! 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: 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. Technorati Tags: Local Events, Egypt, Mostafa Murad, designrific, Osama Murad, ITWorx, LinkDev, ITS, IT Soft, SilverKey, SilverKey Tech, Community, dish party, Barbecue
Cross posted from weblogs.asp.net/meligy
Tuesday, August 12, 2008
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 Technorati Tags: VS, VS 2008, isual Studio, Service Pack, SP, SP1, .NET, .NEt 3.5, .NET3.5, netfx3.5, Visual Studio 2008 Service PAck 1, Visual Studio 2008 SP1
Cross posted from weblogs.asp.net/meligy
Sunday, August 03, 2008
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 :).
Cross posted from weblogs.asp.net/meligy
Saturday, July 26, 2008

Introduction
In Egyptian Developers Conference (EDC) 2008 this April, my geek network noticed a very nice, cute, and sweet little girl with me that I was very proud to introduce not just as one of the cleverest developers in SilverKey, but also as my life mate, my fiancée. Not sure if any of you noticed that by then, although being engaged, we were not wearing rings, yet!
Well, WE DID FEW HOURS AGO! Yes, I now wear a ring with Mona's name on it. What a pleasure that is? To understand, you just need to meet her once. I'll try to give a VERY limited summary of it.
Getting deep into the picture
Mona is a solid geek who just "gets it" when it comes to C# 3.0, jQuery or ASP.NET MVC and all this patterns stuff. That's easy to guess about my fiancée and is very true about Mona. However, this is a VERY MINOR great thing about her, and didn't get much of my attention because it is one of near infinity (at least I'm discovering new great thing every other situation/talk). Besides being so smart and having this great look that makes you feel so calm and comfortable when seeing her, she also has a TRUE pure soul that accepts no harm to anybody on earth and perfectly matches her soft but not easily to be broken nature. Somehow, she merges all this with such a cool nature with a great sense of humor, all this with a very admirable respect to herself being a moderate Muslim.
She has an impossible combination of great talents, skills and natures that I only mentioned the very basic ones of. You can add to that impressing wisdom, talk about a hundred type of kindness, or go talk about the sweetness that shows in every movement or word that comes out of her. I'd dedicate a series of blog posts to talk about each of her greatness as I "mentally" measure them vs. tons of other people I met in my life, counting males and females of all ages, starting at age 8 and above (say in cuteness/sweetness, …) going through 20s to 40s (say in beauty and humor, …) to 50s and counting (say in kindness and wisdom, …). This got me to a conclusion that such person is very rare to happen to exist in the entire world not just in my life.
The Big Pre-Event
So, now that such a rare existing person accepted to spend the rest of her life with such a normal guy whose only good thing is being just another geek of thousands around the world and in Egypt, that is something that makes me so proud.
Having the symbol of it in her hand having my name on it is a true charm that will help me wait the months it takes till we are married and living in the same house. Another wonderful thing is that I now "wear her name" in my hand represented by the ring that has just few hours ago got into my right hand and will hopefully soon move to the left one.
Thank you very much, Mona, for showing yourself in my life. Thank you way more for accepting sharing your valuable life with me. This is the favor of my entire lifetime. I know I cannot reward you for it whatever I do, so, all promise is to still try my best.
I love you, my little sweet cute smart girl.
Thanks again.
Cross posted from weblogs.asp.net/meligy
Monday, July 07, 2008
I found this great article that tells you how to do testing for WCF services exposed as web services, especially REST services (like the ones we create in my company for the project I work on now). What’s the problem ? Typically, for HTTP GET services, you can just put a URL that matches the URI template of the service (the template of the URLs that call the service) in the browser, and simply see what comes back in the browser itself However, when you want to test a service with other HTTP verbs than GET (Say POST, PUT), you need a console that creates the HTTP request with headers and request body and such, because a browser normally has no way of making you create a new customized request (because it creates them for you and encapsulates the entire process of request/response). Usually you write that console on your own. We wrote one for the current project but it didn’t serve all our needs. The solution There’s a program called “Fiddler” (Microsoft Freeware). This program works as proxy server that allows you to intercept and inspect requests and responses for all the web calls you do from your machine. This is very useful but as Firefox extensions do this for us, I haven’t personally installed it for a while. However, Fiddler has a great feature called “Request Builder”. This is where you can construct your request with all parameters and such and change any part of it (headers, body, raw request) and see the response in multiple views (Raw, Text XML, …). You can put the URL of your service in it, choose (or type) the HTTP verb and HTTP protocol version (by default 1.1) it uses, and then check the result to see whether it is what you expect or what. Notes on usage - With Vista or IPv6 supported OS, this fails sometimes especially when your service is hosted with ASP.NET development server (that’s included in Visual Studio). To fix that in Fiddler, go to Tools->Fiddler Options and then uncheck “Enable IPv6 (If available)”.
- This is how Fiddler looks like in sample test
Note that: - The part to the left is the previous HTTP connections. You can fill the request builder parameter by dragging any of them.
- The “Content-Length” header is filled with the right value automatically for you by Fiddler itself.
- An important part to enter in your requests is the “Content-Type”. Many services would behave differently according to that. For an XML web service, that’s typically a new line with “Content-Type: application/xml” in it.
- Fiddler configures itself as proxy for IE automatically. Firefox by default does not use a proxy server. To make Firefox it use Fiddler, from Firefox go to Tools->Options, then the “Advanced” tab, then “Network” sub-tab, then in the part “Connection” click “Settings”. Then
- Click “Manual proxy configuration”
- Enter 127.0.0.1 in “HTTP Proxy” (and “SSL Proxy” if you want this for HTTPS) and then “8888” (default port for fiddler, can be changed from it) in the “Port”.
- Clear the “No Proxy for” textbox to be able to test URLs on “localhost”.
You can alternatively keep it and use http://MachineName instead of http://localhost when testing.
 The One Resource for This This is coming from a great article that talks about the topic (but not with all the notes). The article also shows a VERY NICE example of creating a REST web services WCF project to be hosted in IIS. Go read it right away. Technorati Tags: WCF, REST, RESTful services, Fiddler, POST, HTTP Verbs, webservices, WCF service, WCF services, Firefox, testing
Cross posted from weblogs.asp.net/meligy
Sunday, July 06, 2008
I discovered just now that this blog post was not correctly cross posted from my new weblog to this one.
Trying to copy it manually also does not work (tried in Firefox 3 as well as IE 7). It looks like a timeout or something (warning: yes, it is a big post).
Anyway, if you are interested in my coverage of SOA Anti Patterns session in dotNETwork 5th gathering, you can find it here:
dotNETwork 5th Gathering – Really enjoyed that Silverlight & SOA Anti Patterns Mix (Part II / II)
In my company, we agree on certain subject macros for articles, news and similar non work related messages. Each of us creates his own Outlook 2007 Rules to move those to specialized folders. The drawback of this is that new messages that get moved to other folders than Inbox do not have the desktop alert:  You do not know whether you got a new message or not. This might be OK for messages flagged [fun], but as I have been in the company for long, I used to have folders for each of my complete projects messages in case I get a maintenance message or so. The project I work on right now has its own mailing list, so, I move its messages to a dedicated folder. I cannot afford missing instant note of an email in the project I work actively on right now!! If you face a similar situation, it has an easy fix to get the desktop alerts for all the messages you need it for. Actually it’s no more than creating another Outlook folder :). Let’s see how easy it can go: Start by going to Tools-> Rules and Alerts …  Then click “New Rule…”  Make your selection as below and click “Next”  See if you need to apply this to only certain messages, typically just click “Next” You may get a confirmation message. Just click “Yes”.  The last step is to select “Display Desktop Alert” and click “Finish” and "OK" to next messages.  Hope this helps anybody in similar situation.
Cross posted from weblogs.asp.net/meligy
I’ve have just sent this email to the developers exchange group in my company: I think you all know the routing engine that works with ASP.NET MVC framework to enable customizing URLs and mapping those to the corresponding controls, actions and their parameters. Some of you may know too that the routing engine is not just for ASP.NET MVC, but ASP.NET in general. If you happened to download the source code of the ASP.NET MVC framework (any preview), you’d have noticed that the routing comes as DLL not in source code format like other parts of the ASP.NET MVC framework. I have found an interesting series of articles going through the routing assembly that I thought you might be interested in: I found them at: http://msmvps.com/blogs/luisabreu/archive/2008/07/04/the-routing-series.aspx Regards, Mohamed A. Meligy SilverKey Technologies - Egypt Senior Software Engineer Hope that helps somebody. I feel shamed for not writing genuine articles for long. This is to come soon (God Willing). Maybe in two weeks or hopefully less. Technorati Tags: ASP.NET, ASP.NET MVC, aspnet, aspnet mvc, aspnetmvc, routing, routing engine, url rewriting, asp.net routing, asp.net routing engine, link list
Cross posted from weblogs.asp.net/meligy
Saturday, July 05, 2008
“Foundations of Programming, Building Better Software” is a new eBook by Karl Seguin. The book does not say in its introduction that it’s all ALT.NET-ish, it starts by introducing what ALT.NET is, it's goals etc, afterwards, all the topics the book covers are inspired by ALT>NET frequent topics. This includes Domain Driven Design (DDD), Dependency Injection (DI), Object Relational Mapping (ORMs), Mocking, etc… Here’s what Channel9 had to say about it (which is how I originally found it too): Karl Seguin recently released a great free 79 page eBook for .NET developers covering design patterns, unit testing, mock objects, memory management, object relational mapping, and more. Get it while it's free! Now, if I did my job well getting your interest, then you may want to get to the best part: Foundations of Programming, Building Better Software – EBook Download IF you’re not interested yet, I know this must get your most interest in the book, the table of contents (highlighting chapter titles in bold): About the Author ...............................................................................................................................6 ALT.NET ............................................................................................................................................7 Goals .............................................................................................................................................8 Simplicity .......................................................................................................................................8 YAGNI............................................................................................................................................8 Last Responsible Moment................................................................................................................9 DRY ...............................................................................................................................................9 Explicitness and Cohesion ................................................................................................................9 Coupling ........................................................................................................................................9 Unit Tests and Continuous Integration .............................................................................................9 In This Chapter.............................................................................................................................10 Domain Driven Design.......................................................................................................................11 Domain/Data Driven Design...........................................................................................................11 Users, Clients and Stakeholders .....................................................................................................12 The Domain Object .......................................................................................................................13 UI ................................................................................................................................................15 Tricks and Tips ..............................................................................................................................16 Factory Pattern .........................................................................................................................16 Access Modifiers .......................................................................................................................17 Interfaces ................................................................................................................................17 Information Hiding and Encapsulation ........................................................................................18 In This Chapter.............................................................................................................................19 Persistence......................................................................................................................................20 The Gap .......................................................................................................................................20 DataMapper ................................................................................................................................20 We have a problem ...................................................................................................................23 Limitations...............................................................................................................................24 In This Chapter.............................................................................................................................25 Dependency Injection .......................................................................................................................26 Sneak Peak at Unit Testing.............................................................................................................27 Don’t avoid Coupling like the Plague ..............................................................................................28 Dependency Injection....................................................................................................................28 Constructor Injection.................................................................................................................28 Frameworks.............................................................................................................................30 A Final Improvement .................................................................................................................32 In This Chapter.............................................................................................................................33 Unit Testing.....................................................................................................................................34 Why Wasn't I Unit Testing 3 Years Ago?..........................................................................................35 The Tools .....................................................................................................................................36 nUnit .......................................................................................................................................36 What is a Unit Test ........................................................................................................................38 Mocking ......................................................................................................................................38 More on nUnit and RhinoMocks.....................................................................................................41 UI and Database Testing ................................................................................................................42 In This Chapter.............................................................................................................................42 Object Relational Mappers ................................................................................................................43 Infamous Inline SQL vs. Stored Procedure Debate ...........................................................................43 NHibernate ..................................................................................................................................46 Configuration...........................................................................................................................46 Relationships ............................................................................................................................49 Querying .................................................................................................................................50 Lazy Loading .............................................................................................................................51 Download ....................................................................................................................................52 In This Chapter.............................................................................................................................52 Back to Basics: Memory ....................................................................................................................53 Memory Allocation.......................................................................................................................53 The Stack .................................................................................................................................53 The Heap .................................................................................................................................54 Pointers ...................................................................................................................................55 Memory Model in Practice.............................................................................................................57 Boxing .....................................................................................................................................57 ByRef.......................................................................................................................................58 Managed Memory Leaks ...........................................................................................................61 Fragmentation ..........................................................................................................................61 Pinning ....................................................................................................................................62 Setting things to null .................................................................................................................63 Deterministic Finalization ..............................................................................................................63 In This Chapter.............................................................................................................................63 Back to Basics: Exceptions .................................................................................................................64 Handling Exceptions ......................................................................................................................64 Logging....................................................................................................................................65 Cleaning Up ..............................................................................................................................65 Throwing Exceptions .....................................................................................................................67 Throwing Mechanics .................................................................................................................67 When To Throw Exceptions .......................................................................................................68 Creating Custom Exceptions ..........................................................................................................69 In This Chapter.............................................................................................................................72 Back to Basics: Proxy This and Proxy That...........................................................................................73 Proxy Domain Pattern ...................................................................................................................74 Interception.................................................................................................................................75 In This Chapter.............................................................................................................................77 Wrapping It Up ................................................................................................................................78 The book cover has the www.codebetter.com URL, the community blogs whose owners originally started ht ALT.NET movement (I wrote about it very early back). I suspected it even before reading the table of contents! Oh my. This is the book I always wanted to either read or write. Now I only have one option!!! Technorati Tags: ALT.NET, Link List, Foundations of Better Programming, ebook, ebooks, design patterns, ddd, di, mocking, patterns, Karl Seguin
Cross posted from weblogs.asp.net/meligy
Monday, June 30, 2008
This Sunday, I went to dotNETwork 5th gathering to see how interesting it would be to have some Silverlight fun followed by SOA and Patterns and Anti-Patterns goodness. It was a really fun day, and here comes its writing as I saw it. Starting Out (No tech – you can skip) The day started by meeting Mohamed Samy (the SOA guy, and my friend!) at 10 AM, getting some sandwiches (and coffee for me as I didn’t have sleep the night before), then, going to the buses place in El-Sekka club (as neither of us figured out how to go to the Canadian University). We tried to follow the first bus by his car (so that I could hopefully get a front row seat as for my eye sight issues), but we moved too late, got stuck at some traffic signal, and we simply lost the bus after we were already far from the original bus stop. We tried to continue the way on our own using guidance from dotNETwork guys on the phone and trying to track the university signals. That was around 11 AM. Long story short, we arrived at the university around 12:45 PM, after going to so many places that look very different from each other, and false tries to meet with other guys from dotNETwork in any known place in this area (if “known place” can ever exist in it). Thankfully, that was the only inconvenience of the day, yet, the only adventure as well. Silverlight 2.0 – Yasser Makram Yasser is really deeply technical guy, especially when it comes to Silverlight. He works for a company that does Arabization for Silverlight, so, you can imagine how deep he needs to be to get into that. Clearly I reached his session 15 minutes late at least (given the session started later than it should). I found him discussing Silverlight competition with Flash, mentioning earlier acquisition Microsoft has made that did not help the competition, and why he thinks Silverlight will make it. He said there're other things The reasons he believes Silverlight is going make it is that Microsoft is playing well on many roads. For developer reach, it’s very clear having thousands of threads in Silverlight forums while still in BETA. For partners and component developers, there're many controls, some are free, like Devexpress AgDataGrid, a very advanced grid control. In terms of showcase applications, there're cool goodies like Popfly and Silverlight Streaming service (which hosts any Silverlight application not just streaming media with up to 10 GB and streaming is free up to 5 TB of aggregated bandwidth). For public websites (which Microsoft relays on to spread installation of Silverlight). there`re many, like the upcoming Olympics in August 2008. I asked Yasser though whether there`re even rough numbers of how much of a percentage Microsoft expects for Silverlight market share, but he said there’s none. XAML Afterwards, Yasser moved from his exploratory Silverlight and PowerPoint slides to the XAML of a basic Silverlight demo, which remained until the end of the session. He briefly introduced XAML, and how every XAML tag is used to instantiate an object of a corresponding class. Also syntax for mapping CLR namespaces and assemblies to XAML namespaces for use with custom namespaces, and said some of them are in AssemblyInfo. Then he talked about object properties. Those are expressed in XAML as attributes or sub elements for properties of complex (or custom) types. The element name is in format “ComplexTypeClassName.PropertyName”. Silverlight uses “Type Converters” to map the XAML element names (which are strings) to types of objects to instantiate them. He also showed how VS has the ability to generate event handler method stubs for the events when you type the event name in XAML markup. Small thing we web developers miss with ASP.NET markup :D. Controls: Data Binding & Layout The next point was Markup Extensions, which syntax-wise are just other attributes that start with curly brackets “{}”, usage-wise similar to both “$” and “#” i build extensions and data binding in ASP.NET. They are used in builtin implementation for getting data from static resources, but you can use them for any data manipulation, even better (more extensible as per Yasser( than type converters. Talking about data binding, he stated how Silverlight 1.0 didn’t have any input controls or data binding. Silverlight 2.0 has bunch of those. Silverlight in general has two types of controls, ‘simple control” and “content control”. Actually, most of built in Silverlight controls are content controls. A content control is a template based control, so, you can embed any other control in it even when you think you normally can just add plain text or nothing at all. an example is a tool-tip or a button, in Silverlight, you can for example put an entire grid inside the tool-tip!! Data binding also works in fashionable way. You basically map the namespaces you need, create a “resource” (which is something like data source in ASP.NET as per my understanding), give it a key, and use that with the control you want to bind to. The last step is to fill the source with any enumerable (list of values). I asked Yasser how the data binding work, whether you have to call “DataBind” manually as in ASP.NET or it works automatically and bi-directionally as in win-forms, which Yasser said it does. Talking about data binding made him mention Devexpress grid as well which has more features than the basic built-in one like built-in sorting, paging, and inline-editing. The next topic was Silverlight “Layout”. This is determined via a layout manager which as I understand defines how controls are sized (called “Measure”) and located/aligned together(called “arrange”). Three main layouts in Silverlight are the Canvas (sounded like absolute layout to me) the Grid layout (just a table layout), and the Stack Panel (where elements are stacked next to each other). He explained that you can always create your own layout manager by implementing “measure” and “arrange”. Programmability Silverlight has support for LINQ-To-Objects. Yasser presented how to use it to apply certain change to all controls of certain type contained in another parent control. I asked him about other 2 LINQ providers, he said LINQ-To-SQL is not supported, but LINQ-To-XML is. I asked him about creating customer providers, he said it is supported given the created provider is built to target CoreCLR (Silverlight CLR) of course. Yasser also mentioned Isolated Storage (like temporary folder for caching or whatever), which he said we should only use as advanced alternative to cookies. For example in last MIX conference, there was a demo of an email application that used Isolated Storage for keeping a local cache of the email inbox. Note that the quota (max size) for the Silverlight application storage is 1 MB. The user can configure the quota size still of course. Design Of course talking about Silverlight wouldn’t be complete without mentioning developer/designer separation having developer using VS and designer using Expression Blend. He mentioned two design terms, styles, which are like property setters that are saved in application level file (while the developer works on the content file), and control templates, that have template contracts (the parts to inject controls in the template), states (like enable, disable, hover, …). He used Blend (in the designer, with no manual markup) to show how you can change completely what a control looks like or hat nested controls it contains. Next topic was Animations. He said they can be specified in code (called “procedural”). It can be also defined in markup, he showed how those can be created in Blend with the story board designer (similar to time line in Flash I guess). Then mentioed a not about Flash procedural animation libraries being ported from Flash to Silverlight. He also mentioned DeepZoom. This enables you to make as big picture as you want (he mentioned an example of 6 million pixels), and not download them at once, but zoom and download zoomed part only as needed. Arabic Support Silverlight has no support for Arabic right now. This is funny thinking that Silverlight has general good localization support. Yasser showed how you can put Silverlight in a page by JavaScript or an EMBED html tag, and how to pass “culture to it”. It recognizes Arabic and shows the Arabic characters but in reverse order and separated from each others.and from right to left just as if they were English (Yasser showed that via applying the culture on an application with a Calendar control – he mentioned it’s not extensible BTW). Santeon, the company Yasser works for, has provided free Arabic support for Silverlight.Yasser explained why Arabic is hard to get. You could just reverse the order of all characters but how about numbers and mixed English and Arabic content ? There’s also the issue that the character looks different based on its place in the word, and in some fonts based on what character comes after it. Also word wrapping. Someone hold a side discussion why Microsoft although is known excellence in this in Windows didn’t just use that, and Yasser said any application that supports Arabic well is mainly using system service built into the operating system itself, while Silverlight implementation tries to be not use an OS specific services. The Arabic support for Silverlight from Santeon is done by creating alternative controls to the ones built into Silverlight. A way I personally don’t like but understand it might be the only way to go. They give out their Arabic support at: http://silverlight.santeon.com. Conclusion Yasser is a very knowledgeable guy. He knows much about Silverlight coding and it makes sense as per his work in its Arabization. I think he could make the session last longer though and had much more to tell than he did :). Most of the guys felt he could have improved the way he gave the sessio, but in general it was a good session with a certain depth that I was not expecting to reach in a Silverlight session. P.S. I had a discussion with Yasser about Silverlight and DLR (Dynamic Language Runtime), and why there’s a CodePlex project called DynamicSilverlight if it’s included in Silverlight already. He said he didn’t know. We did not agree on him to send me further information or such, but he later found my blog and usedmy contact page to send me the following: Hi Mohamed, I have checked the Dynamic Languages SDK project on CodeProject, and I found out that this projects is used to host the following: IronRuby Silverlight libraries IronPython SIlverlight libraries Chiron tool, which is a commandline tool used to package Dynamic Languages applications in XAP files (ZIP file with a manifest which is used to redistribute Silverlight 2 applications) Source code for IronRuby, IronPython for Silverlight Dynamic Languages Samples The tools (Chiron), and the libraries are included in the distribution of Silverlight SDK (by default located at C:\program files\Microsoft SDKs\Silverlight). So there is no need for confusion, the CodePlex project is not a separate project, as the libraries coming with Silverlight SDK is actually compiled from this CodePlex project. He sent me his contact info, but I’m not putting them here without asking him of course! Thank you, Yasser. He also sent me the following information about himself when he knew I was going to blog the event. It’s very interesting info, so, I’m sharing it here: Hi Mohamed, I have seen your blog and noticed that you will be blogging about yesterday's session, and also noticed that in a previous post that you don't know about me. So I though to briefly introduce myself to you, and specifically regarding Silverlight. I have been active in the Silverlight community since the beginning. I have been camping daily on the Silverlight official forums, reading threads and answering questions till I became the first to post over 1000 posts and have been ranked as the top contributor. In the last few months I have not been as active, but I still ranked as one of the top 5 contributors in SIlverlight community hall of fame http://silverlight.net/community/recognition/hall-of-fame/ . I have worked on some Silverlight projects, including http://www.ddjsilverlight.com and http://www.nba.com . I am very glad to see bright developers like you in Egypt, after reading through your blog. Good luck and wishing you more success in the future. Heading to SOA Patterns, OOPS, AntiPatterns (Coming in Part II) The next session was very enjoying one as well as informative. I have had the honor to see Mohamed Samy putting the following touches on it before it happens, but seeing it in action was completely different. In order to not make you all wait until I finish that other long part, I’m publishing this part right now and will be sending about all the fun great SOA story in a separate part/post. I hope it’ll be as fun and informative to you as the session was to me. Sorry for taking long to write. I’m already overwhelmed with investigating some other SOA related stuff :D :D :D, and some other less fancy stuff of course. Stay Tuned !! |