Thursday, November 29, 2007

Free official copies of Camtasia studio and SnagIt

Want Camtasia Studio (the best software to make screencasts - remember about Justin's competition?) and SnagIt for free? No problem, just go and download it from official Techsmith website. What's the catch? No catch! This is old versions, provided for free by the company.

Download Camtasia 3 (current version 5) here and get free license key here.
Download SnagIt 7.2.5 (current version 8.2) here.

Have a nice weekend.

via Windows Connect

Wednesday, November 28, 2007

WPF quiz #1: Moving rectangles

Referring last event, I want to start new section in my blog, named "WPF quiz".  In this section, I'd like to ask you WPF related question and a day later answer the question my self. So, let's start

Question:
I have to display large amount of rectangles, which moving randomly at the screen. What approach, should I use in order to gain best performance for my application?

Answers (creation):

  1. Create DependencyObject with relevant properties. Create ObservableCollection of those objects. Create DataTemplate to visualize the object into Rect. Bind ObservableCollection to Children property of Canvas.
  2. Create UIElement, that draws Rect. Create ObservableCollection of those UIElements. Bind ObservableCollection to Children property of Canvas.
  3. Create FrameworkElement hosts Rect. Create ObservableCollection of those FrameworkElements. Bind ObservableCollection to Children property of Canvas.
  4. Create CustomControl, that visualizes Rect. Create ObservableCollection of those FrameworkElements. Bind ObservableCollection to Children property of Canvas.

Answers (movement):

  1. Bind attached properties Canvas.Left, Canvas.Top to X and Y of the objects
  2. Bind RenderTransform -> TranslateTransform property of the objects to X and Y
  3. Create and remove appropriate objects with preset X and Y in ObservableCollection
  4. Create DispatcherTimer to change X and Y properties of the objects.

You should choose one from Answers(creation) section and one from Answers(movement) section to archive full answer to this question.

Please use comments for this post to answer.

My answer will come tomorrow. Good luck.

DEV411 - presentation and demos download

I uploaded my presentation, done in DevAcademy2 to SkyDrive. Now you can download, use and review it.

PPT only presentation (7.2 MB)

PPT only presentation before final cleanup (7.6 MB)

Full presentation, including demos, code and PPTX file (26.1 MB)

Have a nice day.

Thank you and Microsoft Expression Blend SP1

First of all, I want to say thanks for all those, who took part in DevAcademy2 event yesterday. I believe, that such events can bring a lot to developer's community all over the world.

Next, I want to announce great work of Microsoft Expression team, that brings us SP1 for Microsoft Expression Blend product.

What fixed in SP1? Most of issues, you reported here.

Download Microsoft Expression Blend SP1 >>

Monday, November 26, 2007

Dev Academy II - updated matrix

Today, I got about 10 phone calls about what's happen with time matrix for Dev Academy II time slots matrix. Please note, that the matrix you got is updated. Please, download and print updated one from here (my slot is at 9:30 AM).

 

Download Dev Academy II Matrix >>

DEV411 - WPF for developers: optimizing your WPF application

Less, then 24 hours until Developer Academy 2 a lot of pressure and stress. Last fixes to my presentation - it's too long now. A lot of stuff, I want to speak about, a lot of demos (mostly very bad performing applications, I dealing with), three computers (one is really cool with 8.9 Vista score) and, of cause, a lot of code to write. But I have only 75 minutes to do it all. So, I have to think a lot about how to do it all together with such tight timeframe (do you remember? - 9:30)

What I'll speak about? I'll speak about cool luxury cars, really.

  • First of all, the most common problem, WPF developers faced with, is performance. No, WPF scale it, but you should know how to do it smart way.
  • Next, practices. Yes, there are practices and it's worth to learn wisdom by the follies of others. So, I'll speak about those follies.
  • Why sometimes, pixel is matter, and sometimes it is not?
  • What two threads, you are working with? Are there really two? Where the application problems is lying?
  • What is tier? How to measure it? How to know when I'm working with GPU and when with CPU? How to influence it?
  • How much memory (either computer and graphic card) I need?
  • What's the greatest evil of your WPF application?
  • How to scale very large bitmaps or very large amount of controls?
  • How to easily make data virtualization by your own hands?
  • How to create your own UI threads? Yes - you can do it!
  • How to make your ListBox x70 times smaller and faster, your data x20 smaller and x700 faster
  • How manage layout and measurement engines
  • How to do things in background without paying application fees
  • How to manage dispatchers
  • How to use visual and data performance measurement tools and how to analyze and profile unmanaged resources
  • How to make your application starts x400 faster and load resources on demand
  • How to load XAML without loading System.Xml.dll and using DOM or SAX
  • How to run the same WPF application on P3 with 128MB RAM and internal graphic card and Core Duo 2 with 4GB RAM and GeForce 880 GTX and get the same behavior of fast running application
  • ...and much much more...

Waiting for you tomorrow at 9:30 AM (this is almost night, kind of morning) at Arbel hall of Avenue at Airport City near Ben Gurion airport. Come an hour before.

image

Thursday, November 22, 2007

Time slot of my session in Developer Academy 2 has been changed

Due to external factors, the time slot of my session in Developer Academy 2 has been changed and now it from 9:30 to 10:45 in Arbel hall in floor 0 (entrance at left). I'm really apologies for this inconvenience and waiting for all of you to come. We're open at 8:30 and there is registration and might be sandwiches in the hall. Come first and park near entrance :)

