What's up!

Pyaarey Allah!

Saturday, July 14, 2018

Is node.js still immature?

0 comments

Recently I was interviewed and accessed by a technical auditor. These people claim to visit incorporations internationally and talk on technical and non-technical aspects and processes of companies. They interview the technical leaders firstly and then speak to the team. After that they send written recommendations to the management, get approval and then dispatch those recommendations to the team leaders.

By background I was doing all my R&D on how I could use AWS cloud and node.js capabilities to achieve best of pricing, development, deployment, testing, DB storage, file storage etc. I was writing a small but comprehensive boilerplate app where I was testing almost s full life cycle of development and then test and deployment.

The interesting part of our discussions was that the accessors commented on node.js as an immature platform. Of course no developer in the current world ignores the importance of node.js and knows that node.js is emerging part of software development.

So as the accessor said: "Do you know Asif, we totally appreciate your efforts and like your work and R&D but we think that node.js is an immature platform yet. I said, "What in node.js is immature sir" and he tried to argue and me as well. During such comprehensive assessment we never have time of few seconds to touch a topic. Either they will not go in detail or will give you maximum of 20 seconds to explain your point of view. Which sometime is cruel for some topics and sometimes even 20 seconds is a total waste of time; but this is what it is.

My question remains there. Is node.js an immature platform? My head kept revolving around the same topic. One day in my life I want to speak to the same accessor and explain to him one single topic which is: "is node.js an immature platofrm"

So here my friends are my arguments

What exactly in node.js is immature? By core node.js is neither a web server, not a tool to give you anything finished. Node.js just runs on V8's JS engine and some of threading handled by libuv. What exactly you want node.js to do for you? My friend: node.js is just a baseline platform of tool to allow you to use whatever you want to do with ECMA/JS. That is it. So the tools which you use such as express, koa or meteor or anything matter; node itself has no big tooling other than providing a base installation on your machine.

Once we understand that node.js itself is too small to be called a "Solution provider" We must go and check "what makes node.js a "solution provider" Here is the list of things which make node.js an ultimate solution provider.
    1. Package manager examples
      1. NPM
      2. Yarn
    2. Webserver tools/framework examples
      1. express
      2. koa
      3. meteor
    3. Language options
      1. ECMA any version is possible
    4. Databses
      1. Anyone of your choice
    5. Data access layers
      1. Knex
      2. Typeorm
      3. sequelize
    6. Development tools/Views controllers etc
      1. Angular
      2. react
    7. TDD
      1. Chai/Mocha
      2. Jasmine etc
    8. And so so much more no npm and yarn
As we can see there is a good list of tooling around node.js, almost everything, then we cherry pick tools of our own choice. Such as I can prefer Angular over React or vice versa.

Then lets start comparing these cherry picked tools with one big solution provider framework such as ASP.NET
ASP.NET solution has these components
    1. Database layer usually SQL Server
      1. Entity framework for data access
    2. C# coding layer
      1. Services or BLL
      2. Data Access layer including repository and unit of work
      3. Dependency injection
      4. Controllers
      5. Routing configuration
      6. Application startup coding
      7. Request interruption such as Authorisation attributes & Action Filters  
    3. View engine
      1. Razor
    4. Front-end coding layer i.e JS
      1. All the tooling you can use in browser using JS/ECMA
Now we take each one of these components and start comparing with what is available on github in node.js tooling. We can start comparing test cases ran on the tool and we will find out that in node.js the tooling is tested and developed by mature teams which run countless tests on their own tools, and we can also compare how comprehensively issue tracking is done on tools.

For rapid examples
    1. View engines
      1. React: 100,000 stars, 18000 forks, 1200 contributors
      2. Angular (views and more) 58000 stars, 28000 forks, 1600 contributors
    2. Scripting
      1. Typescript, 36000 stars, 5000 likes, 316 contributors   

Lets create a list of comparisons of choices and maturity, This is done a format that first I will narrate ASP.NET component and then put a :: symbol and narrate its alternate in node.js 

  1. Database layer usually SQL Server or any db :: node can also use any db
    1. Entity framework for data access : substitutes I wanna mention
      1. Sequelize 15k stars with 700 contributors, 8k commits & 374 releases
      2. Typeorm 7k stars with 200 contributors, 3k commits & 36 releases
      3. Knex 7k stars with 240 contributors, 2k commits & 118 releases
  2. C# coding layer
    1. Services or BLL :: Usually done in C#
    2. Data Access layer including repository and unit of work
      1. Mentioned above
    3. Dependency injection :: Usually not needed bec of JS's nature of require(...) still there are plenty of good tools such as 
      1. https://github.com/jaredhanson/electrolyte
      2. https://github.com/jeffijoe/awilix
      3. https://github.com/luin/express-di
    4. Controllers :: three choices we can mention
      1. express 39k stars with 200 contributors, 5k commits & 275 releases
      2. koa 22k stars with 153 contributors, 1k commits & 70 releases
      3. meteor 40k stars with 390 contributors, 21k commits & 1100 releases
    5. Routing configuration
      1. Part of controllers framework
    6. Application startup coding :: All in your control in node.js
    7. Request interruption such as Authorisation attributes & Action Filters  :: All controller framework have great startup and middleware support much more powerful than ASP.NET
  3. View engine
    1. Razor :: In node.js you have so many view engine choices over 10 good ones, so there had to be a need to consolidate and now there is consolidator for express
  4. Front-end coding layer i.e JS
    1. All the tooling you can use in browser using JS/ECMA :: Same for node.js

