My Article on Dotnetslackers.com: Bulk Operations Using Oracle Data Provider for .NET (ODP.NET)

My first article for Dotnetslackers.com is up. Here’s an excerpt:

In a typical multi-tier application, one of the biggest performance bottlenecks is the overhead of making round-trips to the database. Minimizing these round-trips is often the first area you should look at during performance tuning. Fortunately, the Oracle Data Provider for .NET (ODP.NET) makes it fairly easy to do this by providing several built-in methods to write and read data in bulk.

You can view the article here.

Finds of the Week – 10/24/2007

.NET

  • Improve ODP.NET Performance (Mark A Williams, via Oracle Magazine) shows how Connection Pooling, Controlling Fetch Size, and Statement Caching can be used to maximize performance with the Oracle Data Provider for .NET.
  • Did you know that you can profile a selected Unit Test in Visual Studio Team System? Read more at Profiling a Unit Test (Noah Coad, via blogs.msdn.com).

Tools

  • Sysinternals (now part of Microsoft) has released a new version (v11.02) of their extremely useful Process Explorer utility. This is one of my must-have utility on any new system.
  • Process Explorer

  • FileZilla is an open source FTP utility for Windows. It's free and has all the features I use. What more can one ask for?
  • Filezilla

  • I signed up for Mozy two weeks ago. The price is right: $4.95 per month for peace of mind. However, it’s been 2 weeks and the initial backup is still only 50% complete!! I have a Verizon FIOS connection with 2000 Kbps upload speed and about 37GB of data to backup. I’ll post an update on how restores work whenever this thing finishes.
  • Mozy

Windows Mobile / Pocket PC

  • Google has just announced free IMAP for Gmail! Unfortunately, it's not available on my Gmail account yet. I am hoping that the IMAP with Windows Mobile Outlook is better than Gmail mobile (via Pocket IE or Opera Mobile).

Blogs

  • Scott Hanselman's Computer Zen is one of my favorite .NET related blogs. I don't know how he does it, but Scott often writes several detailed posts a day. Don't forget to check out his Tools List post.

Miscellaneous

  • Did you know that the best Wikipedia content is often from anonymous "good samaritans"? "Anonymous contributors with a single edit had the highest quality of any group." Read more here.

And Now, Something Different

Alexa.com's current list of 100 Top Sites in the United States (sorted by traffic) has a couple of interesting entries. In addition to the familiar Yahoo!, Google, and Myspace, there are two Vietnamese related sites: VnExpress at number 70, and Vietfun, at number 80. Besides these two sites, there are no other non-English or minority-centered web sites on the list that I could tell.

Possible explanations:

  • Alexa rankings are way off base.
  • Vietnamese Americans are using the net much more than any other minority groups (unlikely). If this is true, there is an untapped market here.

Anyone else has an explanation?

alexa-rankings-usa-1

alexa-rankings-usa-1

Samsung SCH-i760 Windows Mobile Phone Now On Verizon Wireless Web Site

The i760 is now available for order through Verizon Wireless web site. The retail price is $519 but if you can take advantage of various discounts (New Every 2, 2-year contract, data plan), the price will go down to $99.

Samsung Windows Mobile 6 Phone SCH-i760 on Verizon Wireless

The SCH-i760 is a Windows Mobile Pro (Pocket PC) 6 phone, featuring a backlit QWERTY keyboard, 1.3 Megapixel camera/camcorder, microSD, WIFI, and bluetooth.

I still have a few more months to go before my New Every 2 discount will kick in :-(.

Samsung SCH-i760

Related Posts

Finds of the Week – 10/17/2007

As an attempt to make this blog appears more busy:-), I will begin my "Finds of the Week" series. Each week, I will share miscellaneous finds and thoughts I ran into that are related to mostly .NET development.

Here are the finds for this week:

