03 March 2011

Night time shadows on open sand

I feel as in a sex fevered pipe dream of polarized dragons chasing mind shadows across a digital horizont of conflicting diagrams and clashing systems.
My mind is playing depth perception dreams on me. Hand quivering, extended forwards, I cannot grasp what is in from of me. It is as if its beyond and the across my terrestrial self at the same time, as if it started leaving in an non-euclidean space time continuum, where regular rules of out earthly domain do not matter as innocence proves nothing in a gaming future of constant, hateful warfare.
It is the day of surprises and ending and endless driving across the bare Istrian wasteland of rolling hills and idyllic, void filled, villages and townships.
After two hundred and some kilometers I can proudly and tiredly say that I had three presentations today in two different counties in two different regions and two different towns.
The first two were an introduction in Functional testing of web applications with Selenium 1.0 and a sneak peak of the web driver run Selenium 2.0 (which I wrote in Java on Ubuntu). The second was a more advanced presentation of the same topic where I've generated .NET unit test form Selenium IDE and then executed them inside MonoDevelop again on Ubuntu with NUnit and the test worked. Yey me.
The third presentation was the most taxing of all. In Rijeka for the monthly SQL/Dev user group meeting at the Maritime University of Rijeka I've held an introductory session about WCF RIA Services. In all I think the sessions went well. I've made some mistakes with my slides which I will correct for next time and the low point was my virtual machine which literally broke and wouldn't function right so my code example didn't really show in good light.
There was around twenty people in the room and I had a really good time. I've held a mixed presentation where I talked from slide and draw ad hoc UML diagrams on a chalkboard with sliding panels. I've talked with the audience and there was really a lot of questions which I really liked.
Latter we went to an old fashioned, communist style, drinking place where we had a blast talking with each other.
So long my dear fellows, sleep awaits my tired, tired mind.

20 February 2011

So long .NET

Its been a long time since I've written something here. A lot has changed since my last post. It was generally personal stuff that occupied my mind during that time. Business wise nothing new on the horizon.
I've started learning Java again. It is a long time dream of mine to be a Java developer and since I'm about making significant changes in my life I decided to follow my dream.
.NET is a great and cool platform. The IDE is fantastic and the speed the framework  is progressing is astounding with the barrage of cool stuff is overwhelming. Recently I've learned WPF, Silverlight, RIA Services and Entity Framework. All cool stuff. But what always bugged my Mikes software it is that you need a whole lot of cash to develop and deploy your solution.
I've always been an open source enthusiast. The ability to develop software with free tools always sided good with my 'have not' upbringing.
So I started relearning Java. And its is progressing really smooth for now since the syntax is so similar to .NET.
On the other note I will conduct a RIA Services for begginers presentation in Rijeka (Pomorski fakultet) on the March 3rd at 17.45.

02 November 2010

Project learning and Book learning smackdown.

During my carreer as a developer I came to realize the learning benefits one gets from doing projects, e.g. solving real life project and the benefits one gets from applying structured learning practices when learning a topic.
Let me explain how I learn first.
Generally once or twice a year I make a sorted list of technologies or topics I'm interested in learning. The topics are sorted by priority and how hard are they to learn. And then I start learning those technologies by moving from he the first item on the list to the last.
When I've picked up a technology to learn I usually by a book or two about it and then I start reading the book while sitting on my computer and working all code examples. This takes a lot of time since I work full time and also have a family but it gives me hand on experience with all aspects of a technology. Unfortunatelly this only gives me some experience, not true proficiency. True proficiency comes form working six months or more in a technology solving real life problems and learning how the technology works in the field, what are its problems and what are the best patters for its utilization.
Projects are really good at being proficient with common tasks in a technology, but do not delve deep in all use cases and technological aspectes of a specific software solution being applied. In some cases I relied only on my project learning to get a grasp on a technology and came completely stack when faced with something new and different for which I didn't have the necessary theoretical background which I would had if I took the time to learn the technology properly.
With book learning I get a real good foundation in a technology but lots of it I don't get to use during the technology life time, so the learning effort is kinda wasted since I don't get to use directly that knowledge practically. On the other side the wide knowledge base usually gets me pretty fast out of tight spots others find impossible to surpass.
In my opinion in order to be a good sofware developer one must do both types of learning :
  • Project learning , learning a technology by doing a project in it.
  • Book learning, learning a technology by following a structured learning mechanism such as a book or reference manual.