Please notice: that there are morning traffic jams at the entrance to Airport City as well as registration hassle, thus all those, even come via road 6, take half an hour to 40 minutes spare to enter the parking lot and register.

I'm sorry, that you have to wake up so early, but remember: "Early to bad and early to rise makes a man healthy ,wealthy, wise and not late to DEV411 about WPF lessons learned from last year" :)

27-Nov @ 9:30 AM
set your clock to wake up at 6:30AM and I'll bring you a coffee¹

¹ Limited to first 250 visitors only

Very bad startup name

Today morning, I got call from someone, who ask me to assist new startup with WPF development. I asked a name of the startup. The name is "Proc To Light". Nothing special, they are doing very interesting application, that support analysis to make right decisions regarding different business process. I typed the name of the startup and phone number into my E61 without spaces. Once I got to office, I looked into the note made burst out laughing like crazy. The name of this startup is "PROCTO LIGHT". I called the guy and told him, that I advice them to change their company name in order not to spawn investor's relation.

Image:Anorectum.gif

What other fun startup names do you know?

Wednesday, November 21, 2007

Why good programmer never write good programs

Here, one of visitors, begun a discussion about good and bad programmers. Here, I wrote about absolutely unnecessary and not relevant questions to good programmers. Someone things, that good programmers should write good programs. However, I want to interpose my objections to the statement. And this why.

image

Let's start with the term "good programmer". What is it?

  • He knows any, even small details of programming language
  • He knows to write very efficient algorithms
  • He always in new technologies and applies them in his everyday work
  • He is extremely innovative
  • He tries to make his every bit to be perfect
  • He glows with enthusiasm
  • He's very smart and inventive

Can such person write good program? Probably not. He can not write even average program, because of very small fact - the target of the programs we writing.

Whom we write for? For customers. The customers has no idea about what programming language we are using to write the program. He even do not know why we use this or other approach to solve his business problems. He do not care about algorithms, structures and abstract layers. He do not care about top and very efficient technologies, helps us to perform tasks better. He want to solve his problems and he want to do it quicker as possible with minimal effort from his side.

Now I want to ask you a question: "Do you (as programmers) interested with his (customer's) business processes and problems?" - the answer is NO! You're much more interested with how to make your work smaller and be able to expand it in the future upon customer's requests (not needs). To expand and enhance the program by yourselves - not by any other. You are the programmer!

Honestly, you are right, it is not your job to understand user - this is the job of business intelligence expert. However, how many companies hires this one? How many job boards advertises "BI experts"? - NONE (except those, how want him to sell their products). Everyone are looking for programmers, team leaders and architects. They want you to do it. They want you to understand customer's problem and you to solve it. Will you? Probably not, but you'll try to and this will take most of your work time. This why the programmers of today, probably good programmers, but, actually, they are not writing (and unable to write) good programs. It maybe very good from inside, but will be never good outside.

