June 2008 - Posts

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 !!

 

Hey all, I’m still blogging about my very interesting trip to dotNETwork 5th gathering, what Yasser said about Silverlight 2.0 and Mohamed Samy said about SOA Anti-Patterns.

This will be coming late tonight (God Willing).

I just had a sudden graduation project documentation help request to have to in its writing to start final printing. But I still have my OneNote pages and those are still going to be converted to blog post(s).

I write this to confirm the writing though latency. This post is likely to be updated or deleted when I post my take on the day.

Stay tuned1!!

Update:

I’ve already started finished my writings. Here are the published blog posts:

Mobinil, one of the 3 mobile phone networks in Egypt, owned by the same owner of Link dot NET, one of the leading ISPs in Egypt as well have come with a WiFi service for cafes, just like other ISPs provide.

When I’m in a cafe, I just use the Internet connection that the cafe provides via their ISP WiFi, and that’s it. I do NOT have to pay extra money for the Internet service. I do NOT have to register my Email and mobile phone number anywhere. I do NOT have to buy scratchy charge/balance cards like those for mobile phone credit. This is how it has been for years.

Mobinil screwed that all.

To get to the Internet in cafe, you have to do this the first time you connect:

  • Register your Email and mobile phone number
    • Refresh the page (clearly hosted by Link dot NET) if you get this exception
      mobinil2
      I’ll not get into the details of how horrible  is getting much detail of an exception. It’s not the first time.
  • Wait for the activation code to come (As SMS to your mobile phone, because you have no email, as you have no Internet yet)
    • MY friend did not get his activation code, in this case you call the customer service land line number to get the code.
  • Activate the service using the code, and then sign in to the service page (although you have just activated your account, they don’t know who you are).
  • Use a promotional free 2-hours card to access the Internet (clearly for only 2 hours).

Every time you want to connect to the Internet from a cafe, you have to:

  • Buy a card similar to the ugly scratchy cards you buy for you mobile phone credit
    • The packages available are:
      • 2 hours for 10 EGP
      • 10 hours for 50 EGP
      • 130 hours for 150 EGP
  • Sign in to the service
  • Enter not only the PIN code hidden under the scratch here part, but also a card serial number that’s even very hard to see.
    • I could not see the serial number for how small it is. My friend read it for me.
    • Here’s how the card looks like. The blue rectangle is the PIN code and the green rectangle is the serial number.
      cardBack - Copy
  • Use the Internet finally with the amount of hours you paid for. In my experience, the speed looked like 256Kb or 384Kb max, but maybe this is different from cafe to another or whatever.

For everybody who reads this, is this normal ? Is it a very popular style in so many countries ? I used to go to a respectable cafe paying certain amount of money for my coffee to get extra customer services. Not only that they get me AC and will not kick me out as soon as I finish the coffee, but also that I can get my FREE Internet.

Clearly Mobinil is able to replace other ISPs for cafe Internet, and has already acquired the big name cafes that I know. This is too bad.

 

I want my FREE cafe Internet back!! It has been there for years, and there’s no reason I have to let it go now.

 

Hopefully the other Internet providers will recover this somehow, otherwise, there should be sort of strong petition or stopping going to cafes with this service or such.

 

Emad Lotfy, a software engineer in test and fellow developer in my company, discovered yesterday that the EDC 2008 videos are now available on the EDC 2008 official website.

See the videos NOW.

 

Recommendations

If I happen to choose only one session of those I attended then it’ll be Andrew Pardoe’s CoreCLR session (part 1 end of this file, and part 2 beginning of this file).

Other than that,, there’s Also Ahmed Bahaa’s VSTS 2008 and beyond session (this file), Ahmed Farrag’s SAAS session (this file).

Those are the best of what sessions I attended though . I’ve gone through the videos quick and clearly the other Silverlight videos are good too.

Notes

The videos are released for the 2nd time in developer conferences arranged by Microsoft Egypt. The first time there were problems that made the videos unusable and actually made some of them unavailable at all!

This time, Microsoft Egypt, congratulations. You have done a very good job. My friend could download the complete videos and I can see almost all the videos I was looking for. GREAT!

However, there’re still some issues that I tell here for people to avoid:

  • The video files are not related to specific sessions. They’re just related to conference rooms and then conference days then just numbers. You’ll also find some sessions split into tow videos.  you need to watch for this (I don’t know how – in my case, my friend just downloaded al the videos for us).
  • When you go to a link of a conference room and you want to go to another room, SOMETIMES this will not work. Click the address bar of your browser and press ENTER again to re-navigate to the page (do not try to Refresh (F5)). I think there’s some problem with the conference rooms links being LinkButtons and tryign to AJAify them or.. I don’t know
  • Ahmed Nagy’s Session about VSTO has no links (Should be Khafraa A Room: Day 02: CD 02, because I see myself in beginning of CD 03 asking Ahmed Nagy about his session after it’s complete :D). I would recommend it if it was there. Not sure what other sessions I didn’t notice are not there.
n587461065_1343848_971The 5th dotNETwork gathering will be: Saturday, June 28, 2008.

The agenda is as follows:

12:00 AM - 01:30: Delivering Rich User Experience Applications using Silverlight 2 by Yasser Makram

01:30 PM – 2:00 PM: Coffee Break

02:00 PM – 3:30 PM: Patterns and antipatterns of SOA by Mohamed Samy

03:30 PM – 4:00 PM: Lunch

 