The real trick is to find a balance between both.

31 October 2010

Model/UI Model/UI Controler javascript patter in short

I've watched today an interesting presentation about functional design patters and I wanted to share it with you my dear and loved reader.

http://www.infoq.com/presentations/Functional-Design-Patterns

Functional programming and functional languages started interesting my from the moment I grokked Javascript. Javascript is an interesting language that blends, in my opinion, good sides from both the object oriented paradigm and the functional paradigm.

Lets face it. Javascript is used mostly for dynamic GUI's on the web and on the mobile platform. User interface events are behavior(action oriented) and the functional style of programming can be very useful in such and environment with some good speed gains. But also the DOM or the UI is an object rich environment , full of entities, relations and etc. Not to mention custom POJSO's (Plain Old Javascript  Object) indicating  varius states our screen can take or coordinating the behavior of other objects in the same screen.

I generally do something like this. First I define my screen entities, those objects that correspond to specific entities which live happily on my screen:


function Person(name, age, sex)
{
  this.Name = name;
  this.Age = age;
  this.Sex = sex;
}



I will then link those two entities to corresponding UIEntities. UIEntities are those POJSO's that group a set of DOMElements and coordinate their UI logic in respect to the current state of the associated Entity object.

For example:

function PersonUIModel(element,person)
{
    this.Element= element;
    this.Name = this.Element.find("input.person-name");
    this.Age = this.Element.find("input.person-age");
    this.Person = person
}

PersonUI.prototype = {
  validateRequired:function(textBox)
  {
      if (textBox.val()=="")
      {
         textBox.css('border','1px solid red');
         return false;
      }
     
      textBox.css('border','');
      return true;    
  },

  Bind:function()
  {
     var object = this;
     //Populate values
     object.Name.val(object.Person.Name);
     object.Age.val(object.Person.Age);
     
     //Bind events
     object.Name.change(function(e){
        if (!object.validateRequired(object.Name)) return;
        object.Person.Name = object.Name.val();
     });
     
     object.Age.change(function(e){
        if (!object.validateRequired(object.Age)) return;
        object.Person.Age= object.Age.val();
     });

     
  }
}


The previous code piece needs some explanations. First for everything UI related I use JQuery, so all examples here that touch the DOM will make use of its innate capabilities.
The constructor of the PersonUIModel object gets two values an JQuery object named Element which corresponds to the actual HTML rendered with the page and attached to the PersonUIModel for controlling. The second argument is the actual Person entity binded to the HTML through the PersonUIModel object.
For ease of use I've extracted the two actual controls I'll need in separate fields of the PersonUIModel object.
The Bind method is used to start the actual two-way databinding between the Person entity and the HTML associated with the PersonUIModel object. Nothing fancy here except for two things.
Just on the start of the Bind method the this indentifier is associated with the object variable. This is done because of the change handlers latter in the code the context of their anonymous methods relies on the PersonUIModel object. If I would make a call like this in the Age.change event handler :

this.Age.change(function(e){
        if (!this.validateRequired(this.Age)) return;
        this.Person.Age= this.Age.val();
     });
I would receive a nice, fat, juicy error indicating the the validateRequired function doesn't exits on the DOMElement. The 'this' inside the event handler actually points to the textbox associated with the Person.Age property (not the JQuery object but the actual DOMElement). But with the power of closures I magically convert my PersonUIModel 'this' to object (or any other variable name) and everything is fine).
The PersonUIModel objects binds to a html code like this:


<div class='person'>
Name: <input class='person-name' type='text' />
Age: <input class='person-age' type='text' /></div>


Now we are left with the question who creates the PersonUIModel instance and binds it to a Person instance and the related HTML code. This is the role of the PeopleUIControler a specific class that coordinates the lifecycle of PersonUIModels.
The PeopleUIControler has the following roles:
  • Finding or creating the appropriate DOMElements on the Screen.
  • Loading and Saving Person models.
  • Binding Person models to DOMElements through PersonUIModel instances.
This means the the Person model is totally decoupled from the UI in which it is located. The PersonUIModel knows only of its little piece of HTML code and its Person model and nothing else. This means that the PersonUIModel doesn't know about other PersonUIModel's on the screen nor does it have any impact on the HTML outside its little realm.

