Tag Archive for development

HTML5 and Javascript is not a HTML5 Javascript application

Javascript and HTML5 is in everybody’s mouth nowadays, looks like everything is around them: Node.js is wonderful and made what others tried to achieve long time ago, frameworks like knockout.js or backbone.js taught us how to develop MVVM and MVC oriented applications using javascript, jQuery is your everyday tool, and even an major operating system (Windows 8 ) announced their support for native HTML5 and Javascript to develop desktop touch friendly applications.

Javascript has emerged from a mere hacking language as a now mainstream language, now it’s common to see job offers for “javascript frontend (or UI) developers” and almost every website I’ve been involved into requires a lot of interaction using your browser… So, what’s the problem?

The problem is simple, even when we have new frameworks, new IDE’s, new paradigms for HTML and javascript applications I see that most developers still treating javascript as a hacking language, I mean, throwing lines and lines of code into the problem, without any separation or patterns or anything else, they still writing rich interactive application as HTML plus javascript, not as a HTML and javascript application.

A good application is more than code and UI, a good application should follow DRY, KISS, SOLID or whatever other acronym do you want to throw at them. HTML and Javascript applications are more than just HTML with Javascript.

Want to do something better? don’t tread Javascript as a hacking language. Period.

JustCode is not loading in Visual Studio 2011

Telerik’s JustCode it’s an awesome product, it’s a very lightweight extension that may lack some features (sorry, I won’t mention names) but it does its job, and that’s good. Almost a month ago Telerik announced JustCode support for Visual Studio 2011, that’s awesome, specially when I decided to try out Visual Studio 2011 in a pristine installation inside a virtual machine (and yeah, I know other extensions already announced the same).

installer

I downloaded the JustCode internal build and the installer correctly detected my Visual Studio 2011 installation, sweet, everything finished without any problem. Then when I started Visual Studio 2011 I realized JustCode didn’t load… and all what I get it’s a very verbose exception in the JustCode’s output window:

ERROR 2011-10-23 00:23:38.842 :  [HResult: 80131602]
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
[and a lot of more lines...]

I submitted some bug tickets, write to some Telerik’s developers but no right answers, you know, the usual.

Well, I decided to see what’s happened, so I did what every other developer would do, attach your debugger to Visual Studio and then found the issue. JustCode is trying to load the assembly Microsoft.VisualStudio.CSharp.Services.Language, Version=10.0.0.0 but in a machine without Visual Studio 2010 this assembly didn’t exist, it’s unique of a Visual Studio 2010 installation. Of course, I’m using a Virtual Machine snapshot, I don’t have a previous version installed. The assembly present in my VS2011 installation is Version=11.0.0.0.

The easy way to fix it? Go to a Visual Studio 2010 installation, copy the assembly Microsoft.VisualStudio.CSharp.Services.Language.dll from the Common7 directory and paste into your Telerik’s JustCode directory, that’s all, JustCode now it’s going to load. Maybe this would cause some other problems, but come on, it was my first attempt! =)

Probably a better way to fix it would be using assembly binding redirection, or taking care of the fact that maybe a previous installation it’s not present maybe in the installation process. I’m just saying!

Note for developers in general: it’s a good idea to test your installation in a pristine installation before release it to the wild, just to see what’s happening, you know, just in case =)

El espejismo de la separacion por capas, toma dos

app_3Hace varios meses escribí un blog post (que quise luego transformar en serie y como cosa rara en mi por tiempo nunca llegue a continuarlo) en el que indicaba mi falta de amor a la palabra “capas”….

El concepto de “capas” o “layers” me parece desde unos años para acá tan ortodoxo, viejo, fuera de lugar, obsoleto, mal aplicado, afuera totalmente de contexto. La idea de capas tenía mucho sentido hace décadas atrás (tampoco décadas pero fue hace tiempo) cuando los programadores cavernícolas (en los cuales me incluyo yo picando piedra) teníamos que depender fuertemente en la base de datos, hacíamos las consultas en plano SQL, insertábamos directamente en plano SQL, y si mi DB me la movían literalmente movían mi aplicación.

