Thursday, September 24, 2015

Immediately-Invoked Function Expression : what and why?

I remember I was confused by the syntax of Immediately-Invoked Function Expression in my early days with JavaScript. I'll follow DRY principle in this blog post and shall point to the articles that I found most helpful when I learned this.

The definitive explanation with very good examples can be found in Ben Alman's blog post. He actually coined the term IIFE which was widely adopted later in JavaScript community.

Why and when to use IIFE? 2 cases are recurring:
1) create private namespace: We can create private functions and properties and can expose only those members intended to be public. This helps us not to pollute global namespace. Vivin Paliath explained this really well on stackoverflow.

2) resolve global variable conflict: Josh Mock gave a good example of this.

Monday, September 21, 2015

Skills of a full stack developer

I had the following questions:
  1. What is the standard definition or scope of full stack developer?
  2. What does that 'full stack' look like actually?
  3. Why do employers seek full stack developer instead of developers specializing in particular aspects?
  4. What are the skills a full stack developer bring to the table?
  5. How to become a full stack developer? Is there any road map?

So I googled and read blog posts and articles. Here's my findings:

1. What is the standard definition or scope of full stack developer?

There is no acceptable definition yet. Some people have tried to define it in a logical way; some called it meaningless with valid arguments. Facebook engineer Carlos Bueno defined full stack developer as a generalist with a broad range of skills. Mike Loukides echoed the same idea - "Full-stack development is about exposing yourself to a broad range of ideas". The general impression that I got after reading several other articles is that it's a term being used to mean engineers or developers who is capable of working in any layer of the whole stack (usually web stack).


2. What does that 'full stack' look like actually?

The first bottleneck of defining a full stack developer is coming up with a good idea of the stack itself. Scott Hadfield presented a non-exhaustive list of layers that contains from hardware, OS, hosting, scaling to frameworks, front-end dev, security, business requirements. Edward Chung gave a list of roles/jobs needed to build a web application, ranging from web designer to web analyst, quality assurance tester.

Whenever we hear 'full stack', we usually think of LAMP, WAMP, or MEAN stack. What is obvious now is that these acronym-style stacks are just the tip of the iceberg or we can say the beginning of a long yet fun and rewarding journey.


3. Why do employers seek full stack developer instead of developers specializing in particular aspects?

The main reason for hiring 'jack of all trades' is speed and the economic benefit that follows. When a company wants to build a prototype or a MVP (Minimum Viable Product), a full stack developer is very handy. Because (s)he can understand and work in all layers of the application. This essentially eliminates the overhead of communication, for instance, between UI designer, front end developer, back end developer, database developer and database administrator, DevOps engineer. In an Agile environment, a full stack developer can focus on a complete end-to-end feature.

4. What are the skills a full stack developer bring to the table?

Jack of all trades, master of a few. In my opinion, that's a reasonable expectation. We no longer can afford to remain in a silo and to become a true master of one thing but almost ignorant of others. A full stack developer is able to grasp the big picture - the whole stack - and working across the layers and whenever help is needed, (s)he is able to communicate the problem effectively to an expert in the team. The 'value proposition' of full stack developer is versatility.

5. How to become a full stack developer? Is there any road map?

This is subjective. The answer also depends on the background (web designer vs. web developer) of an aspiring full stack developer. The following is the start of one of many possible road maps:

