Wednesday, December 17, 2014

Angular.js

There is a lot of demand in the tech community for AngularJS. Many companies currently maintain sophisticated data intense web front ends and would like to migrate to Angular. Some others are looking into starting new projects. They heard about Angular and they wonder if they should start straight on Angular or just implement a traditional Javascript/JQuery solution. And there are other companies that are already on Angular, they love it and want to expand on it!

I decided to write this article as the technology is relatively new and there is a certain learning curve for decision makers and IT personnel. Business decisions and productivity can very well be influenced with this technology.

AngularJS is a web applications framework developed by one of the teams at Google in 2009. They were experienced front end developers who felt a need to simplify both development and testing of front end components / web based user interfaces.

Angular is based on a MVC (Model-View-Controller) architectural model which basically divides the application in three different components:

- the model = captures the behavior of the application

- the view = displays an output of the application (such as a chart or a graph on the screen)

- the controller = accepts input and converts it into commands

The controller usually sends commands to the model to update its state or to the view to change its presentation, the model notifies its associated views and controllers when it was a change in the state and the view requests info from the model to update its presentation to the user.

So, in short, Angular works by reading the HTML page with its embedded custom tag attributes. These attributes are interpreted as directives instructing Angular to bind input and output parts of the page to a model that is described with standard Javascript variables.

AngularJS is designed to:

- decouple the UI from the Application's Logic
- decouple the client side of the application from its server side
- provide a structure to the sequential operations of designing UI, writing business logic, coding and testing
- reduce the difficulty of testing (by the way the code is structured)

Angular presents the programmer with very powerful directives that allow for re-usable custom HTML-type of elements. Here are some of these directives:

- ng-app = declares the root of an angular.js application
- ng-bind = sets the text of a DOM element to the value of an expression
- ng-model = establishes a two-way data binding between the view and the scope
- ng-view = handles JSON data before rendering templates
- ng-controller = specifies a JavaScript controller class that evaluates HTML expressions

Here is a version of a "Hello World!" type of application in AngularJS:

<script type="text/javascript"
     src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
----
<!DOCTYPE html><html ng-app><head>
  <title>Hello World in AngularJS</title>
  <script type="text/javascript"
   src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> </head><body>
     Textbox:
    <input type="text" ng-model="mytext" />
    <h1>Hello {{ mytext }}</h1>
</body>
</html>

The ng-app attribute basically tells Angular to be active in this part of the page. The ng-model attribute binds the state of the textbox with the value of the model (which is mytext). In a two-ways binding way, when mytext value changes Angular automatically changes the model with this value. And if we change the model's value Angular will change the value of mytext.

In conclusion, AngularJS presents the following advantages and opportunities in comparison with traditional JavaScript/jQuery programming:

- enables the programmers to create software quicker and with less effort
- delivers code that is easier to maintain and expand
- improves testing experience
- encourages good programming practices
- allows for easier, smoother collaboration with your team

Examples of applications where AngularJS is a great choice are:

- single or multiple pages web applications / front ends prone to future expansion
- complex, data intense applications
- web applications where the front-end developers do not have access to the back-end
- detailed, "grid-type" front-end applications such as financial applications or applications for accounting firms
- any other kind of application where html rendering in the browser makes sense

Examples of applications where AngularJS would not be the best choice are:

- highly computational / mathematical applications
- games

Make it a great day!

Adrian Corbuleanu
Miami Beach, FL
http://wittywebnow.com

Notes: to document for this article I used the following online resources.

1. http://wikipedia.com
2. https://angularjs.org
3. http://viralpatel.net
4. http://jeremyzerr.com

Monday, December 8, 2014

Node.js

Node.js is an open source runtime environment / platform that allows advanced programmers to build scalable, high-performance network applications.

Since lately there is a lot of node.js buzz in the Miami start-ups community, I decided to write this blog & explain the technology in a little more details. This blog does not want to be a comprehensive a node.js manual but it will give new developers and business community an idea about this relatively new technology.

Node.js gets implemented server side (i.e. on a Linux machine), it's based on javascript and it uses an event-driven, non-blocking I/O model which is very good for data intensive real time applications.

Node.js was created by an individual by the name of Ryan Dahl in 2009. It is currently gaining popularity and it is used by some large companies like Microsoft, Yahoo, Walmart, Groupon and Paypal.

The story says that Dahl was inspired after looking at a large file upload progress bar on Flickr. The browser could not assess what percentage of the file was uploaded and it had to query the server to retrieve that information.

Node.js can keep many connections alive without having to reject the new incoming connections. It can be compiled on the linux server and, many of these enhanced packages/libraries, it can also be downloaded as a pre-compiled library/binary. Combined with a  document database (such as MongoDB) node.js offers a unified javascript development stack.