.NET

  • Parallel Performance: Optimize Managed Code For Multi-Core Machines; by Daan Leijen and Judd Hall; via MSDN Magazine. In a few years' time, I predict that most new PCs will be multi-core. This article talks about the new Task Parallel Library (TPL) and provides code samples.
  • document.f.q.focus(); The Billion Dollar Line of JavaScript (by gst, via blogstorm.co.ok) talks about how many people use the Search Box on their browser to navigate to various web sites, instead of typing in a URL, and how this practice translates into revenue for Google. Interesting read.
  • alessandro pointed out that and IMG element with an empty src attribute will call the browser to make a request to the default document (usually default.aspx).
  • Understanding Windows Workflow Foundation (by razi bin rais, via Codeproject.com) is a nice overview of Windows Workflow Foundation.
  • Where are the basic controls in Silverlight 1.1? When I started experimenting with Silverlight recently (see my Silverlight Hello World application), the first question that came to my mind was: where are all the basic controls such as button, checkbox, textbox, etc?

    XAML Intellisense drop-down

    Don't worry! Apparently, they are not there because it's still an Alpha release. According to this post from Tim Sneath, the following controls are planned to be included in the released version of 1.1: Button, TextBox, Scrollbar, Slider, ListBox, CheckBox, RadioButton, ComboBox, and UserControl (no TreeView, RichTextBox, or DataGrid).

 

Tools

  • Probably old news to most CSS pros, but just in case you have not heard, FireBug is a very useful extension for FireFox/CSS development. Highly recommended if you ever work with CSS. I could have saved countless hours debugging HTML/CSS issues with this tool.
  • Notepad++ is a new addition to my toolset. Supports syntax highlighting, regular expression search/replace, Unicode, Macros, and is light-weight.

Windows Mobile / Pocket PC

Blogs

Miscellaneous

  • I am pretty bad with keeping in touch with people, and I have found that LinkedIn makes it fairly easy to keep in touch with past colleages. Last week I had some free time so I decided to look up old colleagues on LinkedIn. It was great to hear from many people I worked with years ago. I found many people by simply searching on the name of the company we worked for.

And Now, Something Different

Check out the Windows Live Maps Bird's Eye view below. See the black car entering the cul-de-sac? That's me and my car.

Microsoft Windows Live Maps - Chinh's Car

How do I know that’s my car? Well, for one thing, my car is black. But the real reason I know it’s me is that a moment later, my garage door opened half-way… as I was about to drive into the garage:

Microsoft Windows Live Maps - Chinh's Car

At first glance, it seems to be an amazing coincidence (like one-in-a-million amazing). What is the chance that Microsoft’s Bird’s Eye low flying plane would fly across my house and snap pictures just as I am about drive into my garage? However, after further calculations, it turns out that the real probability is around 1/8640 (5-second window over 43200 average seconds of day-light). Still a very small chance, but certainly not lottery-winning “amazing”.

My Silverlight 1.1 Hello World Application

Update 1/27/2009: I posted an updated version of this article targeted for Silverlight Runtime 2.0 here

Imagine being able to author rich Internet applications in your .NET language of choice, without having to mess with Javascript, cross-browser compatibility issues, or ActionScript. That’s the promise of Microsoft Silverlight 1.1. In this article, I will document my attempt at creating a Silverlight 1.1 “Hello World” application. My Hello World application is a little bit more fancy than the typical one… this one involves some animation, and drawing a few shapes from code.

Silverlight Hello

If you are new to Silverlight, Silverlight 1.1 (currently in Alpha) is the version that will include the .NET CLR and allow you to write Silverlight code with .NET languages such as C#.

Most Silverlight 1.1 C# examples I found on the web use the XAML file to declare and set object properties. In my example, I am going to create and draw most objects from the code behind c# class.

Installing Visual Studio 2008

If you don’t have Visual Studio 2008 already installed. You can download it from here. Downloading and installing Visual Studio 2008 to my Virtual PC took about 3 hours (1 for the download and 2 for the install).

Note: It’s possible to
develop Silverlight 1.1 applications with Visual Studio 2005
, but the process is not integrated as with Visual Studio 2008

Installing Silverlight Runtimes and Tools

Install the following runtimes and tools from here. I am linking to the main page instead of the individual downloads just in case the download links change.

  • Microsoft Silverlight 1.0 Runtime.
  • Microsoft Silverlight 1.1 Alpha September Refresh
  • Microsoft Silverlight Tools Alpha Refresh for Visual Studio 2008 Beta 2 (July 2007)

Create a New Silverlight Project

  • In Visual Studio, choose File/New/Project and select Visual C#/Silverlight/Silverlight Project. The Silverlight project type is added when you install the Microsoft Silverlight Tools above.
  • Give your project a name.

Creating a new Silverlight Project

Silverlight Project Files

After the project has been created, you are presented with the default Page.xaml file:

Page.xaml

Your Solution should now have the following files:

Page.xaml