Tuesday, November 20, 2007

I love such SPAM

That's exactly what I mean, when writing such articles.

image

Translation for English speakers: "Wake up!!! Job boards are overloaded... Very high wage in HighTech. .NET. Press here and you're financially secured.

Monday, November 19, 2007

Visual Studio 2008 new test features

Referring my disappointment from the topics on 70-552, I start looking on new test features, provider by Visual Studio 2008. I worked with performance analyzer in VS2005 (which is looked much more like debug tools for .NET CLR developers in MS) and today, after public release of VS2008, I can show you my research.

From the first sight, it looks like nothing changed

 

image

But when we're digging deeper, we discover new interesting features.

image

Look in this. My application decodes jpegs most of the time. And this is very right.

image

Another great feature, that makes our live easier is Set Root method and Hot Path marking. Now, once, you found the root of your application, you're able to "hide" unnecessary nodes (in most cases, those are system calls) and then mark the critical path (from performance point of view) in your call tree. You also can find all modules and functions, called selected method.

image

Another feature of new performance analysis tool is ability to compare your test run samples.

image

Very very cool tool, however it still too complicated for average user to understand what all those numbers mean, even with handy new Noise Reduction filters :)

image

Now you, probably, know what the problem with CarKiosk.exe application. You do not know what is it? Come and see at Developer Academy II at DEV 411.

VS2008 RTM is available for MSDN subscribers

After long wait, Visual Studio 2008 (code name Orcas) become available for MSDN subscribers. Download it now >>

Sunday, November 18, 2007

How to make your code completely unreadable with .NET 3.5

With the time we got our developers less and less professional by enhancing programing languages and using easier code syntax. However, while we are trying to make things better, we discovered that things are going bad. Let's see following code sample

delegate string BringBeerDelegate(int amount);

 

static void Main(string[] args)
        {
            Console.WriteLine("Bringing beer using anonymous delegates");
            AskBarmenAboutBeer(2);

        }

 

static void AskBarmenAboutBeer(int amount)
        {
            BringBeerDelegate bringBeer = new BringBeerDelegate(BringBeer);

            Console.WriteLine("You got {0}", bringBeer.Invoke(amount));
            BringAnotherBeer(bringBeer, amount+1);
        }

 

static string BringBeer(int amount)
        {
            return string.Format("{0} beers",amount);
        }

 

static void BringAnotherBeer(BringBeerDelegate firstPint, int newAmount)
       {
           string res = firstPint(newAmount);
           Console.WriteLine("You got another {0}",res.ToString());
       }

It pretty clear what this code is doing. It creates new delegate named BringBeerDelegate, that actually formats string. Then it invokes the delegate. After it the delegate transferred into BringAnotherBeer method and invokes there. This way it works in .NET 1.1 So far, so good. Let's use anonymous delegate, introduced in .NET 2.0 instead on using method to invoke it. Now, we'll add another method, that creates and invokes the anonymous delegate BringBeerDelegate.

static void AskBarmenAnonymouslyAboutBeer(int amount)
        {
            BringBeerDelegate bringBeer = delegate(int am) { return string.Format("{0} beers", am); };

            Console.WriteLine("You got {0}", bringBeer.Invoke(amount));
            BringAnotherBeer(bringBeer, amount + 1);
        }

Now, calling AskBarmenAnonymouslyAboutBeer with number of pints we want, we'll create and invoke the anonymous delegate. The code less readable (as for me), but never mind, we saved a couple of code lines.

Now, let's write following:

BringBeerDelegate bringBeer = am => string.Format("{0} beers", am);
BringAnotherBeer(bringBeer, ++amount);

What the hell all those => are doing? This is anonymous delegate BringBeerDelegate defined by lambda¹ expression.