JavaScript-based platforms and frameworks are extremely in demand now. So this road map assumes that we want to be proficient in JavaScript-based full stack.

  1. Decide on a project idea that you are very motivated to see coming into life. Write down the detailed requirements. Create 'user stories'. Go through the requirements again and again so that you have a good idea of what you're going to get. If you don't have any idea, just google for project idea.
  2. Learn the basics of language first. As you work more and more in that language, you will learn details about the different features the language provides. It is not a good idea to target being a master in the first step. Just get comfortable using the language.
  3. Pick a popular front end framework or library. I wasted a lot of time trying to figure out THE ONE. Like all programming languages, frameworks and libraries have strengths and weaknesses. AngularJS is a very popular and established framework now. Let's start with this. The experience gained while working with one framework/library will definitely help you pick another one very fast. Do a few tutorials of AngularJS. Then implement the client-side functionalities of your project.
  4. Pick a back end framework or library. Node.js is the most popular JavaScritp based platform. Pick a popular Node.js-based framework or library. Following MEAN stack, you can choose Express framework. (By the way, the number of JavaScript-based libraries and frameworks will soon outnumber the population of the world. So don't spend too much time to choose the 'best' like I did.) Do a few tutorials of Express. Then implement the server-side functionalities of your project. It's okay if data is hard-coded for now. Expose your server-side capabilities as APIs. Modify client-side to consume those APIs.
  5. Pick a database. A full stack developer should be very knowledgeable about the trade-offs of relational vs non-relational (NoSQL) databases and must know when to use which. For now, just pick MongoDB. Learn the basics, design your data collections and attributes. Do a few tutorials of Mongoose and know how what it is useful for. Finally implement the integration of your server-side code with DB. You should be careful about how you keep the DB interaction logic and business logic separate in your code base.
  6. Now it's time for deployment. You can use cloud infrastructure provider. In that case, learn about docker, do a few tutorials and write dockerfile for your client, server and DB containers. You can use docker-compose (successor of Fig). Alternatively, you can use PaaS, for example, Heroku or Pivotal (Cloud Foundry). Learn how to use them.
  7. Now start broadening your knowledge about trade-offs involved in design decisions. In addition to that, increase your familiarity with different available libraries and frameworks. Let's start with front end. What are the other popular alternatives? Pick one by one. Do a few tutorials. Re-implement your client-side with that library or framework. What kind of client-side needs is this suitable for? Do the same things for back end.
  8. Regarding databases, know about different data models of NoSQL databases (key-value, column, document, graph) and the trade-offs (performance, scalability, flexibility, complexity). Which one will be the most appropriate for your project when you have millions of hits per hour? Moreover, in which cases relational databases are the most appropriate ones?
  9. Eventually the back end can be a distributed application communicating through messaging. How can you decompose your back end application into small independent applications so that you can scale in a more refined manner? This is where polyglot programmers come in handy. For instance, you can implement a CPU-intensive part of your distributed application in Go.

I would appreciate your suggestions regarding the possible road maps for being a full stack developer.

Wednesday, August 22, 2012

Tracking Time at Office

Before being a team lead, I used to work on a single task, in addition to the usual office chores. Now things have changed a lot. I find it hard to keep track of time during office hours. At the end of day, I wonder how much time I actually spent on my assigned task, how much time I worked with other teammates. I felt the need of a time tracking software.

In my previous software firm, Structured Data Systems Ltd. - an offshore branch of AfriGIS, South Africa, employees were encouraged to track time by using a software named Klok. A free version is available. I have started using it.

I intend to try out other related softwares later.

Here is the template I am using now:

Office chores
  > Check office mail
  > Daily scrum meeting
  > General office meeting : occurs occasionally
  > Lunch
  > Refreshment : 2 times a day - at around 11 am and 5 pm.
  > Table Tennis : we play TT at office!
 
Team work
  > Check client issues at JIRA and update TRAC
  > Check teammates' yesterday's work at TRAC
  > Today's task assignment
  > Retrospective meeting: weekly event
  > Work with teammates: I frequently do this. Tracking time for every teammate will enable me to find a trend about with whom or on what task I do pair-programming for a given period of time.
  > Knowledge sharing session: I greatly encourage to do this immediately after lunch when everyone is relaxed. I am planning to practice this more vigorously.
  > Meeting with Product Development Manager (PDM): occurs everyday intermittently.

Wednesday, August 08, 2012

Checklist Before You Join a New Company

Sometimes I browse the job sites to find out companies for better opportunity. When a job circular seems good, many questions pop up in my mind. Often, I can manage someone familiar working there and I get to know about that particular company.

I think it is a good idea to have a checklist for this. Here it goes!

PROJECT:

1) How many projects are currently going on?

2) What is the average age of the projects?

3) Which technologies does the company work with?

4) How important is the project (for which recruitment is going on) to the company?

5) What are the application domains of the ongoing projects?

6) What is the average experience of engineers working there? I mean years of experience for most of the engineers.

WORK CULTURE:

1) How do you think the company provides a good learning opportunity for an engineer?

2) Do you feel sportive at office? or it feels like a conventional office (everyone working at his desk, no adda, few brainstorming among colleagues)?

3) How many hours do you "actually" need to work a day, on average? I mean, productive hour.

4) How frequent is overtime?

5) How frequent is working on weekend?

6) Do you feel that your job is secure?

7) How friendly is the relationship among the engineers?

8) How cooperative is the relationship between engineers and management?

9) What do you think a unique quality of the company that sets it apart from the other companies in the market?

10) Do you follow any software development process? If yes, what is it?

REMUNERATION:

1) What is the salary range for a fresher?

2) How many times in a year do your company give salary increment?

3) What is the average percentage of increment?

4) Is project bonus a regular phenomenon?

5) What are the other benefits?

Tuesday, July 26, 2011

snprintf is not a member of std

