Vikas Gupta: Software architect

JavaScript MVC Framework Comparison

Posted by Vikas Gupta on August 4, 2013

Javascript is emerging as a prominent development language in past few years. It has been increasingly adopted in various web based projects. It is also used to develop hybrid mobile applications. However, a common concern in the adoption of Javascript as a development languages has been the maintenance of  Javascript code in larger teams. Over the years, in order to improve code maintainability, separation of concerns using MVC pattern has been used. A lot of Javascript frameworks have emerged which have provided a means to enforce MVC pattern in Javascripe code as well. In this post, I will discuss top MVC frameworks and their pros and cons.

Let me start by presenting the results of survey conducted by to choose the top MVC frameworks.

JS MVC comparison

According to the survey, some of the top frameworks are AngularJS, Backbone.js, Knockout, Ember.js. Let’s discuss the pros and cons of top frameworks. We will consider pros and cons of AngularJS, Backbone.js, Knockout, Ember.js. Read the rest of this entry »


Posted in JavaScript | 1 Comment »

Continuous Integration Patterns

Posted by Vikas Gupta on July 15, 2013

Continuous Integration (CI) is the process of building software with every change committed to a project’s version control repository.

CI can be explained via patterns (i.e., a solution to a problem in a particular context) and anti-patterns (i.e., ineffective approaches sometimes used to “fix” the particular problem) associated with the process. Anti-patterns are solutions that appear to be beneficial, but, in the end, they tend to produce adverse effects. They are not necessarily bad practices, but can produce unintended results when compared to implementing the pattern.

Posted in Agile | Leave a Comment »

MySQL : Schema Optimization

Posted by Vikas Gupta on June 16, 2013

Good logical and physical database design is essential for high performance of a system. In this post, I will list down some of the best practices that you may use while designing your schema.

Choose the right data type

Choosing the right data type goes a long way in improving the performance of a website. The following guidelines may help you in making better choices:

  • Try to use the smallest data types that can correctly store and represent the data. The reason is obvious. Smaller data types use less disk space, memory and CPU cache.
  • Use simpler data types. For example, use integers where you can instead of strings.
  • Avoid Null if possible. Most of the times we do not make a column as NOT NULL, even though there is no NULL value in that column. This happens because columns are null-able by default. We should avoid null-able columns, because they makes optimization harder for database.

Guidelines for choosing right data type

It is not hard to choose a data type on a broad level. For example, it is not hard to decide whether to use String, Date, Numeric type. However, you may follow the guidelines mentioned below to choose a specific data type.

Whole Numbers

MySQL supports TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT requiring 1,2,3,4 and 8 bytes of storage space, respectively. While using these data types, if you add an UNSIGNED attribute, the storage capacity of these datatypes, effectively doubles. Both, signed and unsigned attributes use the same amount of storage.

Real Numbers

Numbers having fractional part are real numbers. MySQL support FLOAT and DOUBLE for approximate floating point math and DECIMAL to store exact fractional numbers. DECIMAL can also be use to store numbers that are so large that they do not fit into BIGINT.

FLOAT and DOUBLE use lesser amount of space than DECIMAL. Use DECIMAL only in case when exact calculations are required. However, before using DECIMAL, explore the option to storing the values as multiple of the smallest fraction of currency you need to handle. For example, if you want to store the data up to two decimal places, you can  store the value multiplying it my 100 and use BIGINT. It will result in better performance

String Types


VARCHAR stores variable-length string and is the most common string data type. It requires less storage space because it uses as much space as needed.  VARCHAR also uses 1 or 2 extra bytes to record the value’s length. For example, VARCHAR(11) will use up to 11 bytes of storage space.

VARCHAR helps performance because it uses less space. However, it may lead to fragmentation. So, use VARCHAR when the average column size is much smaller than the maximum column length, or when updates to a particular column is rare. MySQL preserves the trailing spaces when you store and retrieve values.

CHAR is fixed-length. CHAR is useful if you want to store very short strings or if the values are nearly the same length. For example, CHAR is a good choice for MD5 values of user passwords, which are always the same length. CHAR is also not prone to fragmentation.


These datatypes store binary strings. These are useful to store binary data and want MySQL to compare the values as bytes instead of characters. Byte comparisons are faster than string comparisons.

BLOB and Text