The PeopleUIControler will look like this:

function PeopleUIControler()
{
      this.People = [];
      this.PeopleUI = [];
}

PeopleUIControler.prototype = {
  btnSave: null,
  btnLoad: null,
  pnlPeople: null,
  Load:function(){
      //Ajax loading ... loads a bunch of Person entities
      this.People = bunchOfPersonEntitesLoadedThroughAjax;
  },

  Save: function(){
     for(var i=0;i < this.People.length;i++)
     {
         var person = this.People[i];
         //Save the person through AJAX
         //....
     }
  },
  Bind:function(){
     var object = this;

     this.pnlPeople=$('.panel-people');

     this.btnSave=$('.person-save');
     this.btnSave.click(function(e){
        object.Save();
     });

     this.btnLoad=$('.person-load');
     this.btnLoad.click(function(e){
        object.Load();
     });

    //Load entities synchronously (just for the sake of the argument)
    this.Load();

    var html="<div class='person'>
Name: <input class='person-name' type='text' />
Age: <input class='person-age' type='text' /></div>";

    for(var i=0;i < this.People.length;++){
      var personUI = new PersonUI($(html), this.People[i]);
      personUI.Bind();
      this.PeopleUI.push(personUI);

      this.pnlPeople.append(personUI.Element);
    }
  }
}

The code for the PeopleUIControler is similar to that of the PersonUIModel. The controled has two methods Load and Save for loading and saving Person entities to a permanent source and a Bind method which binds all elements. The PeopleUIControler ties it self to an html structure that sports a panel for PersonUIModels and two buttons one for loading and saving. When first loading PersonUIModels each model is binded to a generated piece of html and then the same html is appended to the PeopleUIControler panel. The final html code used by the PeopleUIControler would look like this:
<div class='panel-people'></div>
<div>
<button class='person-save'>Save</button>
<button>load<="" <="" button>="" class="person-load" div>=""></button>

24 October 2010

Went to Zagreb and maybe lived to tell the tale

I went to Zagreb today with my colleague Hrvoje Hudoletnjak to the monthly WebUG meeting. There were two topics:
  • Lightswitch by Gjuro Kladarić, FFZG
  • Hybrid Mobile Applications by Matija Šmalcelj, Pet minuta
I was really excited to go there. It was an opportunity to learn and to network with some like minded people over the mountain (Istra where I live is separated from the rest of Croatia by a mountain named Učka). 
What I was looking for is more Lightswitch education. I just started some Silverlight development my self and the idea of Lightswitch intrigued me. There are a lot of applications being developed in pure code today which could just easily be developed by a Lightswitch-like tool.

In my opinion developers tend to be to high horse about development practices and techniques. The majority thinks if something wasn't developed in pure code, using the hottest techniques and frameworks its something to keep quiet at leat or at worst to be ashamed of.

Latter experience taught me some lessons. For the majority of LOB applications nobody really cares how we do it except us. Now, I'm of the opinion that we should care how we do what we do. But I also think that we can do a good job by not being such asses about the way we do things regularly. For somethings there is no need for unit tests, for somethings database design is just enough. Not to mention that not everything needs to be a three layer architecture and that some forms with code behind and a data store are the proper solution for some LOB applications.

The Lightswitch presentation was purposefully short.  It reminded me about Microsoft Access and my faith in the tool just sunk. It seems it wasn't really what I hoped it would be. The presenter repeatedly pointed out that this tools isn't for the regular developer but for fairly advanced administration personel. Ok. I can achieve more with Drupal, CCK and Views.

The second presentation, about Hybrid Mobile Applications was really interesting. The presenter works in a company specialized in social networks and mobile applications and he illustrated the business case for developing Hybrid Mobile Applications, e.g. web applications written for webKit and run inside a native wrapper in order to give an illusion of a native iPhone or Android app.

Whats the deal here? If you want to write a cross platform mobile app you need to write a separate implementation for each platform. One in objective-c for iPhone, one in Java for Android and so on. With Hybrid Mobile applications you just write (or take an open source one) native wrapper e.g. an application that internatlly starts the browser as a control and that resizes its self that all browser specific features are hidden from the screen thus leaving the page content. The real application is written using webkits HTML5 capabilities CSS3 animations, Javascript local storage, geolocation etc.

