Why .Net has it all

Disclaimer: I'm no MS/.Net evangelist. I'm just a computer software developer that wants to share his experience working on a weekend project (actually 3 weekends...)

As a bet between me and my wife, I took the challenge of developing grid computing software over the weekend. The aim is to basically solve a very challenging billion of billions of possibilities puzzle with a 2 million dollar prize.

The functional requirements were:

  • A user friendly GUI (and an easy to use gui designer)
  • Webclient Capabilities
  • Email sending capabilities
  • Encryption/Decryption
  • Installation and Setup
  • Software Updates Engine
  • Process Execution Priority
  • Registry Management
  • MySql DB Connection Adapter

And there were a few non functional requirements:

  • Multi-Threaded Execution
  • Code Access Security
  • High Performance
  • Small Memory Foot Print
  • Source Code Obfuscation

 

So I've set up and started to work. By taking a look at the list of functional and non functional requirements I've decided that going for .Net is probably the best call. While I might get a slight impact with the high performance requirement, I would still earn a lot of good stuff as a tradeoff.

Developing with VS2005 was a real treat, and when I've concluded my work , I took a step back and was wondering whether I could have achieved this with another programming language and a different development environment at the same or shorter time. Sure, unmanaged C++ would have probably give more cpu juice, but developing all of the stuff that was  in the list, would have taken me a lot more effort with C++. There were other possibilities that I had considered like Java, Perl and Python but all of them had drawbacks compared to .Net.  Perl and Python are somewhat Gui challenged, sure there are some Perl and Python Gui Toolkits, but they are not always supported by a proper designer and would probably require a more complicated installation scheme. And as for Java , well I couldn't find any study or survey that does an apples to apples compare of Java penetration rate versus the .Net runtime penetration rate on Win machines, but an internal hunch told me that .Net is more widely spread. Moreover having a simplified .Net installation capability versus none for java had made me remove Java as a software language candidate. I could however be criticized for not taking into consideration Java's cross platform advantage, but .Net has its renegade unix/Linux brother known as Mono (a .NET linux run time engine) . The only difficulties with Mono would be to introduce a new setup flow , because ClickOnce would probably not work on a linux machine and I also had to Tweak the Windows.Win32 to work with linux as well. But having these two relatively easy tasks would have put me in a position where I could use my code on a Linux or MacOS box as well. In case you are wondering whether the winforms might have an issue running on a Linux box, stop wondering, they work great!