These datatypes are designed to store large amounts of data as either binary or character strings. Characeter types haves TINYTEXT, SMALLTEXT, TEXT, MEDIUMTEXT, and LONGTEXT, and the binary types are TINYBLOB, SMALLBLOB, BLOB, MEDIUMBLOB and LONGBLOB. Interestingly, TEXT is a synonym for SMALLTEXT and BLOB is a synonym for SMALLBLOB. The difference between binary and character types is that binary types stores binary data with no collation or charecter set, but TEXT types have a charecter set and collation.

One important point to note about regarding sorting BLOB and TEXT columns is that MySQL instead of sorting the full length of the string, it sorts only the first max_sort_length of such columns.


ENUM columns can be used to store values which are predefined for a particular type. For example, if you have a table with a column name status, then ENUM can be used to store values for that column. The benefit of doing this because MySQL stores ENUM columns very efficiently. It used just one or two bytes as internally it stores the values as integers.

Please note that by default MySQL sorts fields by internal integer values, not by the string themselves. So, it is advisable to specify ENUM members in the order in which you want them to sort.

One downside of using the ENUM is that the list of strings is fixed, and adding or removing strings requires the use of ALTER table. One more downside of using ENUM is that it is slower to join CHAR or VARCHAR with ENUM than with another CHAR or VARCHAR.

Date and Time types

MySQL supports various kinds of date and time values, such as YEAR and DATE and most of the times there is not two choices about which one to choose. The question of choice arise when you need to store both the date and the time. MySQL offers two very similar data types for this purpose: DATETIME and TIMESTAMP.

The main difference between the DATETIME and TIMESTAMP types are:

  • DATETIME uses 8 bytes of storage space and TIMESTAMP uses only 4 bytes of space.
  • DATETIME store the date and time into an integer in YYYYMMDDHHMMSS format and TIMESTAMP stores the number of seconds elapsed since Midnight, Jan 1, 1970.
  • TIMESTAMP preserves the timezone.
  • TIMESTAMP columns are not null be default.
  • MySQL sets the values of first TIMESTAMP column during insertion and updation if it’s value is not specified.

By default one should you TIMESTAMP to store date and time. Also, when you need to store time upto subsecond resolution, you can use a BIGINT column and the store then values as a timestamp in microseconds.

Posted in MySQL | Leave a Comment »

MongoDB Course

Posted by Vikas Gupta on May 30, 2013

Recently I completed an online course on MongoDB conducted by 10Gen, a software company that develops and provides commercial support for MongoDB. The course comprised of online lectures, quizzes and weekly assignments following by a final exam. The entire course lasted for 7 weeks.

The overall course pedagogy was really good and concepts were explained really well. One point of improvement is the speed of their website which was slow as page refresh took long time. The course covered the following topics.

  1. Introduction to MongoDB
  2. CRUD using MongoDB
  3. Schema Design
  4. Performance and Query Tuning using Indexes
  5. Aggregation for complex queries
  6. Replication and Sharding

The course concluded with a Final Exam. I got overall 85% marks.

All those who secured more than 65% marks were given a completion certificate. You can see my certificate which is attached here.

10gen is offering other courses as well on MongoDB. You can visit their courses page to know more.

Posted in MongoDB | Leave a Comment »

Implement your Test Strategy

Posted by Vikas Gupta on January 28, 2013

Importance of having a Test Strategy

Testing is a cross-functional activity that involves the whole team, and should be done continuously from the beginning
of the project. Building quality in means writing automated tests at multiple levels (unit, component, and acceptance) and running them as part of the deployment pipeline, which is triggered every time a change is made to your application, its configuration, or the environment and software stack that it runs on. Manual testing is also an essential part of building quality in: Showcases, usability testing, and exploratory testing need to be done continuously throughout the project. Building quality in also means constantly working to improve your automated testing strategy.

The design of a testing strategy is primarily a process of identifying and prioritizing project risks and deciding what actions to take to mitigate them. A good testing strategy has many positive effects. Testing establishes confidence that the software is working as it should, which means fewer bugs, reduced support costs, and improved reputation. Testing also provides a constraint on the development process which encourages good development practices. A comprehensive automated test suite even provides the most complete and up-to-date form of application documentation, in the form of an executable specification not just of how the system should work, but also of how it actually does work.

Read the rest of this entry »

Posted in Agile | Leave a Comment »

Automate your software delivery

Posted by Vikas Gupta on January 20, 2013

