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

Monday, July 17, 2006

Localize This!

Localization, that's pretty much what I've been doing since I got in the DeKlarit team. I've been working on it for win and web forms and I must say that it's really simple in .net framework 2.0.
There are different techniques in order to achieve that, one of them is to generate a resource file for every form in your app. Even though this approach is less complex, I don't like the idea of having as many resource files as forms in my application, so I'll describe how to achieve localization with a different approach.


First of all, create a simple win app and add some controls to the main Fomr (Form1). Add some labels some buttons and what ever you want.
Now create a resource file and name it StringResources.resx. Edita that file with VS2005 and add all the strings you want to localize, ok, cancel, HelloWorld, etc...
In order to localize your form create a method (called form the Page_Load method) where all texts are going to be set. In order to do that write the following sentence for every control you may have in your form:
btnOK.Text = StringResources.NewCaption;
Once you run the application you should see every text you've entered in your resource file.
I now what you're going to say, so, this is the cool part? nope, this is the hard part, to cool part is coming right now. From the Solution Explorer Copy and Paste your resource file and rename it as StringResource.es.resx. Change the values of that file to spanish, Aceptar, Cancelar, HolaMundo, etc. Now change you regional settings so your default language is spanish.
Rerun you app and that's it!, your app should now be displaying all the controls in spanish, or what ever you've entered in the resource file.
In order to get the same result for web applications you can do two things. One is to do exactly what we just did and the other one is to set the "call" to the resource file right on you aspx of ascx file. To do that just change the text attribute of the control for something like this:
Text="<%$Resources:StringResources,NewCaption%>"
You may need to Databind the control in order for the text to be displayed.

So there yo have it, your own application with localization features. Start playing with it and add it to your applications, you never know where's your next buyer from ;)

Read Full Post

Friday, June 16, 2006

Geek draft season


You're probably aware that Robert Scoble left Microsoft, also there's a "rumour" that Gates is leaving Microsoft, and now I'm leaving The Soupreme Court of Justice for DeKlarit ( www.deklarit.com). LOL!

This is a big opportunity to me and I'm very excited about it. DeKlarit is a Visual Studio add-in used world wide and it's used to develop .Net applications (win, web, mobile) faster than ever. You take care of your businness rules and let DeKlarit create the tables needed to model your application reality.
I'll start working in a big software company and thats really exciting to me, cause our business is about biulding software.

I'll be bloging about it soon so stick around.

Also, no more spanish, I'm tired of translating and keeping in mind that most of my visitors are english speaking peple and that english is the official interenet languagge there'll be no spanish from now on. Sorry to those who do not understand english... you need to start learning english right away.

Read Full Post

Friday, May 26, 2006

LINQ: ADO.Net next generation


I recently tried The LinQ Project. LINQ stands for Language Integrated Query and it is just great, at least for me. What's the best way to manage data? If you didn't say SQL stop reading!
The best way to explain LINQ is with examples, so here I go. Imagine you have an array of strings (string[]) and yo want to print every string which length is longer than 5 characters, and you want to print'em in upper case.
You would probably do something like this:

foreach (string s in myStrings)
{
If (s.Length > 5)
Console .WriteLine(s.ToUpper()); //What if you want'em ordered?
}

Well, now with LINQ you can use the classic SQL syntax like SELECT, FROM and WHERE. The only difference is the order you use with those "commands".
Let's write the same example using LINQ.

expr = from s in myStrings
where s.Length > 5
orderby s //Ordering here!!!
select s.ToUpper();

foreach (string item in expr)
Console.WriteLine(item);

Isn't that great?!

And trust me, this is the simples dumbed example, you can do amazing things with it, like creating classes for your application in runtime. In this example we're just selecting text, but let's say you want to select many attributes from a User table like Name, Address, and Phone. You can select those attributes and "declare them" as a class called Clients and you can reference that Client class later on in your code.
I hope I made myself clear, go to the LINQ Project home page and also download Anders' video from Channel9.

Recientemente probé el proyecto LINQ. LINQ significa consultas integradas al lenguaje (o algo así por su sigla en inglés) y es fabuloso, por lo menos para mi. Cuál es la mejor forma de manejar datos? si no contestó SQL deje de leer!
La mejor forma de explicar LINQ es mediante ejemplos, asi que aquí voy. Imagine que tiene un arreglo de strings (string[]) y quiere imprimir todas las cadenas cuyo largo sea mayor que 5 caracteres, y quiere imprimirlas en mayúscula.
Probablemente ud. haría algo como esto:

