JavaScript

JavaScript MVC Framework Comparison

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 Infoq.com 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. Continue reading

Standard
Agile

Continuous Integration Patterns

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.

Standard
MySQL

MySQL : Schema Optimization

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 and CHAR

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.

BINARY and VARBINARY

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

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.

Standard
MongoDB

MongoDB Course

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.

Standard
Agile

Implement your Test Strategy

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.

Continue reading

Standard
Agile

Automate your software delivery

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.

Continue reading

Standard
Databases, MySQL

B-Tree Index in MySql

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. Continue reading

Standard