Sunday, June 27, 2010

WPF vs. Silverlight Differences

I just Google random things that interest me sometimes. Today it was "Awesome WPF". This lead me to this post:
http://blogs.msdn.com/b/jimoneil/archive/2009/06/12/awesome-wpf-silverlight-guidance.aspx

Which lead me to a detailed comparison sheet of WPF vs. Silverlight:
http://wpfslguidance.codeplex.com/


Enjoy!

Friday, June 18, 2010

The truth behind Hungarian Notation

I am a real admirer of Charles Petzold's programming windows (and in fact all of his books). But I never knew :

http://www.joelonsoftware.com/articles/Wrong.html

Good to know the truth.

Plus really useful information about naming conventions.

Enjoy!

Friday, June 11, 2010

.NET Trick Question

What do you think will be the output of the following code:

    class Program
    {
        public class StringClass
        {
            public string TheString { get; set; }
        }
 
        static void Main(string[] args)
        {
            List<StringClass> stringClassList = new List<StringClass>(){
                new StringClass{TheString="asdf"}
            };
 
            IEnumerable<StringClass> stringClassEnumerable = stringClassList;
 
            IEnumerable<StringClass> AllItems = stringClassEnumerable.Where(item => (true));
 
            stringClassList.Add(new StringClass { TheString = "fdsa" });
 
 
            foreach (StringClass item in AllItems)
            {
                Console.WriteLine(item.TheString);
            }
 
            Console.ReadKey();
 
        }
    }


If you think the output is :
asdf

You are wrong.
It is :
asdf
fdsa

This is because the result from the where extension methods is deferred till you try to access the result (in this case the foreach loop).

Enjoy!

Copy Source as html for Visual Studio 2010

Any .net programming blogger should definitely check it out:

http://sandrinodimattia.net/blog/post/Copy-Source-as-HTML-in-Visual-Studio-2010.aspx

Update: As pointed out on twitter : https://twitter.com/jameskovacs/status/29095602121 removing this plugin really sped up my VS2010 experience. So no Copy as html for me :)

Enjoy!

Thursday, June 10, 2010

Backing up SQL Server databases using code

A new article on code project:
http://www.codeproject.com/KB/database/sqlbackupprogressasync.aspx

Check it out!

Enjoy!

The need for events and why delegates should not (or should be) used in a chained subscription

In case you are familiar with the syntax surrounding delegates and events in c# you might have wondered why you need to use the event keyword. The reason is encapsulation.

In below discussion delegates are the objects that were defined without the event keyword.

Subscriber encapsulation
Delegates allow syntax of the form :
someDelgate = someMethod;
This will allow a rouge subscriber to remove all previous subscribers.
Events allow assignment only in the encapsulating class.

Publisher encapsulation
Delegates allow syntax of the form :
someObject.SomeDelegate();

That is anyone can invoke public delegate members. Events only allow the encapsulating class to invoke the event.

Additionally
You can initialize events so that you do not need to do null checking before invocation using the "= delegate {}" syntax.

PS: this was written on my iPad. Definitely pulling out my laptop in future.
It's not bad...just weird.

Wednesday, June 9, 2010

Best software for PDF reading on the IPAD

I got an Ipad. I bought it for just one reason ... reading PDFs. My job is such that I need to keep myself updated with the latest and greatest technologies in .NET. So the first thing I did was get PDF readers:

Here's what I reviewed and why I left them:

  • Air Sharing HD: Kept crashing 
  • iGoodReader: You cannot view two pages at a time. For pdf viewing it is one page to second page only. And when code listings are between pages this becomes "Annoying"
  • iTech PDF Reader Pro: Laggy between page changes. Also couldn't browse pdf bookmarks. Above all a bad anti aliasing.

Here what I stuck with: 
iAnnotate PDF

I love it with ALL MY HEART! With Good Reader and PDF Reader Pro i knew these shortcommings the moment I installed them (and concerned about the iPad purchase). This software however blew me away. It is ULTRA responsive. Completely worth it!


Advantages:

  • One huge advantage (which I didn't even consider possible in iPAD) it has is the ability to highlight (and generally annotate) PDFs. I mean for real...into the pdf file so that it is maintained even when you view it with adobe reader on your PC.
  • You can open multiple pdf documents simultaneously ... which is simply amazing. And therefore browse them side by side
  • Search all the PDF (text) in the library!
  • Once you exit the application and open it up again ... since it is tab based .. it will open all the books that were previously open in the tabs ... and on the last viewed pages. A great time saver! Just exit -> Ipod -> back ... makes reading on this the best experience ever I have had in a long long time (much much better than adobe reader on the PC)


Note:
Also once you import the file it does some preprocessing (only once per file) ... so you need some patience ... but after that boy does it work. You can fly between HEAVY pdf pages with ease.

Thanks guys (if you ever read this :))

Enjoy!

Sunday, June 6, 2010

Sybase ASE 15 .NET Drivers possible issues

These are just good tips to keep in mind anyways when using Direct ADO.NET interfaces. But here goes:

  • Always surround your Connection with Using. (this calls dispose on finishing usage)
  • Note in case you call connect be sure to balance it with a disconnect as well 
  • Set the connection timeout before you connect
  • Set the command timeout on your command
  • In case you do heavy data import. Try to set the local variables above the try block to null in the finally.
Enjoy!

Wednesday, June 2, 2010

WPF / Silverlight Layout Panel specifically for data entry forms

A great utility:

They also present the case why using the StackPanel and the Grid is insufficient for the requirement of a user form.

Enjoy!

Tuesday, June 1, 2010

On WindowStyle set to None the maximized window hides the taskbar

Was going through the sample code in "WPF Control Development Unleashed" i saw that the custom chrome window would hide the taskbar on maximize. Lucky someone already had it fixed:
http://blogs.msdn.com/b/llobo/archive/2006/08/01/maximizing-window-_2800_with-windowstyle_3d00_none_2900_-considering-taskbar.aspx

Actually I got to it from this article:
http://blogs.msdn.com/b/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
It contains all you need to know about customizing the title bar in wpf application

Enjoy!