The two files that you will be working with are Page.xaml and TestPage.html. Page.xaml stores the markup for the design elements (for more info on XAML, see this MSDN article). TestPage.html is the regular HTML page that will host the main Silverlight object. Silverlight.js is the Javascript helper file for Silverlight applications.

For our example, we will be adding code to Page.xaml.cs. This is what Page.xaml.cs looks like initially:

Page.xaml

Add Some Code

Ready to write some code (complete source code at the end of the article)? First, we are going to add a Storyboard element to our Page.xaml. This Storyboard element serves as a timer for the animation we are going to display.

<Canvas.Resources
 class="kwrd">>
    <Storyboard x:Name
        class="kwrd">="mainTimer" Duration="00:00:00"
            class="kwrd">/>
</Canvas.Resources>

Then, we add some code to the Page.xaml.cs file (click here

for simple “Hello World” version… if you just want a simple Hello World app):

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace CdoHelloWorld
{
    public partial class Page : Canvas
    {
        /// <summary>Represents a cell on the grid</summary>
        private class Cell
        {
            public double X; //
                x-coordinate of cell
            public double Y; //
                y-coordinate
            public bool On; //
                True if cell is "on"
            public double Order; //
                Display order
        }

        private List<Cell> cells = new List<Cell>(); 
            class="rem">// list of all cells
        private int xSize = 26; 
            class="rem">// width of the grid, in number of cells
        private int ySize = 7; 
            class="rem">// height of the grid
        private int numCells; //
            total number of cells
        private int cellIdx = 0;

        public void Page_Loaded(
            class="kwrd">object o, EventArgs e)
        {
            // Required to initialize variables
            InitializeComponent();

            // Assign a random value to each cell 
            Random rnd = new Random(Environment.TickCount);
            numCells = (int)(xSize * ySize);

            for (int y = 0; y < ySize; y++)
            {
                for (int x = 0; x < xSize; x++)
                {
                    Cell cell = new Cell();
                    cell.X = x * (this.Width / xSize);
                    cell.Y = y * (this.Height / ySize);
                    cell.Order = rnd.NextDouble();
                    cells.Add(cell);
                }
            }

            string template = " "
                            + " x x xxxx x x xx "
                            + " x x x x x x x "
                            + " xxxx xxxx x x x x "
                            + " x x x x x x x "
                            + " x x xxxx xxxx xxxx xx "
                            + " ";

            for (int i = 0; i < template.Length; i++)
            {
                if (template[i] == 'x')
                {
                    cells[i].On = true;
                }
                else
                {
                    cells[i].On = false;
                }
            }

            // Sort the cells by the random values
            cells.Sort(
                delegate(Cell c0, Cell c1)
                {
                    return c0.Order.CompareTo(c1.Order);
                }
            );

            mainTimer.Completed += new EventHandler(mainTimer_Completed);
            mainTimer.Begin();
        }

        void mainTimer_Completed(object sender, EventArgs e)
        {
            // Get the next cell
            Cell cell = cells[cellIdx];

            // Draw the cell
            Rectangle r = new Rectangle();
            r.Stroke = new SolidColorBrush(Colors.DarkGray);
            if (cell.On)
            {
                r.Fill = new SolidColorBrush(Colors.Red);
            }
            else
            {
                r.Fill = new SolidColorBrush(Colors.LightGray);
            }
            r.Width = this.Width / xSize;
            r.Height = this.Height / ySize;
            r.SetValue(Canvas.LeftProperty, cell.X);
            r.SetValue(Canvas.TopProperty, cell.Y);
            Children.Add(r);
            cellIdx++;

            if (cellIdx <= numCells)
            {
                // restart the timer
                mainTimer.Begin();
            }
        }

    }
}

Here’s the simple version of the code:

TextBlock t = new TextBlock();
t.Text = "Hello world!";
Children.Add(t);

Firefox Bug and Workaround

There is a known problem that causes the Silverlight object to not show up in Firefox. To fix the problem, remove the DOCTYPE declaration from the HTML file. See this MSDN forum thread.

Deploying Silverlight Applications to Your Web Server

To deploy my application, I simply copied the files including the ClientBin directory to my web server. Any web server will do (the server that hosts my Hello World application is an apache server).

And Now, Ladies and Gentlements, My Hello World Silverlight App

Click here.

Source Code

Download complete source code for this article.

kick it on DotNetKicks.com