Esto tenía todo el sentido del mundo en nuestras aplicaciones no tan complejas y sin mucha orientación lógica que hacíamos en aplicaciones desktops o web, o sea, en vez de escribir cientos de líneas SQL esparcidas por doquier en nuestro código de php (por ejemplo), mejor lo abstraíamos todo en un solo lugar donde estaba guardadito nuestro SQL, ahí en su cajita, donde nadie lo tocaba y si alguien lo tocaba era una vez (como que si tocar una consulta no involucrara cambiar algo… silly us). Esto se llevó un paso adelante y en vez de poner consultas como SELECT * FROM [tabla] mejor usamos SP’s, así que cambiamos eso por EXEC usp_MiConsulta, esto dio origen a otro problema, pero vamos a ir al grano primero.

En ese tiempo la gente comenzó a percatarse de algo, si abstraigo las consultas a la DB, luego las llamadas a la DB en otro lado, puedo entonces poner la “lógica” de negocio en otro lado y sobre ella hacer la UI. Esto tenía mucho sentido y asi nació el concepto de “layers”… Tiene sentido, tenía sentido en ese tiempo, teníamos aplicaciones con el “típico” color aqua y un par de botones con iconos de puertas y equis tachadas en primera plana, con una grid para mostrar facturas y un botón donde agregábamos una factura nueva (generalmente con el icono más o con un lapicito que aun no entiendo porque aparecía ahí).

Luego vino la moda SOA (que pareciera nunca acabar) y dijeron, va, ahora en vez de hablar directamente la lógica con la data, vamos a tener alguien en el medio que expone esa data por un servicio. Entonces hablamos de SOA… como ya no eran 3 capas si no 4 o más renombramos el modelo a n-Capas…. y aun me perfora el oído escucharlo….

He visto degeneraciones de este modelo, un “buen” ejemplo son las aplicaciones ejemplo de MS, donde abstraen todo a servicios que al final el mismo objeto desde el comienzo al fin es el mismo. Es increíble pero he visto a desarrolladores veteranos que aun insisten en usar su versión de servicio para exponer todo, pero esa es otra historia…

Nuevamente recalco, eso tenía sentido *en ese tiempo* los ORM’s o no existían o eran sumamente rudimentarios, la mayoría de db devs que habían estaban aún acostumbrados a hacer _todo_ en la DB (no, en serio, una vez vi una app que hasta el proceso de pago de paypal era hecho internamente en la DB), tenía sentido cuando tu aplicacion era la tipica aplicación con botones grandes y background aqua… Tenía sentido cuando decías que abstraías el acceso a datos en una clase que por lo general comenzaba por una pequeña clase con un par de métodos y terminaba como cientos… porque tal cosa como reutilizar el acceso a datos se tornó un santo grial.

Eso no tiene sentido HOY, cuando nuestros objetos son (o deberían ser) ricos en comportamiento, cuando modelamos en base a lo que _va a pasar y hacer nuestra aplicación_ no en cuanto a la data que va a contener la base de datos (puntos extras para el que comprenda la diferencia entre ambos approaches en la oración anterior). No tiene sentido hoy que nuestra “lógica de negocio” realmente puede ser embebida en el objeto del dominio o de negocio, donde hacemos una distinción entre lógica de negocio (o reglas del negocio) y lógica de presentación (que como dice el nombre solamente afecta la vista). No tiene sentido cuando no interactuamos contra solo una base de datos si no contra base de datos, archivos, servicios (y generalmente varios). No tiene sentido porque no le veo ni cara ni cuerpo a tener un ORM (por simple que sea) y envolver las mismas entidades y exponerlas mediante otras entidades que contienen los mismos símbolos, no tiene sentido hablar de capa de acceso a datos ya que tus Objetos de ORM no solamente viven ahí y pueden contener la lógica que tanto necesitas en la “siguiente” capa. No tiene sentido en un mundo donde el programador está acostumbrado (y hasta espera) que la consulta se genere automáticamente mediante Linq, no tiene sentido en un mundo donde ya no escribimos SQL a mano.