foreach (string s in myStrings)
{
If (s.Length > 5)
Console .WriteLine(s.ToUpper()); //Qué pasa si quisiera ordenarlos??
}

Bien, pues ahora con LINQ usted podrá utilizar la clásica sintaxis de SQL como ser SELECT, FROM, y WHERE. La única diferencia es el orden en el que uno escribe estos comandos.
Escribamos el mismo ejemplo utilizando LINQ.

expr = from s in myStrings
where s.Length > 5
orderby s //Ordenado desde aquí!!!
select s.ToUpper();

foreach (string item in expr)
Console.WriteLine(item);

No es bárbaro?!

Y créeanme que este es el ejemplo mas choto que existe, uno puede hacer cosas asombrosas con esto, como crear clases para su aplicación en tiempo de ejecución. En este ejemplo simplemente estamos seleccionando texto, pero digamos que usted quiere seleccionar varios atributos de una tabla Usuarios como ser Nombre, Dirección, y Teléfono. Usted puede seleccionar esos atributos y "declararlos" como una clase llamada Clientes y puede referenciar esa clase mas adelante en su código.
Espero haberme hecho entender, vaya a la página del LINQ Project y bájese el video de Ander de Channel9.

Read Full Post

Friday, April 21, 2006

Easily encrypt your passwords, here's a tool to do it!



Where do you keep you password? Are you trying to hide something from the rest? we all are. And that's why I created YAPS (Yet Another Password Saver). I know there is a commercial product with that name but I swear I didn't know when I named it... anyways, this one is free!

Actually I created YAPS for a developer contest Microsoft LATAM was conducting, see my LATAM only post. Anyways I didn't win the big price but I got a Visual Studio 2005, and that's not bad at all.

Where am I trying to get with all this, I wanted to share YAPS so everybody can use it and tell me what you think about it. It's pretty simple to use. Create a new file, enter as many passwords as you like, save the file with a password (you have to remember that one) and that's it. Every time you want to review your passwords you have to open your file, enter the password you remembered and click on the Decrypt button while the password you want to decrypt is selected.

How does it work? simple, the passwords you entered are encrypted using DES with the password you have to remember as the key. All that info is saved into a XMLDocument along with your key, which is also encrypted with a key only I know, but you can change it since I'll let you download the source code (that key is hard coded). That XMLDocument is saved into a yaps file. That's right a yaps file is an xml file, see it yourself.

So feel free to download it, use it, investigate it, modify it, and tell if you found it useful or not.

I forgot! it's a good first Visual Studio 2005 application example, since uses Generics (the coolest thing) and object as a data source.

Donde tienes tus contraseñas? Tratas de ocultar algo del resto? todos lo hacemos. Y es por eso que creé YAPS (Todavía otro "salvador" de contraseñas, por su sigla en inglés). Sé que existe un producto comercial con ese mismo nombre, pero juro que no sabía cuando lo nombré... de todas formas, este es gratis!

En realidad creé YAPS para un concurso de desarrollo llevado a cabo por Microsoft LATAM, vean el post LATAM Only. De todas no gané el concurso pero me gané una copia del Visual Studio 2005, y eso está bárbaro.

A donde quiero llegar con todo esto, quise compartir YAPS para que todo el mundo pudiese usarlo y dejarme los comentarios. Es bastante fácil de utilizar. Cree a un nuevo archivo, ingrese todas las contraseñas que desee, grabe el archivo ingresando una contraseña (de esta se tiene que acordar ud.) y eso es todo. Cada vez que quiera rever sus contraseñas tiene que abrir el archivo, ingresar la contraseña que debía recordar y hacer click en el botón "Decriptar" una vez posicionado en la contraseña que quiera visualizar.

Cómo funciona? simple, las contraseñas que usted ingresa son encriptadas utilizando DES con la contraseña que debía recordar como clave. Toda esa información es guardada en un XMLDocument junto con la contraseña del archivo la cual también es encriptada con una clave que solo yo conozco, pero usted puede cambiarla ya que permito que bajen el fuente (esa clave está "hardcodeada"). Ese XMLDocument es guardado en un archivo yaps. Así es, un archivo yaps es simplemente un archivo xml, véalo usted mismo.

Así que siéntase libre de bajarlo, utilizarlo, investigarlo y modificarlo y cuénteme que le pareció.

Me olvidaba! es un buen ejemplo de primer aplicación con Visual Studio 2005, ya que utiliza Generics (lo máximo) y objetos como data source.