small lyrics: ¹Lambda (uppercase Λ, lowercase λ) - the 11th letter of the Greek alphabet. In the system of Greek numerals it has a value of 30. Letters that arose from Lambda include the Roman L and the Cyrillic letter El (Л, л).
Lambda expressions provide a more concise, functional syntax for writing anonymous methods.

Is it really more concise and functional syntax? What do you think, following code doing?

Func<int,string> firstTime = (int am) => { return string.Format("{0} beers", am); };

Func<T..> is generic delegate type for lambdas. That's piece of cake, isn't it? Let's see you to predict what following code will output...

BringBeerDelegate bringBeer = am => string.Format("{0} beers", am);
Func<int, BringBeerDelegate, string> bringBeerFunc = (int am, BringBeerDelegate beer) => { return beer(am); };
Func<int, Func<int, BringBeerDelegate, string>, string> lastTime = (int am, Func<int, BringBeerDelegate, string> func) => { return func(am, bringBeer); };

The other awful thing in new .NET 3.5 is anonymous types. So, great news, VB programmers, there is new king in the village. His name is VAR. Following previous code section, following make our life even more complicated.

var whatBeer = bringBeer;

//At least, either compiler and interpreter knows, that whatBeer variable is of BringBeerDelegate type

image

Happy and very unreadable coding, my friends.

Source code for this article.

Just released - Microsoft Visual Simulation API

Do you know Microsoft Flight Simulator (X) game? Want to incorporate it's features in your development? Let me introduce you Microsoft ESP. Now, you have visual simulation platform, that might bring realistic visual environment without a lot of development affords. 