I am working on an Xcode project that includes boost thread library through cross-project reference. One step of setting up cross-project reference is to add value for Header Search Paths setting under Build tab (from project target's Get Info option). While doing so, I have checked the Recursive check-box.

When the project is built, the following error occurs:

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/include/c++/4.0.0/i686-apple-darwin9/bits/c++locale.h:72: error: 'snprintf' is not a member of 'std'

Googling leads to a solution - Uncheck the Recursive check-box.

Xcode version I am working with is 3.1.4.

Friday, July 15, 2011

How to build OpenSSL in Xcode

I extensively googled for how to build OpenSSL library in Xcode for iOS. I found the following links most useful:

* TUTORIAL: IPHONE APP WITH COMPILED OPENSSL 1.0.0A LIBRARY

Describes how to use already built OpenSSL static library in an Xcode project, how to build static libraries of OpenSSL for different architectures (i386, armv6, armv7) from terminal, how to make universal fat library with lipo command.

* TUTORIAL: SCRIPT FOR BUILDING OPENSSL FOR IOS (IPHONE/IPAD)

Script to build for both simulator and device.

* Easy inclusion of OpenSSL into iOS projects

Points to the following two Xcode projects on github that hides all the 'black magic':
1. Xcode project for OpenSSL by Stephen Lombardo
2. Xcode project for OpenSSL by Michael Tyson

Michael Tyson's project is easier as it simplifies Lombardo's project.

Since our target is to use cross-project reference technique wherever possible due to its greater flexibility in building for different architectures(i386, armv6, armv7), I went for Xcode project approach and used the one created by Michael Tyson.

The procedure is given below:
1. Download the OpenSSL source code directly from http://www.openssl.org/source/
2. Clone the openssl-xcode git repo to make a local copy
3. Put the downloaded OpenSSL source tar.gz into the same folder as openssl.xcodeproj.
4. The extracted OpenSSL distribution can also be placed in a folder called 'openssl' within the same folder as openssl.xcodeproj, or just extracted within the same folder as openssl.xcodeproj.
5. Then open openssl.xcodeproj in XCode and initiate a build

A possible problem:
In the Xcode project window, under Products directory, there is only libcrypto.a static library. As far as I know, OpenSSL build is supposed to produce two static libraries - libcrypto.a and libssl.a. However, I found libssl.a within the same folder as xcodeproj file. I sent a mail to Stephen Lombardo, original Xcode project creator for OpenSSL, still did not get any reply to the query - why libssl.a is not present in the Products folder of Xcode window.

Update #1:
The problem I guessed might happen actually happened when I tried to use the intended module from a test project. A good number of link errors related to SSL were produced. Googling with the first link error phrase SSL_CTX_free confirmed that libssl were not linked properly. I did not know how to add an additional library to Products folder (under Groups and Files pane in Xcode project window) so that it can be linked properly. Adding libssl.a file to Products folder in a straightforward manner did not help remove those link errors.

While trying out in an adhoc manner, I finally came up with the following procedure that could eliminate those SSL-related link errors:

Add libssl.a to the Products folder under Groups and Files pane in openssl project's window:

Step 1: Add New Target ssl:

Right click on Targets under Groups and Files pane.
Select Add -> New Target...
A dialog with title "New Target" will appear. On the left, under iPhone OS category, select Cocoa Touch. Then on the right, select Static Library.
Click Next button. Write ssl for Target Name. openssl should be selected for Add To Project.
Click Finish.

Step 2: Enter info about target ssl:

A new window titled Target "ssl" Info will appear from the previous step.

We need to add crypto as a dependency of ssl. Under General tab, Between Direct Dependencies and Linked Libraries, click + and select crypto, then click Add Target.

Select Build tab. Type search in the search box.
Under Search Paths category, for User Header Search Paths key, add value $(openssl_SRC) as path, set Recursive checkbox. openssl_SRC is an Xcode Source Tree variable defined from Xcode Preferences. It refers to the directory in which openssl.xcodeproj file is.
For Header Search Paths key, add value $(openssl_SRC)/openssl/include
Close the window.

Step 3: Link
Under Groups and Files pane, drag libssl.a from Products folder to Targets -> ssl -> Link Binary with Libraries folder.

Now the other projects that referred to openssl project with the help of cross-project reference mechanism should have both libcrypto.a and libssl.a static libraries when openssl.xcodeproj is expanded in client project's Xcode window.

Additional necessary steps for client projects:
Now that a new static library libssl.a has been added to openssl project, client projects must know about it. If libssl.a is added to openssl project before any client project refers to openssl project via cross-project reference mechanism, this is not necessary.

Let's assume openSslClient project is using openssl project.

Right click on openSslClient under Targets, select Get Info. A new window titled Target "openSslClient " info will appear.

Under General tab, add ssl to Direct Dependencies.

Under Build tab, User Header Search Paths and Header Search Paths should have appropriate values for openssl as it was done earlier for libcrypto.a. openssl.xcodeproj was added to openSslClient project through cross-project reference, following an excellent article by Clint Harris.

Close window.

Under Groups and Files pane, expand openssl.xcodeproj and drag libssl.a from there to Targets -> openSslClient -> Link Binary with Libraries folder.

Update #2:
Stephen Lombardo replied to my mail. He suggested adding a second target for ssl. I have already done this :-)

Wednesday, July 13, 2011

How to build c-ares library in Xcode

- Download the latest version of c-ares library on a Mac and unzip it.
- Open the terminal and go to the source file directory.
- Execute ./configure and it will create ares_config.h file.

- Now open a new project in Xcode. I created a Library project for iPhone OS category and named it 'cares'.
- Right click on 'Classes' and select Add -> Existing Files. A file dialog box will appear. Select and add the source file directory. The source codes will be added to the project.
- Right click on the project and select 'Get Info'. Under 'Build' tab, write 'flags' in the search box. You will see an entry named "Other C Flags". Add value -DHAVE_CONFIG_H for it.

Now c-ares library should be built in Xcode without any error.