Read Full Post

Friday, March 24, 2006

Developing from a 3rd world country?


I found many questions on forums about how to develop using .net technologies as cheap as possible for the developer and the final client. So I decided to post about it and give you many tips on what to do.
First of all you have the Express editions of Visual Studio 2005. They are free, although  they have some limitations. But if you're a guy trying to get in the .net world and want to develop your first Hello World app, this is the right tool for you.
What about data base? well... there's also an express edition of SQL Server, MSDE's evolution, and I heard it comes with a UI now, so you can forget of osql command line commands (oh those days!). If you think you don't need as much as SQL server, hey! try Access. You need a licence as a developer but there's nothing required for the final user.
What if you're not happy with the limitations the Express editions of Visual Studio have?. You can always go "screw the IDE, I like notepad". That's right, you can develop your app writing your code in notepad and using the compilers that come with the .net framework (they're free).
Now, let's say you're a rebel, or a cheap ass, who doesn't want to pay for the OS. Install Linux and Mono on you PC , then you'll have an entire .net application programmed and build over Linux, or MAC, or what ever mono supported OS you're using.
You think you're tough? write your code using the vi editor! ;)

Encontré bastantes preguntas en distintos foros sobre como desarrollar utilizando las tecnologías .net lo más barato posible tanto para el desarrollador como para el usuario final. Así que decidí crear un post sobre el tema y dar unos cuantos "tips" sobre que hacer.
Lo primero son las ediciones Express del Visual Studio 2005. Son gratis aunque tienen algunas limitaciones. Pero si estás tratando de entrar en el mundo .net y quieres construir tu primer aplicación "Hola Mundo", esta es la herramienta adecuada.
Qué hay sobre los datos?, también existe una edición Express de SQL Server, la evolución del MSDE, y según escuché trae una interface de usuario por lo que uno se puede olvidar de los comandos osql en linea de comandos (que tiempos aquellos!). Si crees que no necesitas tanto como SQL Server prueba con access. Necesitas una licencia como desarrollador pero para el usuario final no necesitas pagar nada.
Y que hay si no estás conforme con las limitaciones de las ediciones Express del Visual Studio? Puedes agarrar y decir "a cagar el IDE, a mi me gusta el notepad". Así es, puedes desarrollar tu aplicación escribiendo el código en el notepad y utilizando los compiladores que vienen con el framework .net (que es gratis).
Ahora, digamos que eres un rebelde, o un amarrete, quien no quiere pagar por el SO. Instala Linux y Mono en tu PC, así tendrás una aplicación .net enteramente programada y construida sobre Linux, o MAC, o cualquiera de los SO soportados por mono que estés utilizando.
Te crees "valiente"? escribe el código con el editor vi ;)

Read Full Post

Thursday, March 09, 2006

.Net Remoting for Dummies

I have made my first .Net Remoting application with Visual Studio 2003. I know Remoting has been around since the beginning of the .net framework, but for some reason I'd never used it before. Actually, now I know why I never used it, I did not quite understand what was is it useful for. But a few days ago, while working on Philippides a friend of mine (Carlitos) asked my if I was making all the communication via remoting and I said no, I was using TcpClient and NetworkStream objects in order to send messages.
At first I sent some text (csv) with the info I wanted to send to the other client. Right now I "created" my own SOAP protocol, it's just plain text sent as xml.
What I need to do is to send objects itself to the other client and I need that the receiver can understand the sent object and access its members.
Well, remoting does that for you. In my previous test I managed to send some native types as strings and integers to the server. In this example you'll see that I managed to send an object from a class I created.
So check it out! You can downloading from here or go to the post on the Sandbox ( Channel9).


Acabo de hacer mi primer aplicación .Net Remoting con Visual Studio 2003. Sé que Remoting es bastante "viejo" ya, pero por alguna razón nunca antes lo había usado. En realidad, ahora sé por qué no nunca lo usé, nunca entendí exactamente para qué me podía servir. Pero hace unos días, mientras trabajaba en el Philippides un amigo (Carlitos) me preguntó si todas las comunicaciones las hacía con Remoting y le dije que no, estaba utilizando objetos TcpClient y NetworkStream para enviar mensajes.
Al principio enviaba text (csv) con la información que quería enviar al cliente. En la actualidad utilizo un protocolo SOAP "propietario", es simplemente texto plano enviado como xml.
Lo que necesito hacer es enviar objetos mismos al otro cliente y que este último entienda el objeto y pueda acceder a sus miembros (que fea traducción).
Justamente, Remoting hace eso. En los tests anteriores había logrado enviar tipos nativos de .Net a un servidor como ser string e integers. En este ejemplo verán que pude enviar un objeto de una clase creada por mi.
Asique víchenlo! Pueden bajarlo de aquí o ir al post en el Sandbox ( Channel9).