If a customer wants to add a feature/idea to a product, the time that it will take to release a feature to the market will depend upon the maturity of processes and practices employed by the software delivery team that works on it. The lesser time it takes, the better it is.

But, how can we reduce the time it takes to deliver software? What are the limitations of the traditional software delivery process? How can automating the various stages of software delivery process reduce time to market. In this post my attempt is to introduce the concept of Continuous Delivery, which in a nutshell is automate everything which you can in your software project. I will also list some of the anti patterns of software delivery. So, if you see any of these in your projects, I think you have an opportunity to improve. This post will the first in the series of posts that I am planning to write on Automated software delivery process. In the coming posts, I will discuss more concrete advice on various phases of software delivery lifecycle.

Read the rest of this entry »

Posted in Agile | Tagged: , | Leave a Comment »

B-Tree Index in MySql

Posted by Vikas Gupta on December 17, 2012

Indexes in MySql works like an index in a book. While, indexes in a book tell you about the pages on which a term occurs, indexes in MySql tell you the rows that contain the matching data. An index contains values from one or more columns in a table. If you index more than one column, the column order is very important, because MySQL can only search efficiently on a leftmost prefix of the index. Creating an index on two columns is not the same as creating two separate single-column indexes. In this post, I will discuss about B-Tree index and it’s working in MySql. Read the rest of this entry »

Posted in Databases, MySQL | Tagged: | Leave a Comment »

Why MongoDB?

Posted by Vikas Gupta on November 21, 2012

A database is needed to persist the data of an application. We have been successfully using relational databases to do so. They are mature and well known. So, why use a new technology like document based database to store the web application data. Let’s explore the reasons by looking at the features of a commonly used document based databases, Mongodb.  Read the rest of this entry »

Posted in MongoDB, NoSql | Tagged: | 1 Comment »

Git Rebase Explained

Posted by Vikas Gupta on November 19, 2012

Using git rebase, you can rewrite the history of a repository in a variety of ways.

rebase takes a series of commits (normally a branch) and replays them on top of another commit (normally the last commit in another branch). The parent commit changes so all the commit IDs are recalculated. This can cause problems for other developers who have your code because the IDs don’t match up.

There’s a simple rule of thumb with git rebase: use it as much as you want on local commits. Once you’ve shared changes with another developer, the headache is generally not worth the trouble.

git rebase takes a branch (the most common use), a tag, or a commit ID to rebase on top of.You can also pass the –rebase option to git pull, causing it to perform a rebase instead of merging the upstream changes into your local branch.

git rebase requires a clean working tree—that is, a working tree with no modified files. If you have changes that you’re not ready to commit, you can stash them until you’re done.

A conflict might arise during the replaying of commits. Like a conflict during a regular merge, a conflict happens when two commits modify the same line of code. git rebase stops when this happens and asks you to fix the conflict and then continue.

You tell Git you’re ready with git rebase –continue.

You can also skip a commit that’s causing a conflict by calling git rebase –skip. That could lead to further conflicts, however.You can abort the rebase too with git rebase –abort.

There’s always a safety net if you need to undo a rebase after it’s completed. Git points ORIG_HEAD at the commit before major changes like git rebase are run.You can use git reset to reset your repository back to that original.

To rebase your current branch against master, use

git rebase master

The following image shows the organization of commits before and after a rebase.


Posted in Uncategorized | Leave a Comment »

Git: How to create a new Repository

Posted by Vikas Gupta on October 16, 2012

Repositories in Git are stored on your local file system right alongside the code they track.You create a repository by typing git init in the directory that you want to start tracking files in.

There are two repositories in Git to collaborate with others: a private one and a public one. Private repository, is where you do all your work. It’s the repository with the working tree.

This two-tier system gives the ability to track local experimental changes while only sharing changes via your public repository that are ready for others to work with.

git init creates a .git directory in your current directory and initializes the Git repository inside that. Once the repository is initialized, we need to add (using git add) and commit (using git commit) the files in the repository.

With an initialized repository, you have a working tree that you can interact with. Working tree is the latest copy of the repository.

Create a repository.
prompt> mkdir test-repository
prompt> cd test-repository
prompt> git init

Add some files in the test-repository folder. To add and commit the files in the repository, use the following commands.

prompt> git add .
prompt> git commit -m “some commit message”

That’s it, with this commands, you have created a new repository and added few files in it.

In the next post on Git, I will discuss about cloning an existing repository into local machine.

Posted in Uncategorized | Leave a Comment »