Thursday, 25 July 2013

Thank you can do you wonders

It has been a while since my last post, I've been busy so much to write. During my daily routine of reading, I came across this wonderful clip about how a young man with high expectations dealt with his frustration in a smart and polite way and how this moved him and changed the course of his life. Please watch it as it has a really important note at the end.

Enjoy :)

Wednesday, 19 June 2013

How to Learn a New Technology?

Quite often in our industry, we find ourselves in the need to learn a new technology. Sometimes we are “obliged” to learn it as we need to deploy it in a project. And sometimes we learn new technologies to enrich our knowledge, enhance our capabilities, and keep ourselves “up-to-date”.

Recently, I found myself in a similar situation. I was assigned a new project that is going to be implemented using some new technologies that I am not quite familiar with. This brought to my mind the question of “how do we learn a new technology?” So, I looked around, and went for a brief chit-chat with some of the far more experienced people in the house with one and only question: “how to learn a new technology”. Herein, I brief the answers I received.

Our Chief Technology Officer, Samer Awajan, suggests that there is a difference between “knowledge” and “gaining knowledge”. And that there is utterly some kind of “unity” between different technologies and programming languages. So if you stick to the concept and try to absorb the main idea behind the technology you are trying to learn; i.e. get to the essence that unites this technology with the ones you already know, you will find out that the process becomes, more or less, a matter of applying what you already know but using new techniques.

The chief also highlighted how the individual experience counts as well. Even when you are going through articles and books your way of reading is different. After some time and experience, you will find yourself skimming through the whole article to grasp the main idea, then going back and forth scanning for the exact piece of information you are looking for.

Our Software Development Director, Wesam Qaqish, states that each person has their own way of learning new stuff. Some people are bookworms; they prefer to read a whole book before even starting to implement anything. But to him, he prefers to read a bit about the topic to familiarize himself with the terminology and key concepts then starts implementing right away.

Wesam agrees that the background counts as well. It depends on “how new” this technology is to you. Learning .NET, for example, when you are a Classic ASP developer is easier than learning to develop with PHP when you are a .NET developer. Concluding with the fact that the more problems you face while trying to implement any technology, the more experienced you become and the easier it becomes for you to learn and master it.

Michael Ghantous, a senior tech lead in the company, stresses the idea of “sticking to the concept”. Take Database as an example; be it MongoDB, Hibernate, MySQL, … A Database is a Database: tables, views, stored procedures, .. The implementation doesn’t really matter as long as you stick to the main concept behind the technology and try to absorb it and again, link it to what you already know.

Whether to watch a tutorial or read an article depends on each individual he says. Some prefer watching, others prefer reading. Though to him, when he wants to learn a new technology, he starts with a video that illustrates the technology and introduces what it has to offer. He starts by taking the flavor to decide if he will go on with it or not and if so, he goes on reading more about it. Learning the breadth of the technology then delving into the depth. It is very important to start gaining hands-on experience along the way, and start playing with it to become more comfortable and accustomed to it.

When exploring, he highlighted a crucial point; that he prepares a list of what he is trying to achieve using this technology. A list of the cases he will encounter and try to solve. This helps him be more focused and straight to the point. He says "at first it doesn’t matter how to implement a specific task using this technology, what matters to me is if it is already there and can be implemented using it or not".

Michael concluded with an intriguing concept and that is not everyone knows how to search and find what they are looking for. Memorizing syntax and implementation details or some specific piece of information is not what sets you apart. It is rather your ability to find the right piece of information from the right source when you need it.

Taiseer Joudeh, a tech lead in the company, agrees that the way of learning new technologies differs from one individual to another. To him, he starts by watching the “Hello World” tutorial, a very basic one, then starts applying as he is watching. He says “I have to take the hands-on experience and apply what I am watching the soonest. I play a bit more with the example and explore more options as I am going. I try to connect it to a real-life example to help me stay more focused and able to connect things more easily”.

Taiseer then moves straight to the official website. He checks the demos, support section, and documentation to see if it is well-written and covers a good aspect of what he needs.