Read Full Post

Monday, February 20, 2006

LATAM only!

Some time ago I received an email from Microsoft inviting me to participate in a developing contest. I've never done that, I thought, so I entered. I created an Windows app with Visual Studio 2005 (C#) which saves encrypted password to a file. The whole idea behind it is not remember every password you have, but to remember just one, the one that opens your file. I don't know if everybody can download it cause the contest is for latin america only, but if you want the app to check it out I'll be pleased to send it to you.
Hope to read your comments about it!

Hace algún tiempo recibí un mail de Microsoft invitándome a un concurso de desarrollo. Nunca entré a uno pensé, y me metí. Cree una aplicación Windows con Visual Studio 2005 (C#) que guarda contraseñas encriptadas en un archivo. La idea es no tener que recordar todas las contraseñas que uno maneja sino que recordar solo una, la que abre el archivo. Para verla y evaluarla pueden ir a www.desarrollonet2005.com , ahí pueden bajar la mía y las de los otros participante, si la mía (YAPS, así es el nombre) le parece buena, por favor vótela, ya que el premio mayor son U$S 2000.
Espero sus comentarios!

--
http://sgomez.blogspot.com

Read Full Post

Wednesday, February 15, 2006

Bunch of cool Sites!

First post of 2006, so first of all, Happy New Year everybody!
This post is gonna be about the new generation of web sites and how new technologies like Ajax or even Flash have changed the way Internet looks and feels in a way we never've dreamed of.
The first site I want to take a look at is Gmail, they changed the way we were used to read mail. I have to say at the beginning I didn't like it, that "conversation" way of showing your emails seemed harder, but now I have to say I wish my Outlook at work worked the same way.
The Gmail site is a good example of Ajax at its best, but as a teacher at university used to say "not because you have a hammer, you'll hammer everything" (that's actually my english translation). Even though Google made a great breakthrough with GMail, their blog reader (Google Reader) is a different story. It sucks! it's the most difficult site to read, I think I used it a couple of times thinking "it's just different and I'll end up getting used to it, just like Gmail", well I didn't! and still using the simple and yet great Bloglines site.
Some other cool sites to check are Flickr, 30boxes and Gtalkr. Gtalkr is a flash made site with the best of all worlds, it's like live from Microsoft but waaay cooler and with more stuff.
People in Uruguay!, since all the maps sites on the Internet don't care about us, there's a couple of guys developing a very cool site with maps from Uruguay. You can drag around the maps and get your way through the cities. It's not online yet but check it out soon at www.mapio.info.

¡Primer post de 2006, por lo que antes que nada, Feliz Año Nuevo para todos!  Este post va a ser sobre la nueva generación de los sitios de la red y cómo las nuevas tecnologías como Ajax o Flash han cambiado Internet en una manera que nunca antes nos imaginamos.  El primer sitio es Gmail, ellos cambiaron la forma a la que estábamos acostumbrados a leer mails. Tengo que decir que al principio no me convencía su formato "conversación", pero ahora me gustaría que mi Oulook en el trabajo los mostrara de la misma forma.
El sitio de Gmail es un buen ejemplo de Ajax bien utilizado, pero como un profesor de la universidad decía, "no por tener un martillo vamos a martillar todo". A pesar de que Google hizo un gran avance con Gmail su sitio de lectura de RSS (Google Reader) es una historia diferente. Es una cagada! Es el sitio mas complicado para leer que hay en la vuelta, creo que lo utilicé un par deveces pensando "bueno, me acostumbraré como lo hice con Gmail", pero no! y todavía utilizo la grandiosa y sencilla interface de bloglines.
Otro sitios muy buenos son flickr, 30boxes y Gtalkr. Gtalkr es un sitio hecho en flash con lo mejor de todos, es como el live de Micorosoft pero muuucho mejor y con mas cosas interesantes.
Gente de Uruguay!, dado que a los sitios de mapas del mundo no les interesamos como mercado hay un par de locos que están desarrollando un sitio muy bueno con mapas de Uruguay. Se pueden arrastrar los mapas y revolverse en las ciudades sin problemas. Todavía no está online pero prueben dentro de poco en www.mapio.info.

Read Full Post