Now, connect it with Virtual Earth (with it's new geophysical API) and you have your own .... {censored}. You know, what I mean and can hear it here. Sky is not limit anymore :)

image

70-552 should be removed (or, at least changed)

About two weeks ago, I'm failed on 70-552 (UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework). I'm FAILED. Just flaked it off, stumble on it, loooooose! I even was unable to imagine, that I can fail any MCP exam? So, I investigate why it happened (shit does not happen, we make it happens)

  • I found, that I ever, never used (aint even think of using) build it unit test framework from VS, 'cos it's really SUX!
  • I do not think, that I ever though to "Test the identified component based on the requirements", 'cos first of all I should understand what client need and what other systems he has. Only then I can begin of thinking about "components"
  • I do not want to "Design a new exception handling technique", 'cos we either can use error handling design patters or incorporate existing exception handling best-practices, used by clients.
  • I do not want to "Decide which configuration attributes to store", 'cos we need them all and if you found, that you should not store some attributes, you can just void them
  • I do not think, that I should "Evaluate the test environment specification" or "Evaluate the performance testing strategy" or, even "Evaluate the stress testing strategy", 'cos we have really good external companies, that does it professionally. I have to write good code, while keeping performance in my mind. I definitely should not test the application performance with Windows Task Manager - this is very bad behavior. So, "Identify performance spikes" and "Track logon times" is not my job!
  • I'm unable to "Evaluate the impact of the bug and the associated cost and timeline for fixing the bug", 'cos if you are only developer in the company, you'll fix it. If not, you should know all developers involved.
  • If you are going to "Track bugs that result from customer activity", you should do only this task. I think any of you, who ever did it, know, that we're, developers, trying to explain the customer, that we never have bugs. All those behaviors are kindly expected.
  • If you are not aware about security and want your customer to report "suspicious activity" with your application installer, you, probably, should know how to "Identify scripting requirements for deployment. Considerations include database scripting". As for me, I do not!

So, by summarizing those points, I'll retake the exam, by writing whatever they want me to write, however, I'm very sure, that this exam should be removed from developers certification, if we do not want our developers to become even worth, than they are.

For conclusion about you, as developers. Try to answer following question (from this examination). Later, I'll tell you what the right and "right" answer for this one.

You are developing application, which includes several components:

  • 3rd party webservice
  • External API, developed in other company
  • Core component, developed in your company
  • MSSQL database in your company
  • External component, that using external API

What two components you advice to test in integration tests.

Good luck.

Friday, November 16, 2007

DIY: How to replace your Dell Latitude D820 keyboard for only $13.99

  Well, after my fight against Dell Israel and Omnitech, I decided to replace my keyboard my self. The keyboard was ordered via official Dell US website for only $13.99 (inc. P&P)

DSC06586

It took about a week to arrive and now I'm ready to start replacement process.

DSC06587

You'll need two wrenches like those.

DSC06605

First of all, you should shut down your computer and remove it's battery

DSC06588

 

DSC06589

Next, by using plastic scribe or small wrench remove front hinge cover.

DSC06590

DSC06591

DSC06592

After the hinge removed, you'll get an access to three screws in the top side of the keyboard and small plug. Unplug it.

DSC06593

 

DSC06594

Then remove screws.

DSC06595

DSC06596

After the screws removed, rotate your laptop by 90 degrees and pull the keyboard forward up to remove it.

DSC06597

Turn the keyboard upside down. You discover the plug, that connects the keyboard. Unplug it by pulling it up.

DSC06598

DSC06599

And remove the old keyboard. Now replace the old with new one and plug it back.

DSC06600

Put the new keyboard to it's place and push it down from the upper side and both right and left side to secure it in place. Do it gently to avoid scratches.

DSC06601

Replace all three screws and upper plug.

DSC06602

Put the hinge cover back by pushing it gently

DSC06603

And you done.

DSC06604

 

You just save $121.01. Not bad does not it? Thank you, local thieves, and know, who spares the bad, injures the good. However, here in Israel, an open door may tempt a saint.

Be good men and have a nice weekend.

Thursday, November 15, 2007

To LiorZ with love

As promised, famous T-shirts have been printed. Here it comes

Picture 2

I can not judge the creativity of Lior, Ori and Gil, but I begin to produce such t-shirts. They are available in black and white in any size (M,L,XL and XXL) for 50 NIS (~12.5$) + postal costs (if you'll take it yourself nothing should be paid). If you want your own blog (or any other address) add another 5 NIS.

If you have (or have a connection to) print house and can make it cheaper - you're more, then welcome to help us with those t-shirts.

Number only TextBox

There are a lot of cases, you have to validate, that user inputs numbers only into TextBox. Someone things, that it's bad behavior to prevent user from typing well-known bad characters. I think, it's good. Let's take an example of form, you have to enter Social ID. Do you really think, that user expects the form tell him: "Hey, you, it's 9 digits only. You typed 'Z', which is not digit. Don't do it anymore...". I think, that the good behavior is when user types Z in text area for social id, nothing should happens. But, anyhow, it's up to you to decide.

Today, I want to explain how to build TextBox, that accepts only numbers in WPF.

In WinForms world, we used to handle KeyDown or KeyPressed event to get character and check whether it number. In WPF world, there are a lot of ways to input anything, that text (for example Voice recognition or handwriting. More then this, in WPF (device independent) world we can not be sure, that when you press key with 2 and @ in your keyboard without Shift pressed, you meant "2". Thus KeyDown or, even PreviewKeyDown event will not bring you salvation. We should handle input text without relation to input device. For this purpose, we have TextInput and PreviewTextInput event. Let's handle it

public class NumberTextBox:TextBox
    {

        protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)
        {
            e.Handled = !AreAllValidNumericChars(e.Text);
            base.OnPreviewTextInput(e);
        }

     }

Pretty cool, ah? What's about validation itself? "5" is definitely number, but what about "٥" ? Well, it's five in Arabic and it's number too. Is '½' is number? Sure, it's a half, but is it digit? No! This why we should use Char.IsDigit method, rather then Char.IsNumber which is not limited to radix 10 digits. The same behavior,   you'll get using Char.GetUnicodeCategory method to compare to UnicodeCategory.DecimalDigitNumber, but in this case, it will be current culture oriented.

Well. now we know if the input it decimal, what's about 1,000.00 numbers? The simplest way is to check whether the char is '.'{0x2e} or ',' {0x2c} and mark it as valid, however, what's about 1'00''00 or 100° which is absolutely valid numbers? NumberFormatInfo.CurrentInfo is your best friend in this case. You can always check my Globalization statements by using this handy program.

Now, when we sure, that everything is ok, we can write the test method

bool AreAllValidNumericChars(string str)
        {
            bool ret = true;
            if (str == System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyGroupSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.CurrencySymbol |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.NegativeSign |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.NegativeInfinitySymbol |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.NumberGroupSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PercentDecimalSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PercentGroupSeparator |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PercentSymbol |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PerMilleSymbol |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol |
                str == System.Globalization.NumberFormatInfo.CurrentInfo.PositiveSign)
                return ret;

            int l = str.Length;
            for (int i = 0; i < l; i++)
            {
                char ch = str[i];
                ret &= Char.IsDigit(ch);
            }

            return ret;
        }

The only thing we should do is handle drag and drop and paste whole text into the textbox. That's all folks. If you want to know how to handle and validate D&D and paste, let me know.

Friday, November 09, 2007

Call for action: Register Microsoft Developer Academy 2 - this is not about CRM

Shahar and Guy announced about open registration to 1032359731 (Microsoft Developer Academy 2). Please notice, it is not "תתחיל להכיר את הלקוחות שלך מקרוב - כנס CRM לארגונים תעשיה ביצוא", it's Developer Academy. So, sign up and attend at hall E at 2:45 PM - 4:00 PM for "WPF For Developers -  Lessons learn from last year (Or Optimizing Your WPF Application)" . Know, it's only 2.5 weeks from now - prepare your questions and bring your problems with you.

Developer Academy

It will take place in Airport city (near Ben-Gurion airport) at Avenue convention center, northern Kfar Truman on road 453. Here the map. Be sure to be there.

image

Thursday, November 08, 2007

Your potential, their T-shirts

Back to the Live event yesterday, I recalled old joke, prepared by me for Lior (Microsoft MARCOM) after Blogference, but never sent him. Today, using Microsoft Live Services, I can collaborate this image with him, while wearing Microsoft's T-shirt with slogan "The Jewish people are Live".

image

I'll probably, print this slogan (about T-shirts, not about Jewish people) one day on white T-shirt for my own...


I even prepaired images suitable for printing on material (TIFF, 300 dpi, black and white background). Download it, if you want to print such T-shirt for your own (or for me :) )

Visual Studio Windows Live Tools - November CTP

For all those, who want to incorporate Windows Live into their applications, new Windows Live Tools from Visual Studio will be great place to begin. Download November CTP on Microsoft Connect.

via LiveSide

Windows Live Tools

Wednesday, November 07, 2007

Windows Live Messenger Web API

A couple of hours after Windows Live has been announced, you can chat with me directly from my (or your blog. Enter and see the left side for Windows Live Messenger Web Control.

Want too? That's simple. First, allow others to see your presence. Then choose the control to use. Now (for those, who are using CS) add it into News section or other place in your blog (Spaces for sure).

image

New branded YourName@live.com is available

After a long wait, Microsoft Live is officially available. So, if you are in USA, you already can register new @LIVE.COM email address and have a new fresh start

Monday, November 05, 2007

Release dates: Visual Studio 2008, .NET framework 3.5 and Microsoft Sync Framework

Great news: VS2008 RTM and the final version of .NET framework 3.5 will be available by the end of this month (November). That's what was committed by Soma today at TectEd in Barcelona. This is really cool and means, that RC version is almost similar to RTM.

The other great news, is that there is new product "Microsoft Sync Framework" - a synchronization platform, that works with Live services and Popfly will be available aside this package. \

So what is "Sync Framework"?

· The first CTP of the Microsoft Sync Framework demonstrates Microsoft’s ongoing investments in synchronization and builds on the synchronization functionality available in Visual Studio 20008. With Visual Studio 2008 developers can rapidly take advantage of offline synchronization capabilities to sync-enable applications and services easily with rich designer support. 

· The Microsoft Sync Framework extends the support featured in Visual Studio 2008 to also include offline and peer-to-peer collaboration using any protocol for any data type, and any data store.

· This is part of Microsoft’s long term commitment to providing synchronization for partners and ISVs who can embed the Sync Framework into their applications easily to create rich sync-enabled ecosystems that allow any type of data to follow their customers wherever they go

What is Popfly Explorer?

· Web developers and Popfly users need an easy way to add Silverlight gadgets built in Popfly to their Web pages, as well as publish HTML Web pages directly to Popfly

· To enable this kind of easy customization, Microsoft today announced that Popfly Explorer will provide deeper integration into Visual Web Developer Express. Now developers can now design Web pages using HTML, CSS, JavaScript and publish those pages directly to Popfly (server-side code is not supported)

· The Visual Studio/Visual Web Developer 2008 integration makes it easy to add Popfly mashups built in Silverlight to your Web page. Making your personal Web site look cool just got a lot easier

 

Have a nice day and be good people.

Sunday, November 04, 2007

Poster of .NET Framework 3.5 namespaces

Many thanks to Paul Andrew, Kit George and Brad Abrams for creation of this useful wall poster for your convenience. Read Brad's and Paul's posts about it. Download the full size PDF version.

image

Thursday, November 01, 2007

WBXML support in C# or let's make it smaller

Dear visitors, 03 01 6A 00 00 01 41 42 03 57 42 58 4D 4C 20 50 72 6F 67 72 61 6D 6D 65 72 00 01 43 03 48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 00 01 01. Do you know what I'm talking about? Those 45 bytes string means following 208 bytes XML

<hello-world>
<greeter>WBXML Programmer</greeter>
<greeting>Hello, World!</greeting>
</hello-world>

Basically, XML is very easy language. It's easy to understand, parse and use. However, XML is very inefficient for transport. In order to send this small XML file, you have to transfer more, then 200 bytes, when actually meanful information is two strings. This is not critical issue, when we are working in LAN environment. However it becomes very critical while working with mobile customers. That's the reason of inventing WAP Binary XML (or WBXML).

This language uses name tables (tokens) to convert nodes and attributes into one byte value and this way it saves a lot of unnecessary information to be transferred. WBXML specification is very easy, however .NET (even Compact) framework lack of XmlDocument, that supports this content format.

Is it common enough to lean and use? Well, this is tricky question. From one hand, all of mobile content providers (even those, who dealing with mobile synchronization) widely uses this format. From the other hand, if you are no really "in" mobile (or any other bandwidth efficient) programming, you do not need it.

I think, that one of most important things in programming (in general) is to be efficient, so I decided to write XmlDocument derived class to provide WBXML support.

How to use it?

- First create name tables (you do not have to, if you are using only one token)

Dictionary<int, Dictionary<byte, string>> tokens = new Dictionary<int, Dictionary<byte, string>>();

Dictionary<byte, string> token = new Dictionary<byte, string>();
token.Add(1, "hello-world");
token.Add(2, "greeter");
token.Add(3, "greeting");

tokens.Add(1, token);

- Then create new WBXmlDocument instance with those tables

System.Xml.WBXmlDocument doc = new System.Xml.WBXmlDocument(tokens);

- Now you can either use is as normal XmlDocument

doc.LoadXml("<hello-world><greeter>WBXML Programmer</greeter><greeting>Hello, World!</greeting></hello-world>");

- And then create it's binary representation

byte[] bytes = doc.GetBytes();

- Or load incoming byte array

doc.Load(bytes);

- And get your XmlDocument

string xml = doc.DocumentElement.OuterXml;

Pretty easy, isn't it?  Download WBXmlDocument.cs

Please note:

  • This is not final version
  • It tests not enough
  • There are known issues with attributes parsing
  • It does not implements full specification (I did it for my own needs)
  • Each company might have their own protocol, that can bi slight different from official specification (SyncML for example)
  • You can know token tables only if you'll get full specification of target protocol. Private tokens are not transferred according the protocol

If you want to help and enhance this solution, feel free to do it, however, know, that I release the source under restrictive CPL. You can use this code or code, derived from this code in either open source, free or commercial application, however, you should clearly provide my name "Tamir Khason" and link to my blog http://blogs.microsoft.co.il/blogs/tamir/ or my private web site http://khason.biz within any distribution of the software. For more information, contact me.