Wednesday, January 24, 2007

Windows Presentation Foundation


It's been a while since my last post. I guess I figured out I won't make a living out of this... he he, just kidding. Anyways, you know the holiday season and all, it's hard to sit down and write, so now, as I wait for the "Doble San Antonio" to come. I thought I'd write something.

Since .net Framework 3.0 (formerly winfx) was released I've been reading about it and now I'll post a little Hello World WPF application. There are tons of papers about WPF and XAML (Zamel) so I won't dig into it.

After I installed the .net 3.0 extensions for VS2005 I wanted to create my first Hello World application consisting in a simple form with a button that once clicked a MessageBox would appear with the catchy phrase, "Hello World". Simple right? Not as simple as it sounds, or at least, not as simple as it used to be.

When you start a WPF application you get the main form in the designer. There are a few improvements there like a rule for aligning controls and stuff. Then I went to my toolbox (many new controls) and drag a button into the form.

While doing this you can see what the designer is writing in XAML in a little window below the designer view. You can work either with the designer and the property page or writing the XAML code yourself.

So, once I had my button on the form I did the obvious thing to do, double clicked on it to write the handler for the OnClick event, right? WRONG!!! you can double click, triple click, and do as many clicks as you want and nothing will happen. After a few tries I discovered the Click attribute on the button tag (XAML) so I went and wrote the name of the function I wanted the button to fire up. After doing that I went to the code behind file and implemented that function (you can also write it in the XAML document). Keep in mind that this method uses the ClickEventHandler, sou you'll have to write it with a matching signature (object sender, CleickEventArgs e).
Finally, write the code to execute the MessageBox (like in 2.0) and voila!, your first WPF XAML app is working.

I added some other controls and stuff in my example, so feel free to download it and take a look at it. Any comments about it are welcome.

It's been a few days since I started to write the post, I did well in the "Doble San Antonio", thank you, and I also added some interesting functionality to the example like binding.

Read Full Post

Thursday, November 02, 2006

SQL Helper


If you’re still one of the few that don't use DeKlarit you'll probably like this tool. I called it SQL Helper, and basically what it does is create the SQL statements you need in order to INSERT, UPDATE, DELETE or SELECT your own objects to a database.

I've been having this idea for a long time now, but it was a few weeks/months ago that my friend Alvarenga introduced to me the PropertyInfo class and it all became clear then.
There are only a few rules you must be careful with in order to use this tool. First of all there’s a naming convention, there's always one, and I'll explain how it works with an example.
Let's say you have to manage Clients. You'll probably have a ‘Client’ class with properties like FirstName, LastName, BirthDate, and so on. In order to get the appropriate SQL statements you'll have to name a table ‘Client’ like your class, and all the columns in that table must be name as the class' attributes. So, for our example, you'll also have a ‘Class’ table with FirstName, LastName and BirthDate as columns/attributes.
If you created that scenario you'll be able to call all the functions from the DDLStatement class.
For the UPDATE, DELETE and SELECT statements there are two functions. One of them gets the object you want the sentence to be created from, and the second parameter is the name of the attribute that holds the primary key in your database. In short, the 'WHERE' part of the sentence.
But if you're starting from scratch you can make your domain classes inherit from 'IDKeyObject'. This is an abstract class that it only has one attribute, 'ID', which is the one I assume is your PK. So, if you pass an instance of any derived class there's no need to tell the PK attribute.
Give it a try, and let me know how can I improve it. It's only been tested in SQL Server, but I think I'm using standard ANSII SQL, so, it should work for every DBMS.

Well, actually there's a function of the DDLStatement class which returns the CREATE TABLE statement to create a table from a class, and the data types I use there are the ones from SQL Server, I guess I could have parameterized than :(

Download SQLHelper



Read Full Post

Friday, September 01, 2006

.Net vs. J2EE (again)

I'm glad Joel wrote about this subject again... but what makes me happier is the fact that he arrived to same same conclusion we had arrived when a little debate took place after my ".Net vs. J2EE, why?" post.
I totally agree with his comments about the people... people are responsible for making a project fail or succeed, not the chosen technology.

BTW: I still prefer .net and I don't see that changing anytime soon ;)

Read Full Post

Tuesday, August 29, 2006

Seinfeld & Superman

...just the best of two worlds ;)
Check out this videos and you'll see what I'm talking about... (yeap, a little off dev topic I know)

The Green Lantern





Episode 1





Episode 2




Read Full Post

Monday, August 21, 2006

Ever heard of Diggnation?






I try to listen every now and then some interesting podcast, but this one I believe it's the best podcast around.Obviously I haven't heard'em all, so feel free to recommend all the podcast you'll find interesting.Understand that the wide concept of interesting, from this one (diggnation) to the TikiBar (watch the videos).
Diggnation is about two guys that read and comment the top dug stories of the week in digg.comSo chek'em out, they are funny as hell, if you can try to downloads their videos.

The banner above is a game made by one of the fans, play with Alex and try to beat Kevin in this drinking contest. Click on Johny Johny (Tiki Bar) to get shots.

Read Full Post