Here are a little more details about the philosophy of non-blocking code:

Blocking code looks like this (in some form of pseudo code):

Read file from Filesystem {
Store content
Print content
}
Do something else

Non-blocking code looks like this (in some form of pseudo code):

Read file from Filesystem {
Whenever you complete, print content
}
Do something else

While apparently there is not much of a difference between these two different ways of serving things, if you sit down and draw time diagrams of these calls you will notice significant differences in performance.

Let's say we have 2 calls: one that takes 7 seconds, the other one takes 3 seconds.

When you run these two different calls in a blocking manner they will be sequentially served and the total time to process them will be 10s. When you run the same two calls in a non-blocking manner they will be served in parallel and the total time to process them will be 7s resulting in a 30% improvement in performance. The more concurrent calls you have, the more you will improve.

Syntax wise, on a standard linux machine:

Blocking

var content = fs.readFileSync('/path/to_filename');
console.log (content);
console.log ('Keep going');

Non-blocking

fs.readFile ('/path/to_filename', function (content, err)) {
console.log(content);
}
console.log ('Keep going');

Please notice the difference in the names of the system functions, readFile for non-blocking (or async) vs. readFileSync for blocking.

This example is just illustrating the concept on reading a file but similar code constructions can be built to consume web services, start/stop web servers, refresh web pages in real time etc. With node.js the events treated in the loop are always asynchronous. Typical blocking operations such as calls to web services / apis, reads / writes from / to databases or calls to extensions can now be accelerated.

Here are some types of applications you can build using node.js:

(1) Chat servers
(2) Social media networks
(3) Fast files upload solutions
(4) Ad servers
(5) High volumes e-commerce sites
(6) Collaboration tools
(7) Mobile apps that talk to a db via an API

Here are some types of applications where node.js is not the best fit for:

(1) CPU intense applications / algorithmic applications [i.e. it won't be the best idea to write a chess game in node.js]

Make it a great day!

Adrian Corbuleanu
Miami Beach, FL
http://wittywebnow.com

To document for this article I used the following online resources:

1. http://nodejs.org
2. http://codeschool.com (node.js for dummies)
3. http://stackoverflow.com
4. http://wikipedia.com

Monday, December 1, 2014

5 business mobile apps we use every day

There are thousands of new consumer apps coming out every day. People use them to communicate, navigate, get on social media, take pictures, figure out their way around in Disney Parks, play games, listen to music, watch videos etc.

But how about business apps? Everybody is using their favorite e-mail application, calendar, browser and text utility. What are some of the more specialized apps though? They can fuel your business growth.

Here are five classes of business apps we use on a daily basis. We actually use many more business apps than just these five including some of our business apps but I am writing this for a larger audience.

1. LinkedIn

The mobile app of LinkedIn is an awesome app to keep in touch with, grow and involve your professional network. I use both the Android and the iPhone versions- they are both free of charges. I add new contacts, respond to messages, post updates, check out profiles, get business referrals etc. Weather I am attending a conference, workshop or client meeting all of these operations work beautifully on the go without booting up my laptop.

2. Meetup and Eventbrite

These are events management apps distributed by their respective Organizations. I am big with local events and tech meetings and I usually schedule my participation two weeks ahead. Meetup in particular is great because it gives you the opportunity to participate in online mobile discussions and interactions right around a certain event is scheduled- which is a great opportunity to have your message communicated and involve users who will participate in the meeting. And of course you have all the standard features like calendars of upcoming events, addresses, phone numbers, mobile sign-ups, integration with Maps / driving directions etc.

3. Fidelity

I've been using this app for about a year now migrating from my older desktop version. It basically allows you to manage your stock market investments with real time quotes. Even if I am not by any means a day trader or a short term investor- I actually prefer long term positions- I always get market quotes on my favorite stocks such as BABA, GOOG, FB, TSLA, AAPL and TWTR.

4. Skype and Google Hangouts

These are good quality mobile communication apps. Without being perfect quality and SLAs wise, they are very decent free tools to have long distance video and conference calls, share work and message with teams involved in projects. I've been using their desktop versions for years and I had been recently migrated with great results to the mobile versions. I can now hold an operational / progress update meetings (i.e. meetings during breaks of business presentations) without being held hostage at my desk- which gives me a push in productivity and velocity,

5. Google calendar

The old Google calendar still makes the list. It is particularly useful as it integrates nicely with the desktop version (it's actually a cloud hosted calendar which can be managed from any kind of device). It is a tremendous help for me as I get reminders on scheduled meetings, phone # / bridges, addresses, contacts etc. It also integrated nicely with Google Maps for driving directions on the go.

Make it a great day!

Adrian Corbuleanu
Miami Beach, FL
http://wittywebnow.com