Category: .NET

First toughts about Windows Azure

Posted on 12:33pm 10/28/2008 by Bruno Silva in .NET, Programming, Web, Windows

After the yesterday’s announcement of Windows Azure, the brand new cloud-based Windows, today I started reading a little bit about it. This new platform seems promising, and I’ll write a bit about it in some of my next blog entries.

First of all I’ll talk about the Windows Azure, which is a part of the Azure Services Platform. It allows you to run applications and store data on the cloud (replace cloud by “a bunch o Microsoft data centers”). You can reduce the Total Cost of Ownership (I don’t say eliminate, because you will have to pay for the service), because you don’t have to build/buy/care about the infrastructure. You contract a service that is payed based on usage, so you can get scalable solutions even for start-up projects for which is difficult to predict the needs.

Computing

You can have 2 kind of applications running on Windows Azure. Web applications and workers (asp.net applications vs. something like the Windows services).

Web Role

Web applications are just like any web app that you write nowadays (receiving HTTP requests and responding) but in order to take advantage of the farm of virtual servers that Windows Azure provides you, your web applications should be stateless.

Well, not really stateless, but the state must be stored in a particular way. If you used session variables stored in the web server, you app would be attached to a particular server (the one to which the first request was made), this way any load balancing decision that lead your end-user to another server would lead to loss of that session data in the subsequent request… The right way to do it is to use cookies or (to prevent overhead on communications, or for security concerns) Windows Azure storage, which is available from all the virtual servers that serve your application.

Worker Role

Another option is to have an application that does some background work. They can’t have inbound communication, but can connect the outside world. They can read data from the Windows Azure Storage, and in the typical scenario, they get data from queues (which is one of the 3 storage mechanism of Azure). This kind of application can run indefinitely just like a Windows Service.

Storage

What about storage? There are 3 kind of storage that I’ll briefly refer.

Blobs - to store large amounts of unstructured data such as images, movies, binary data, etc. You can associate meta-data to blobs such as location and tags for a photograph or title of an audio file, etc. Whatever you need.

Tables - not regular relational tables, just a hierarchical set of entities and properties. You can access it’s data using LINQ and not SQL (to reinforce that this isn’t an SQL table :P)

Queues - As I wrote before the main purpose of queues is communication to and between applications instances with the worker role

All the storage is replicated 3 times in order to tolerate faults (at least some of them).

As far as I read, I wasn’t able to try it yet, the Windows Azure SDK allows you to develop your applications locally and getting some guaranties that when you deploy it into to the cloud it will work smoothly. Locally you can debug you application, which you won’t be able to in the cloud.

Next: .NET Services, SQL Services and Live Services

C# Yellow Book by Rob Miles

Posted on 8:59am 10/20/2008 by Bruno Silva in .NET, Programming

Rob Miles (a MVP from UK) has made available in his website a C# book for beginners that is used in this university in the First Year programming course. Download the PDF and happy reading.

Using Neural Networks for Classification

Posted on 7:18pm 10/15/2008 by Bruno Silva in .NET, Artificial Intelligence, Programming, Software

During the last weeks I’ve been doing some research related to my Master thesis. One of the topics I’m studying is Unsupervised Machine Learning. The main goal is to have a piece of software that given a training set (a set of examples representative of the whole population) allow the software to accept input that it has never seen before and behave as expected.

Imagine for instance a concept called Color Classifier. We usually have several named colors such as red, green, blue, yellow, gray, orange, etc.  You have different flavors of each color, and you can consider different combinations of RGB colors the same color. How  can you, given a RGB Color code, name that color?

One approach is using Neural Networks (which is a unsupervised learning method) for classification.

I won’t talk about the details of Neural Networks algorithms, since it is the reason why many people avoid this kind of approach: complexity. I’ll just show you how, with a library that hides the implementation details, you can use them.

NeuronDotNet is a .NET library which allows you to use Neural Networks algorithms as a black box. They have some samples which can guide you, as they guided me.

The algorithm I’m using is called Self-organizing Map (SOM). The main idea is to generate a 2D map which topology (dispersion of the points and their positions) is based on the relation between the input data. Back to the example, from a set of random colors which can be represented as a vector with 3 dimensions (input), we generate a map with 2 dimensions, where similar colors get close to each other and completely different colors are set apart. The picture bellow represents the results.

(Left: input, Right: 2D map that results from the algorithm)

The number of colors that will be recognized (the number of neurons of the output layer) can be customized in the neural network configuration, prior to the training phase. In the example above I recognize 25 different colors.

Once the SOM algorithm runs in training mode, the resultant neural network is able to classify new colors into the different slots of the map. If you name each slot with the name of a color, you get a color classifier. In the example above you can label several flavors of green, blue, red,  brown, pink, etc. In each slot you have several stripes that represent the colors from the training set and in which slot they ended up.

In the demo application the basic steps are:

  1. Play with the different settings (or leave them alone… take special attention to Layer Width/Height and Set Size)
  2. Generate Training Set
  3. Start (Learning)
  4. Choose Color (to classify)
  5. Classify (the neuron that best matches the selected color will be highlighted with a red border)

Download and try the Color Classifier. Keep in mind that a lot of the source code is UI-related, and not Algorithm-related, so don’t be afraid!

Download Demo | Download Source Code

XNA Game Studio 3.0 beta | Now Live!

Posted on 9:01am 9/17/2008 by Bruno Silva in .NET, Programming, XBox 360, XNA

This release represents the beta of Microsoft XNA Game Studio 3.0, which enables hobbyists, academics, and independent game developers to easily create video games for Windows and the Microsoft Zune digital media player using optimized cross-platform gaming libraries based on the .NET Framework.

The XNA Game Studio 3.0 Beta is a chance to get an early look at XNA Game Studio 3.0, and provide feedback on the product that is currently in development.

in XNA Creators Club

Now it supports Zune with the 3.0 software version. The CTP version didn’t have support for XBOX 360 development, now it is fully supported :) Finally we can use Visual Studio 2008 for XBOX 360 development! Other features that please me are the Rich Presence support (that message in XBox Live that tells you what are your friends playing in the context of a game. eg: level, dificulty,etc.), and Invites for joining you in a multiplayer game.

Data Visualization Charts (Part 3 - WCF Webservice Data Source)

Posted on 10:51am 9/09/2008 by Bruno Silva in .NET, Programming, Silverlight, WCF, Web

Since I’m having trouble to get enough time to complete these post series (1 post was left), I’ll just leave you the source code.

It contains a sample of a WCF service that uses LINQ to SQL to retrieve some data from a SQL Server Database (AdventureWorks) and return it as XML. I’ve also some commented code in order to add a JSON endpoint.

Download Source Code

© Bruno Silva | Powered by Wordpress