He also raised a very important point; that he looks around to see if this technology is popular and well-acclaimed; if it has good community and forums. These are all signs that indicate whether this new technology is going to live thus worth investing time learning or not.

Those were some of the ideas that the experienced IT professionals had to offer. I would like to conclude with one simple idea; and that is the importance of overcoming inertia. When you discover and try to learn a new technology it is very important that you overcome inertia - or the fear to discover a new thing, if I may call it, and start taking action, whatever that is, right away.

[A big Thank You goes out to Samer Awajan, Wesam Qaqish, Michael Ghantous, and Taiseer Joudeh for their precious time and ideas that inspired the writing of this post :)].

Five Must Have Tools for MVC

During my daily reading routine, I came across a great blog post about the top five tools for modern MVC applications. Mainly the post discusses CSS and how the usage of several tools can bring you great results.

A must read in my humble opinion. Here is the link to it Five Essential Front-End Tools That Should be Used with Modern MVC Projects.

Enjoy.

Tuesday, 18 June 2013

Syncfusion Free E-Books

As a developer, the reading process never ends. You have to read and read and read. I am not sure when we are going to stop reading. I guess, reading has become part of our daily routine to a certain extent. Something as important as eating food, or drinking water.

Well, sometimes you don't have the time to dig into some 500+ pages books to learn a new technology, or extend your knowledge in a topic you already knew about. If you are in this position nowadays, have a look at this website, it is called Syncfusion. It contains a number of free E-books covering several important topics in addition to several white papers.

I encourage you all out there to visit this site and have a look.

Happy Coding Everyone.

Monday, 13 May 2013

Rules Engine

It has been a while since my last post. I was caught up with several things for the past three weeks or so, I couldn't add any new posts at all. Well, things are back to normal and hopefully it will stay this way. 

Enough talking about me and let's head straight to the money talk. Well, during the past three weeks I have been preparing myself for a new project, a financial application. I did some deep study on what to use and how, etc ... One of the major points was the validation of my business entities. I wanted to simplify this procedure and locate the validation rules in one layer. By the way, I am a big fan of code centralization, having one thing handling all the validation stuff. I wasn't convinced with having my validation block segregated into two layers, a javascript one for the UI and the other one in VB.NET for the server side.

I decided to go with one layer, and the UI will invoke this layer to validate the objects (JSON objects). For me, I can accept the cost of AJAX posts for the sake of having one solid layer.

I started by implementing something myself, but then I thought there must be something ready out there. Some sort of a ready made library that can be used to achieve my goal. I started looking for one and I came across this wonderful and magical library called "Rules Engine". It is an open-source library hosted on CodePlex. I played with it a bit to get myself familiar, and to be honest from the first line of code I fell in love with it. It is a really nice, simple, straight forward, and comprehensive engine. I deeply recommend this for anyone looking for a good validation engine.

Happy coding ...

Friday, 19 April 2013

Visual Studio Features: Code Analysis, Code Metrics, and Code Clones

In this post I am going to introduce 3 Visual Studio features that are very interesting and helpful; but, alas, may not be that popular. I came to discover them recently and I instantly fell in love with them! I am sure you will love them too after you get to know and try them out. 

They are, namely: Code Analysis, Code Metrics, and Code Clones.

Code Analysis

The Code Analysis feature of Visual Studio examines the code by performing static code analysis to detect common pitfalls, defects, and violations of good programming practices. Thus helping developers identify potential design, globalization, performance, interoperability, and other issues in their code.   

The tool works to raise warnings that differ from compile errors and warnings; because the tool mainly searches for code patterns that are “logically” valid, though may still cause problems on the long run for you or for people who may check/use your code later.

Code Analysis can be run manually on a snippet of code, or even setup to automatically run as part of a Team Build or check-in policy for TFS [Team Foundation Server].  

Learn more about Code Analysis, What's New in Visual Studio 2012, and how to run Code Analysis on your system here.    

Code Metrics

Another feature that I truly like in Visual Studio 2012 is Code Metrics. Code Metrics is a tool introduced within Visual Studio that measures the evolvability and maintainability of a software system by calculating five important metrics. This helps the development team identify potential risks, understand the current state of their project, and track progress during software development.