So we can see that there are so so many mature choices in node.js as of today. We need to cherry pick a good tool for us. The conclusion is that node.js itself is not tool to be called mature or immature. Node.js is a baseline product which allows you to start playing as you like. Then you start picking from huge range of toolchains that you like. And if you make a mistake in your selection, that is purely your mistake not node.js. Also node has substitute for every tool in all popular desktop and web frameworks. 


Further reading: https://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
In this article Tomislav Capan explains some under lying architectural details and then explain some good tools. Worth reading. 

Wednesday, April 1, 2015

Backup and Archive Sql Server Database

0 comments

-- Set the name of the archive backup directory.



DECLARE @bakdir VARCHAR(300)
SET @bakdir = 'D:\radmade_projects\src\code\_db\'

-- Set the name of the database.
DECLARE @dbname NVARCHAR(1024)
SET @dbname = 'rmMedia'

-- Set the name of the database backup directory.
DECLARE @dbbakdir VARCHAR(300)
SET @dbbakdir = @bakdir 

-- Create the name of the backup file from the database name and the current date.
DECLARE @bakname VARCHAR(300)
SET @bakname = @dbname + '_backup_' + REPLACE(CONVERT(VARCHAR(20), GETDATE(), 112) + CONVERT(VARCHAR(20), GETDATE(), 108),':','')

-- Set the name of the backup file.
DECLARE @filename VARCHAR(300)
SET @filename = @dbbakdir + '\' + @bakname+'.bak'

-- Create the directories if necessary.
EXECUTE master.dbo.xp_create_subdir @dbbakdir
EXECUTE master.dbo.xp_create_subdir @bakdir

-- Backup the database.
BACKUP DATABASE @dbname
TO  DISK = @filename
WITH NOFORMAT, NOINIT,  NAME = @bakname, SKIP, REWIND, NOUNLOAD,  STATS = 10


-- Turn on the 'xp_cmdshell' function.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE

-- Build the command line string to add the file to the ZIP archive.
DECLARE @cmd VARCHAR(300)
--set @cmd = '"C:\program files\7-zip\7z.exe" a -tzip "D:\radmade_projects\src\code\_db\rmMedia\db.zip"  "D:\radmade_projects\src\code\_db\rmMedia\db.bak"'
SET @cmd = 'cd.. && "C:\program files\7-zip\7z.exe" a -tzip "' + @bakdir + @bakname + '.zip" "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

SET @cmd = 'del "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

-- Turn off the 'xp_cmdshell' function.
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE

GO

Thursday, March 12, 2015

Essential Concepts for a .NET Programmer

0 comments

C-Sharp(course-outline)
Basic Language features of C#
.Net Framework Introduction
T-Sql basic language features
Interface.
Classes.
Console Application.
Enumeration.
Properties.
Events.
Access modifiers.
Delegates.
Language-Features.
Generics.
Linq.
Extension Method.
Lamda Expression.
Anonymous Function & Type.
Collections.
Collection Intializers.
Collection-Dictionary.
Array List.
Parallel Programming
Threading.
Exception Handling
File Reading/Writing(SystemI/O).
System.String & String Operations.
System.Data.SqlClient(ADO.NET)
Reflection.
Send Email.
Download file from url.
Encryption/Decryption.
Entity Framework(5 or 6).
App.configg & web.Config basic & advanced techniques


MS SQL Server Installation
Create Table
Create Primary key.
Foreign key.
Index(cluster,non-cluster).
Create view.
Stored Procedure.
Cursor.
Trigger.
Normalization(3-Forms).
Data access from ado.net & Entity Framework. 

Good C# Tutorials on Pluralsite

0 comments

http://www.pluralsight.com/courses/csharp-from-scratch
 http://www.pluralsight.com/courses/csharp-from-scratch-part2
http://www.pluralsight.com/courses/csharp-fundamentals-csharp5
http://www.pluralsight.com/courses/csharp-generics
http://www.pluralsight.com/courses/csharp-interfaces
http://www.pluralsight.com/courses/csharp-collections
http://www.pluralsight.com/courses/csharp-extension-methods
http://www.pluralsight.com/courses/skeet-async
http://www.pluralsight.com/courses/csharp-events-delegates

Wednesday, March 5, 2014

SQL Server - Kill process attached to database

0 comments

If you are trying to run a command


And you can't get access to the database because database might be in use by the single user and is in the single user mode.

There is a work around.

Run This command


SP_Who will show you processes attached to your database. See DBNAME Column and find your database in it. Then note down SPID. For example 72 is the SPID of the process you want to kill.
Then run this command to kill the process.

Kill command will kill the process. And then you will be able to run Set multi user mode command again and it should work.

Saturday, February 8, 2014

Shrink database and check its progress

0 comments

Claiming space from a SQL Server database is not like deleting all rows from a table or truncate it. Please follow the instructions if you want to reclaim your disk space.

  1. Run Sql Command:
    DBCC SHRINKDATABASE (MyDBName, 10 )
    Here MyDBName is a valid database name and 10 is the percentage of reserved free space.
  2. Run following command to check percentage done:
    select percent_complete, total_elapsed_time, estimated_completion_time, * from sys.dm_exec_requests where command = 'DbccFilesCompact'

Monday, October 14, 2013

Husool ka pehla usool

0 comments

Husool ka pehla usool be-nyazi hai