The application runs inside a single html page and the entire source code is shipped as single build with the wrapper thus by just changing the wrapper one can ship the same code on any native mobile application. The best thing is that the user doesn't know he is using a web application.

The most important thing  is to develop the application with no connectivity in mind, which is really easy by the existence of the local storage api that gives to the developer a full fledged relational database to use.

The development is really cheap also. The developer needs a webkit browser (Google Chrome or Safari) an IDE (Eclipse comes to mind) and a couple of mobile frameworks to ease the development effort.

 Here are a couple of links given by the presenter:
The presentation gave me a couple of ideas about some project I might do:
  • A mobile Mantis Bug Tracker interface
  • Hmm thats all just one ... :(
Of course I still have some learning to do about WPF 4  and MongoDb. I will wait till I learn those with other activities.

29 September 2010

I'm too old for this

I worry to much I'm going to wash out due to my age. I'm currently, at the glorious time of writing this post twenty nine years old and by the Lords grace I'm not a year older. And I worry I'm to old for this job. This makes me really unhappy since I have a small boy and I wonder how I'm going to provide for him since I'm no good at anything else (well I'm mediocre at a lots of things, but that is nor here nor there so we are not going event to discuss it) and this is all I have for now.
I don't know a lot of developers older then me, a few older then forty and none older then fifty. I really do not know what is my future career plan. I generally planned to gradually move to an architecture design position, since I'm naturally inclined to it and its not a development heavy thing. As I grow older, and as people grow older, we cannot learn as easily and as much as we could before. New technologies emerge and if you want to stay in this job  you need to spend extra time learning them at your own. But later I just can't mange to force my self to find the computer time for it. Sure I read books and blogs, and pay really carefully to code examples for technologies I'm intereseted. Curretnly I'm reading WPF 4 Unleashed by Adam Nathan and Patterns of Enterprise Application Architecture by Martin Folwer, plus I've read the entire MongoDB on-line documentation. But reading is not enough, you got to feel the code bellow your fingers. You just got to. And I really don't to much.
During my holidays I was to washed out to do anything and I told my self its OK you need to rest. But when I got back to work it continued. Sure I started some small coding on the side for learning purpose, I started reading books and blogs and watching presentations but thats just not enough without coding.
What is going on with me you wander. I think a description of my life after work is in order. When I'm finished working I'm with my family helping with the kid, doing house chores the whole nine yards. I put the kid to the bed and around ten o'clock in the evening I'm done with everything. I then go to eat my dinner (yeah I know its kinda late for that, but thats life) take a shower and I'm free to do as I like. I so want to do some coding but when I just think of sitting in from of my computer, my internal will power just crumbles. So I just watch a TV show or read a book. Very depressing, and very unhappy like for me. And then I start to wonder, this is my age doing this to me. Before I didn't have problems with this. Before I could do this all night old. I'm twentynine years old and I can't muster the will power to do this everynight, whats going to happen in ten or twenty years. How I'm going to learn Java or Erlang, or any other technology I'm going to need?
I just don't know and I'm really not happy about it.

28 September 2010

The shock of it all

Once upon a time when I was 'yay' high (shows to his head, indicating it was very recent) I started writing Selenium tests to test the UI compoenents of my ASP.NET application. As you may know ASP.NET screens are notoriusly not easy to test, expecially if you are lazy (side note: you can extract much of you ASP.NET server side logic in separate classes whithout ties to the ASP.NET application service suing the Class Method pattern.) and the only think a poor developer can do in order to test them (I'm not going into the not testing it at all option or just 'my clicks are enough attitude') is to write some good old UI automation tests.
There is nothing wrong with UI automation tests, mind you, I think they are greate since you are sure you've tested the final integration of your product as shown to the user. What I find appaling is the customers reaction of seeing such tests executed.
Let me tell you - and no, pleas, do not hold your breath - they are blowed away. Amazed. Shocked to the core how good they are. Screens flying, textboxes filled, data showed in grids, filtered and etc. The whole UI testing nine yards. And they want more, they want to start using that in their own projects. It is a presentation ass kicker.
And then we start our fivehundred or more unit-test/functional test suite that executes under a couple of minutes testing almost everything in the application and they are emotionally dead as fish. Oh , its nice can we talk about deadline issues now, please? Right.
I have nothing more to say. I'm appaled. Well, I was anyhow when I was 'yay' high (shows to his head, indicating it was very recent).