¿No te gusta un ORM porque tiene demasiada carga para lo que necesitas? bueno usa un MicroORM… y aun así sigues sin hablar de capa de datos, tal cosa ya no existe. Ni siquiera Microsoft con sus prácticas habla de layers…. Vamos, ahora ni en PHP puedes tener el coraje de decir que tienes que escribir SQL a mano, porque entonces abstraer todo en una “capa”, ¿quieren producir algo de misterio? Traten de preguntarle a un programador de Rails donde está su capa de datos, no existe, ¿porque?… No es necesaria tal separación.

Ahora, lo que si debes distinguir es el concepto de Tiers, una aplicación si va a tener varios Tiers, la base de datos (a menos que sea embebida) vivirá y es por definición un tier, ¿expones servicios? bueno, otro tier mas…. Un tier es una separación física de la cual no puedes deshacerte, una layer es una separación lógica que realmente no tiene sentido en un mundo ágil donde no usamos 6 meses “diseñando” la aplicación.

Algún día ordenare todos mis pensamientos y terminare escribiendo un poco más sobre porque el concepto de layer sigue siendo obsoleto, por lo menos para mí.

NOTA: Este fue un largo correo en la lista de Alt.Net hispano que termino siendo tan largo que llego a ocupar un blog post.

Dennis Ritchie

Dennis_MacAlistair_Ritchie_Today I read very sad news, Dennis Ritchie is dead. A person that literally changed my life (I remember reading The C Language and trying to make myself clear what a pointer was). I decided to become a developer when I first started coding and using a Linux system years ago. Today one of my heroes is dead.

Even if you are not a programmer you cannot avoid using Ritchie’s legacy, the Windows operating system you are using? well, took many of its ideas from Unix, and it’s made in C. Are you using MacOSX? well, guess what, it’s made in C. Well, you are a PHP developer? PHP is made itself in C and it’s obvious where the syntax it’s coming from. Even “modern” C#/Java/Python/Ruby developers cannot avoid it’s legacy.

Sir, we are going to remember you with every line of code we write. We owe you too much to be able to measure.

Do you have a blog? Give Dennis Ritchie the tribute he deserved, the one the media won’t give him. http://t.co/bsFFbAA8

UPDATE: Saddest piece of code ever http://t.co/Xp5EmFRg

Thermodynamics and developers’ life

When I was in University my favourite class (or maybe the class that basically changed my perspective of many things) was Thermodynamics, maybe was my teacher (a really brilliant physics and chemistry professor) or maybe was the very abstract and practical examples. She spend most of the time in the class explaining basic things like the rain or the boiling temperature of beans in high altitude with equations and thermodynamic laws. Years after that I still remembering many of the concepts and even making observations based in what I learnt those days.

In the last year I’ve been facing so many different problems as a developer and consultant with different customers, different technologies, different use cases, so many different areas of knowledge. Today I was thinking about the ideas about Gibbs theories and I saw something interesting with my developer life and how they are related.

You’ll see, one day my professor just explained how the Gibbs free energy is related to the human body chemical reactions and how the Entropy is important in everything that happen in human life, including relations. So at the end everything concludes in a simple fact: “you will get the complete equilibrium when you die”. Many developers look for a constant equilibrium in their life’s, some of them spend many years doing the same and making themselves confortable with the same thing, same technology, same platform, same risks, maybe they expect to face tomorrow the same problems they faced today, maybe they are looking for a zero entropy in their developers’ life.

Personally I like the fact to learn new things everyday, to face new problems, new challenges, maybe it’s the fear to have zero entropy in my life and realize I’m just death.

Maybe you need a little more of Entropy in your working life, what do you think?

A little more about Human Thermodynamics.