It’ll be in: Canadian International College - Busses will be available at: Nady El-Sekka (11:00 AM - 11:30 AM).

The gathering being on Sunday not Saturday as usual makes it harder to attend it The gathering facebook event said by mistake it’ll be on Sunday, but it’ll be on Saturday normally like all other dotNETwork events.

Regarding the sessions

I do not know about Yasser, but Silverlight 2.0 is a fairly new topic and it’ll sure be interesting to come and see it. I think Yasser will bring us a lot of amazement!

For the SOA topic, I want you all to set high expectations starting now. Mohamed Samy is a Solution Architecture (VSTS) MVP who has worked in and talked about SOA patterns more than most people I have met in person as both a personal passion and a job responsibility as a Technical Architect in ITWorx. I know Mohamed in person and believe he’ll be delivering a rocking session. Do not miss that.

 

Related Resources

 

Update:

I’ve already started finished my writings. Here are the published blog posts:


· Everything You Wanted To Know About MVC and MVP But Were Afraid To Ask

· Functional Programming in C# 3.0: How Map/Reduce/Filter can Rock your World

· MbUnit 2.4 - Avoiding Crappy Data Resulted From The Test

· Managed Extensibility Framework

· IronRuby at Tech Ed 2008

· Velocity: A Distributed In-Memory Cache from Microsoft

· Must See WF/WCF Influencer MSDN Webcasts

· WCF Webcast Series (Old but good)

· Using CSS to Fix Anything: 20+ Common Bugs and Fixes (Found by Mohamed Tayseer)

· A jQuery Client Status Bar

· jQuery for Asp.net MVC preview 3

· Hands on Labs for Web Client and Smart Client (Web Client Software Factory, Smart Client Software Factory)

· Code Style Review Using Microsoft Source Analysis

· Did you know… You can use Tracepoints to log “printf” or “console.writeline” info without editing your code? - #237

· SOA: Making The Paradigm Shift Part 9 of N

· Functional C# - Learn from F# and LINQ

This is problematic with ASP.NET AJAX. The main Script Components are NOT sent to the client when in :Legacy” mode. This is “By design” in ASP.NET AJAX, although it is a clear limitation!!

I’m investigating the problem for other solutions and will be sending an update soon.

Thank you, Iman Halawany, for making me note this. I’ve been working on WCF services and ASP.NET MVC stuff lately than normal webforms, so, didn’t realize this obvious showstopper.

To all my readers, I owe you a BIG apology.

The Problem

ASP.NET validators and ValidationSummary controls are rendered as SPAN tags that are shown and hidden based on validation state. The properties of the validators are written normally via JavaScript calls similar to these:

<script type="text/javascript">

//<![CDATA[

var Page_ValidationSummaries =  new Array(document.getElementById("vdsSiteLogin"));

var Page_Validators =  new Array(document.getElementById("rfvEmail"), document.getElementById("revEmail"), document.getElementById("rfvName"));

//]]>

</script>

 

<script type="text/javascript">

//<![CDATA[

var rfvEmail = document.all ? document.all["rfvEmail"] : document.getElementById("rfvEmail");

rfvEmail.controltovalidate = "txtEmail";

rfvEmail.errormessage = "Email Missing";

rfvEmail.validationGroup = "SiteLogin";

rfvEmail.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";

rfvEmail.initialvalue = "";

var revEmail = document.all ? document.all["revEmail"] : document.getElementById("revEmail");

revEmail.controltovalidate = "txtEmail";

revEmail.errormessage = "Email is invalid";

revEmail.validationGroup = "SiteLogin";

revEmail.evaluationfunction = "RegularExpressionValidatorEvaluateIsValid";

revEmail.validationexpression = "\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";

var rfvName = document.all ? document.all["rfvName"] : document.getElementById("rfvName");

rfvName.controltovalidate = "txtEmail";

rfvName.errormessage = "Password is missing";

rfvName.validationGroup = "SiteLogin";

rfvName.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";

rfvName.initialvalue = "";

var vdsSiteLogin = document.all ? document.all["vdsSiteLogin"] : document.getElementById("vdsSiteLogin");

vdsSiteLogin.validationGroup = "SiteLogin";

//]]>

 

</script>

 

Note that this is for ONLY 3 validators, 1 validation summary and in directly a page that doesn't use a master page, not in nested user control or such!

How about a page with over 30+ validators (yeah, those forms!!), and each with ClientID like "ctl00_cphBody_ct00_fvUserLogin_rfvEmail_" and such?

If you have ever wondered why those pages take so much time loading, this code block (multiplied per number of validators you have and their properties set) is one reason.

You cannot even take the JavaScipt in separate file that can be cached, because this is dynamically created as per the visible validation controls.

The Solution (See Above Note)

The clear alternative to setting those properties via JavaScript long block with huge ClientIDs is to put the properties in the SPAN tags of the validation controls themselves.

The reason that AS.NET does not do this by default is that this is not XHTML 1.0 Transitional compliant, because the validator properties are not XHTML attributes of the SPAN tag.

ASP.NET tries to render XHTML 1.0 Transitional markup by default. But you can change that in your web.config file by adding one line under <system.web>:

<system.web>

        <xhtmlConformance mode="Legacy"/>

 

This will make the properties render in the SPAN tags themselves, saving so much code in real life scenarios.

Personally I'd recommend: DO THIS IN EVERY WEBSITE YOU HAVE (See above note)

 

Thanks to Paulo Morgado for mentioning this.

More Posts