So here is a list of all of the good stuff that I used and probably saved me a lot of time by selecting .Net as my programming language.
I used VS2005 UI designer to design my application forms.
I used System.Net.WebClient for reporting the distributed clients progress.
System.Diagnostics was used to control the process` priority.
System.Net.Mail was used for sending emails
System.Security.Cryptography was used for symmetric encryption and decryption
Microsoft.Win32.RegistryKey was used for user properties persistency.
MySql.Data for connecting to a MySQL db.
ClickOnce publishing tool was used for Setup and Version upgrades
Dotfuscator's community edition was used to obfuscate the compiled code

And there are probably a lot more C#/VS2005 features that I subconsciously used  that saved me a lot of time.

And I have a small confession to make, my client progress reporting backend server is in (god forbid..)  php. But that's because I was too lazy to convert my hosting account to windows. If it was in windows I would have gone with ASP.Net for sure.

To conclude this post, I would just say that today, in my opinion, C# and VS2005 is the most productive programming language and development environment for producing main stream, non niche, solutions. But that's just me. Be gentle with the comments ;-)

 

Roiy

Posted Sat, Sep 15 2007 2:50 AM by dotgrid | 5 comment(s)

(Web) User Interface Design Patterns

Discovered this hidden gem, thought of sharing this for the sake of User Interface Humanity.
We all know of the excellent design patterns (by GoF ) for solving code design problems.
Well, Yahoo took the concept a little further by presenting design patterns for us UIs challenged code developers.

It's going to be my first stop from now on when thinking on a UI layout for my apps.

 

 

Posted Mon, Sep 10 2007 10:23 PM by dotgrid | with no comments

Tip : c# extracting version number

Comes in handy if you want to implement an automatic application upgrade component.
By calling
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion
You'll get in return which current version is running and can alert the user that there is a new version available.
(The version can be set in a publish wizard or on a setup project in visual studio) 

While dubugging , the CurrentDeloyment object is not available so make sure you wrap the above call with
if (System.Diagnostics.Debugger.IsAttached == false)

Have fun.
Roiy

Posted Sat, Sep 1 2007 3:47 PM by dotgrid | 4 comment(s)

Filed under: , , , ,

Web Development Cheat Sheet
Great job by the realsoftwaredevelopment.com guy.
Below is a partial list, click here for the full list.   

JavaScript

JavaScript Cheat Sheet

Addison-Wesley's JavaScript Reference Card

JavaScript Quick Reference

JavaScript and Browser Objects Quick Reference

JavaScript in 10 Minutes

CSS

CSS Help Sheet

CSS Shorthand Guide

CSS Cheat Sheet

Cascading Style Cheat Sheet

CSS Cheat Sheet

CSS Quick Reference

Design 215 CSS Quick Reference

CSS Level 1 Quick Reference

CSS Level 2 Quick Reference

CSS Property Index

HTML/XHTML

HTML Help Sheet

XHTML Cheat Sheet

HTML Cheat Sheet

HTML Character Entities Cheat Sheet

PDF HTML Cheat Sheet

HTML & XHTML Cheat Sheet

HTML Tags

Reference HTML Cheat Sheet

HTML Tags Cheat Sheet

AJAX

What’s Ajax? Cheat Sheet

Prototype Cheat Sheet

Scriptaculous Combination Effects Cheat Sheet

Scriptaculous Cheat Sheet

AJAX for ASP.net Cheat Sheet

ASP.net AJAX Client Life-Cycle Events

MooTools Cheat Sheet

Colors

RGB Hex Color Chart

HTML Color Codes

Color Reference Guide

 

Posted Wed, Aug 29 2007 9:56 PM by dotgrid | 3 comment(s)

User Friendly UIs - Doing the extra mile

There are some simple basic rules to follow when designing a web page. One of them is keeping your customer happy by
not surprising him with unwanted results. A lot of content sites , which their content expands beyond the window frame also have an auto refresh mechanisms. And this leads to a deadly mixture where you scroll down to the lower parts of the page , you begin reading a paragraph and the "Pooof" the page turns white, the page refreshes and the view is back at the top of the page. Well now of course, you have to scroll down again and find the paragraph you read just a second ago. 

The solution is not complicated , it consists of just checking the page's Y scroll offset before a page refresh occurs. [See JS code below]
So from now on when you insert an automatic page refresh, checking for the pages Y offset before refreshing is just telling your customer you care...

 

...
...
...
function doLoad()
{
    setTimeout( "refresh()", 2*1000 );
}

function refresh()
{
  // use the following for cross browser compatability
  //(document.all)?document.body.scrollLeft:window.pageXOffset; 
  //(document.all)?document.body.scrollTop:window.pageYOffset; 
  if("0" == document.body.scrollTop)
    {
      window.location.href = sURL;
    }
  else
    {
      //at this point , the user scrolled
      //down and is probably reading the page
      //either we double the refresh rate time ,
      // or just hang in a few more seconds/minutes
      //to let him finish. In this specific case
      //we're increasing the refresh time to 2 minutes
      setTimeout( "refresh()", 120*1000 );
     }
//-->
</script>
</head>
<body onload="doLoad()">
...
...
...

Posted Tue, Aug 28 2007 10:53 PM by dotgrid | 3 comment(s)

Filed under: , ,

Loading external poweshell dll / dlls

If you want to use an external .Net lib in powershell, here is a simple example... 

$lib="C:\yael\YaelExample\bin\Debug\zrlabs.Yael.BasicFilters.dll"
[Reflection.Assembly]::LoadFrom($lib);
[System.Reflection.Assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
$img = [System.Drawing.Bitmap]::FromFile("c:/tempcat.jpg");
$textWaterMark = new-object zrlabs.Yael.BasicFilters.TextWatermarkFilter;
$transformedImage = $textWaterMark.ExecuteFilter($img);
$transformedImage.Save("c:/temp/cat_watermark.png");

Mostly a "note to self"...

Posted Sat, Jul 14 2007 10:49 PM by dotgrid | with no comments

Filed under:

Terminals - A WTS/Remote connector alternative

If your frequently connect remotely to Windows based servers , than the following product can make your job a little bit easier.

Instead of constantly mstsc-ing , you can simply use this tool to save connection profiles and connection groups ,it also supports connection tabs. Another nice feature is the "Connect to Console" check box (I wonder if they are ever going to automatically connect you to the console session if the 2 regular ones are occupied)
Download from here http://www.codeplex.com/Terminals/

[Update]: The full screen mode is a bit dodgy, and doesn't always work. To make sure it works properly, switch to full screen mode before you log in ..

 

Nice work Terminals guys!!

Roiy

Posted Wed, Jul 11 2007 11:41 PM by dotgrid | with no comments

Using Workflows to visually construct project Build/Compilation flows.

Code [Here]

I happen to participate in an agile workshop where some automated build tools were discussed ,visual build  was one of them. I liked the idea of visually constructing  the project build instead of using batch files or VS IDE build actions that are hard to execute or to maintain. In "visual build" you simply visually drag and drop activity blocks from a tool box to construct the build process. I wanted have my own "Visual Build Designer" , and it was very obvious that I can utilize Windows Workflow to do that.
My basic required activity blocks were:
  • Extract the latest version from Source Control  [VSTF]
  • Build the project
  • Send an email with the results
Another requirement was that the process builder (the actual person that drags and drops the activity blocks) would not have to write a single line of code. He would have to set in the activity blocks properties of course , but he wouldn't actually need to add additional c#/vb.net to support the basic functionality.
 
So the first step was to read about writing customized activities . This  was a good resource to start.
The second step was to read about extracting code from VSTF source control. Here is a good place to start.
Next step was to write the customized activities.
I wrote three customized activities
  • A source control code extractor - GetCode.cs
  • An MSBuild executer - MSBuild.cs
  • A mailer - Mailer.cs
here is how (in short) the GetCode.cs imports the source control
String tfsName = TFSServer;
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsName);
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer
));
Workspace workspace = null
;
workspace = versionControl.CreateWorkspace(WORKSPACENAME, versionControl.AuthenticatedUser);
WorkingFolder myworkingfolder = new WorkingFolder
(TFSArea, SCPath);
workspace.CreateMapping(myworkingfolder);
workspace.Get();
versionControl.DeleteWorkspace(WORKSPACENAME, versionControl.AuthenticatedUser);

The TFSServer,tfsName and SCPath are activity properties which are defined as so in the code
public static DependencyProperty SCPathProperty = DependencyProperty.Register
(
"SCPath", typeof(string), typeof(GetCode));

[Description("The local folder to get the code")]
[
Category("Dependency Properties")]
[
Browsable(true)]
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string SCPath
{
get{return Convert.ToString(base.GetValue(SCPathProperty));}
set{base.SetValue(SCPathProperty, value);}

and that makes them visible in the designer like so
[WF1.jpg]

So here are the properties of all of the components
  • GetCode - VSTF Server, Source Control area path, and the path to dump the files into
  • MSBuilder - MSBuilde exe path, Project path and Project file name
  • Mailer -  To, Subject, Body , SMTPHost
 
 
 
 
 
Now all that's left is to open a new workflow project, add these activities to the tool box , drag them into the designer window and finally bind the properties of the activities.
 
 
 
 
 
 
 
The binding are as follows:
  • The msbuilder ProjectPath property is binded to the getCode SCPath property, which means that the msbuilder looks at the same directory where the source controller brought the code to.
  • The Mailer branch is binded to the the MSbuilder BuildResult property , if the build succeeded than the BuildResult Property would be set to true and the successful branch would be taken and vice versa.
  • The mailer Body Property is binded to the MSBuild  BuildOutput property which means that the emails body contents would actually be the output of the MSBuild process.
All of the other properties (such as TO, SMTPHost , subject , etc) would be have to be set by the process builder (the person using it)
 
That's basically it, all that's left to do is to run the process and wait for the result email.
 
Build Failed Email
 
 
 
 
 
Build Success Email
 
 
 
Next steps would be to to add more build related activities such as publish(some kind of xcopy), ftp , package, etc.
Which I hope to accomplish soon.
 
Any Feedbacks ? Can you think of other build related activities that would be valuable ?
Roiy

Code [Here]

Posted Sun, May 20 2007 1:43 AM by dotgrid | with no comments

From sourceforge.net into real life
Back in the days , when I had a real physical Linux box (I Use vpc/vmware these days), I've downloaded and compiled one of the first non-ascii-like Linux games.
The game was called Tux Racer and it was basically a downhill ski ride of the Linux penguin figure. Today , while I was walking around the mall with my little daughter , we've went into the games arcade , and there by the side stood a real life tux racers games box.
There is much that's going right now on where are all of the open source millionaires, I don't know if they made millions from this arcade machine, but it was nice seeing something actually materializing from a sourceforge.com project into a real life business object.
 
 

Posted Sat, Apr 28 2007 1:06 AM by dotgrid | 4 comment(s)

Disabling Windows System messages balloons

(Self note)

Want to remove the nagging system notification balloons coming from the systray?

regedit the following
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
Create a new DWORD value by the name of EnableBalloonTips , leave it as 0 and you're good to go.

 

Posted Thu, Apr 26 2007 11:23 PM by dotgrid | 1 comment(s)

.NET image enhancments library (LGPL)
I started getting more and more interested in image (as in gif,jpg and png) manipulations. I've taken a digital imaging processing course as part of my masters degree. It was cool , learned alot about things fourier transform and it made me wonder what kind of image filters are there across the web , and especially what's available to be used in the .NET realm. The System.Drawing ns doesn't give you much. you can do thing like flip and 90 degrees rotation, but for practical web usage you'll probably need more sophisticated (but still basic) stuff like DropShadow, WaterMark , grayscale and other image filters to make your web sites look better and more appealing. I googled for some resources and found some examples, but there wasn't a complete .NET library that encapsulated all of the common used and required image filters.
So I've created one , named YAEL which stands for Yet Another image Enhancement Library.
Currently it consists of the following filters
  • Resize
  • Rotate
  • Grayscale
  • Rounded Corners
  • Boxing
  • Drop Shadow
  • Polaroid frame
  • Text and Image warter marks
    Here are some samples (took a picture of my cat as a model..)
     
     
     
     
     
     
     
     
     
     
    The library and sources are being released under the LGPL which basically means that you can do anything with it  (download is available from the YAEL site)

    Any comments , or any other commonly used filters that you can think of ?
     
     
     
  • Posted Sat, Nov 25 2006 6:31 AM by dotgrid | 14 comment(s)

    making form submitters life easier.
    I stumbled across a very simple web form that included 5 select boxes.
    In my endless pursuit of providing forms that are actually easy to use and to make my web forms users life happier, I wondered how can I improve that form , so I figured why not save the customers last select box selections , so that they their old selection would be initialized by default each week they when come back to re-submit the form.
    I Looked for some open source javascript client that keeps this information as cookies. Couldn't find one , so had to make one.
    I tried to have it as simple as possible so all you have to do is to add an additonal attribute like so:
    <select id="sel1" onChange="UpdatePersistancy()" savestate="1">
    and calling the update and initialize function of course.
    The solution is based on scanning the select tags looking for savestate attributes, than creating a cookie for each one that should be saved, and storing the value in the cookie. The initializer functions (this should be called when the page loads) also scans the select tags and try to look for an appropriate cookie with a value. If one was found than it just initializes the selection. I'm keeping the inner text rather than the index or the value since I figured that indexes can change and so does internal value. The only thing that's left unchanged and visible to the customer is actually the option's inner text.
    It's here if you need this kind of a solution (if you want to save the selection box state). Although it doesn't support multiple selection , just one. And there are some other improvements that can be made (maybe also extending this to radio buttons, check boxes, etc)
    Enjoy.

    Posted Sat, Sep 16 2006 5:35 PM by dotgrid | with no comments

    Can you recognize your favorite blogger if he was standing right next to you?

    I was envy of Mono's and Gnome's blog communities having a nice and much more down to earth web blog community page
    where their members can see how their favorite blogger actually looks.
    [See mono's and Gnome's examples].
    So I thought why not do the same for the (MS based, C# ,VB.NET) .NET communities.
    I've created the following .NET related blogs aggregation site DotNetClan.com
    For now it has my favorite .NET bloggers, but if you want to join in , just send me your blog URL address. roiy _dot_ zysman _at_ gmail.com (adding a mugshot is not mandatory but highly recommended ;-)

    Roiy

    Posted Sat, Jan 7 2006 1:05 PM by dotgrid | 1 comment(s)

    Filed under: ,

    A great .NET + Open Source PPT.

    Monoppix is all about .NET and Open Source , so I was very happy to get an email from Josh Gough telling me about the ppt he wrote on these matters.
    The presentation talks about open source and cross platforms development and deployment, while keeping everything within the .NET context.
    If you're not familiar with .NET on other platforms or if you wish to extend your Mono knowledge , this presentation would give you a good basic start.
    The ppt was probably made for crowd presentations but it is also good for self reading. It has lots of examples and covers a wide range of levels, from very basic to advanced.
    You can download the ppt from here

    Josh is currently working as a senior systems analyst with the Centers for
    Disease Control and Prevention in Atlanta. If you want to contact him or send him feedback on this ppt go to
    http://www.ultravioletconsulting.com/

    Roiy

    Posted Sat, Aug 27 2005 1:33 AM by dotgrid | 1 comment(s)

    Monoppix V1.1.8.0 released !

    We just released Monoppix V1.1.8 . Downloads - [torrent] (see below for more download options)

    The main new features of v1.1.8 are:
    - mono 1.1.8
    - libgdiplus 1.1.8
    - xsp 1.0.9
    - monodevelop 0.7
    Additions:
    - Mplayer to allow viewing our
    tutorials from Monoppix
    - Hello world video tutorial included in the image
    Notes:
    Native mono Windows.Forms class libraries are available without wine thanks to Mono's v1.1.8 implementation.

    The last bit means that you can compile and design your .NET winforms applications on VS2003 , take the exe file and run it on Monoppix to see if it works on Linux with Mono (Most chances that now it would !!!) [Example]

    If you don't have a torrent client installed and you're running some kind of WIN*  you can try this to download
    (It basically installs a lightweight BT client and begins the download.)
    Regular FTP and HTTP mirrors will be available later today...

    Roiy

     

    Posted Thu, Aug 25 2005 12:00 AM by dotgrid | with no comments

    More Posts Next page »