The five metrics are:
  • Maintainability Index: a value between 0 and 100 that represents the relative ease of maintaining the code. Higher values indicate better maintainability.
  • Cyclomatic Complexity: this metric is a measure of the structural complexity of the code; it calculates the number of different code paths in the flow of the program. The actual value of this metric differs from one Visual Studio version to another. But a rule of thumb is that no individual method or property should have a Cyclomatic Complexity that is greater than ten.
  • Depth of Inheritance: it indicates the number of class definitions that extend to the root of the class hierarchy. The deeper the hierarchy the more difficult it might be to maintain and understand the code. However, a high depth of inheritance can also indicate a greater level of code reuse. So it is difficult to judge what a good depth is.
  • Class Coupling: this one measures the coupling to unique classes through parameters, local variables, return types, method calls, and other types in the source code. High values of coupling limit the value of a type to be reused; so a lower value [lower than ten] is what you should aim for.
  • Lines of Code: a value indicating the approximate number of lines in the code. A very high number indicates that the method/type is trying to do too much and should be split up. It may also indicate that the type/method is hard to maintain. 

More about this important topic and how to generate Code Metrics in Visual Studio 2012 can be found here and here. 

Code Clones

A personal favorite! It is a new feature introduced in Visual Studio 2012 that detects ALL code fragments that are copied throughout the solution. The tool detects the separate fragments of code that are very similar. Usually, code clones make it hard to change your application because you have to look for each fragment to update. Now it is easier as Visual Studio helps you find these clones so that you can refactor or modify them. Or just get to know the amount of “potential” copy/paste used in the system you are working on! :)

More about this, here. 

Monday, 8 April 2013

Store Data with sessionStorage

Recently, I began working on a web application that relies heavily on client-side scripting. At some point, I needed to store some key value and use it again within the same context. Sounds easy, no? But hey, I need a client-side solution; so no sessions. And cookies won’t do since they can be disabled by the user; and they get sent to the server on every HTTP request, among other downsides.

After researching our options, we found about a neat solution that does fit the situation: sessionStorage.

What is sessionStorage?

sessionStorage is one of 3 client-side data storage options introduced with HTML5. The 3 main options are sessionStorage, localStorage, and client-side databases.

It is basically an object that exists as a property of the “windows” object. You can use it to store up to 5M [most browsers] or 10M [IE] of key-value pairs to be used locally.

The sessionStorage object persists in the window [tab] in which it is being used. If you close the tab [the top-level browsing context] it will not persist. Though, it will still persist if you refresh the browser tab, or navigate to another site then use “Back” to return to the same window it is defined within.

In short, the data in the sessionStorage object is deleted when the tab [window] is closed, or upon deleting it explicitly. This makes sure the data is not stored indefinitely.

API Methods and Example Usage

The sessionStorage object ships with the following five methods:
  • getItem(key): retrieves the value for the given key or null if the key doesn’t exist.
  • setItem(key, value): sets the value for the given key.
  • removeItem(key): removes the key completely.
  • key(position): returns the key for the value in the given numeric position.
  • clear(): removes all key-value pairs.

And one property, length, used to indicate how many key-value pairs are currently stored in the sessionStorage object.

The most straightforward example to showcase sessionStorage usage would be:

//Setting a key “Name” to the value “Alice” and saving it in the sessionStorage object.
  • sessionStorage.setItem("Name", "Alice"); 
//Retrieving the value of “Name”.
  • alert(sessionStorage.getItem("Name")); 

sessionStorage vs. Cookies

The main advantages of sessionStorage over Cookies are:
  • Cookies don’t allow big objects. sessionStorage on the other hand allows for 5M [most browsers] or 10M [IE] of data.
  • Cookies get sent to the server with each HTTP request which increases the traffic; not the case with sessionStorage.

Browser Support

According to Wikipedia, sessionStorage is supported in IE8+, Firefox 3.5+, Safari 4.0+, and Chrome 4.0+

Further Reading

You can refer to this very good article on NCZOnline for more information about this important and interesting topic.