Posts Tagged ‘.NET

08
Dec
07

A State of Flex

I remember when first seeing Flex, that it was the ultimate, best thing out there. With its advanced binding abilities, MXML, and those cool sleek visuals – what more can a dev ask?. Then came AIR, adobe was determined to rule RIA. And MS had no answer.

I myself researched alternatives, openlazlo, etc. There was only Winforms to compare to, but that was oranges and apples, really.

Then came Silverlight. This was actually the quiet before the storm, Silverlight had no builtin effects, no controls, and exposed raw interface and unknown idioms. People started comparing Silverlight vs Flex, and the general opinion was the Flex was much superior. I spent a day googling for such comparisons, and saw some conversations between an Adobe dev and Silverlight fans over the Silverlight forums.

But then the storm came. Microsoft rose up all guns machine guns, rockets, and turrets blazing, with the release of VS2008, .NET 3.0, 3.5 the VAST documentation, blogs saturated with information, and now even upcoming MVC.NET and framework source code(!).

Only with these all bits and pieces out there, everything starts falling into place. suddenly using Expression Blend feels “right” and making my own Silverlight controls is a second nature. Visual Studio is so great that it makes me want to leave it open 24/7, and WPF is so much fun I don’t want to do anything else!
Currently I guess Adobe is deep in developing the Flex 3 IDE, and from the Beta2 state of things, its hella buggy. So, I think it is inevitable to declare Flex as dead.

03
Dec
07

Attached Properties/Events

This is a new concept in WPF. However I find that the best selling book in WPF (WPF Unleashed) fails to explain the meaning properly. I will attempt to explain this, trying to rely on familiar concepts.

Firstly, you can take at this short but to the point post to get the motivation for using Attached Properties/Events.

If you’ve read the motivational part in the link above, you now know, that a Parent object needs to store information about his Children.

So the Parent attaches a property, a tag if you will, on each Child. Imagine it as you putting post-it notes on items before shipping them off. Coding rational: the information serves you and thats why you need to provide the facilities to store and manipulate it:

(From Rob’s example)

RobPanel.SetRotatationsPerMinute(b1, 30);

Rob’s Panel tracks information, or property, of the button b1. From the button’s b1 point it has an attached property.

This is a lot simpler than the XAML syntax, because it would rely on knowledge you already have. Attached Properties are probably a concept for something you coded before.

So Attached things conceptually are nothing but a Hash at the parent, where the key is the child object and the value is the information. Practically, it might be that the Child “inherits” the property from the Parent, what ever it may be, the concept remains the same.

The confusing part is that in XAML it only seems like it works the other way around. That is, metaphorically, every item puts the post-it note on himself:

(Directly from Rob’s example – see link above)

<my:RobPanel>

<Button Name=”b1″ my:RobPanel.RotationsPerMinute=”60″ />

<Button Name=”b2″ my:RobPanel.RotationsPerMinute=”3″ />

</my:RobPanel>

Hope I’ve cleared things up.

08
Nov
07

Coderev: Paint.NET pt.I

I’ve started with reviewing the Locale and Setting modules. The code is very clear to me, and I’d like to scribble points I’ve made to myself here.

Settings is a module which rides the registry for saving/fetching settings. This is useful, since you could drop any kind of object and get any kind of object (not just strings) from the registry.

So they did. You can get/set booleans:


public bool GetBoolean(string key, bool defaultValue)
{
return bool.Parse(GetString(key, defaultValue.ToString()));
}

While GetString relies on GetObject (this is the default value version, more on that later):

public object GetObject(string key, object defaultValue)
{
try
{
using (RegistryKey pdnKey = CreateSettingsKey(false))
{
return pdnKey.GetValue(key, defaultValue);
}
}

catch (Exception)
{
return defaultValue;
}
}
Which is the heart of the thing.

Elegance

The do their best to provide a clean and efficient interface:

Settings.CurrentUser.[SetString/GetString/SetObject/GetObject...]
Settings.SystemWide.[SetString/GetString/SetObject/GetObject...]

Which is done simply by instantiating two singletons to the respective HKCU/HKLM keys (CurrentUser, SystemWide are both Settings objects).

Another point to make is the use of “default value”. For some reason I find this a Good Thing. A get method takes a default value, an returns it instead of the null-value it should usually return when encountering error/absence of data.

All in all, this is a module that cries for reuse. And I will definitely put it in may favorite sources box, after I make sure it is generic enough.

19
Oct
07

VS 2005 Toolset

There are several of such posts and then some more. However I’ve decided to make my own, with emphasize on performance and usability. I would avoid lengthily describing each, because that’s what google is for.

While I’m probably not (yet) an authority on coding, I must say that I enjoy wasting hours upon hours searching for perfection. And I’ve come up with those tools. I’m intending to do this in stages, in order to make sure only the best tools are listed here (and not what I was thinking of right at that moment). Here we go.

  • NUnit - Essential for unit testing.
  • TestDriven – Driver for the testing, GUI and runner features. (Better than using the NUnit GUI client)
  • Expresso – For regex testing. (DO NOT use Regulator, it sucks)
  • ReSharper – Very intelligent like promised, however slow and resource eating. Use it, but use with cation.
  • dotTrace – Nice profiler, excellent usable interface. Must have, not free.
  • NDepend – Analyze your code, dependency graphs, treemaps, great for visualization junkies.
  • SmartPaster – Paste strings as StringBuilder statements, Comments, etc.
  • GhostDoc – Generate XML documentation (like Java IDEs have for JavaDoc). Will try its best parsing method/variable names and fill in the blanks.
  • Regionerate- Divide your code to regions automatically, you can specify a custom layout.
  • FxCop – Check/analyze your code with various rules (now by MS).
  • CodeSmith – Code generation by templates. Not sure this is the best option but I’m still working on it.
  • DPACK – No link, I am still evaluating, google if you want to check it out.
  • to be continued…