Arthur Wang's Blog
Follow me on
  • My General Blog
  • Software Development
    • Latest Articles on Software Development
    • Complete Resources for Developers >
      • Tutorial Information for Developers
      • .NET Developer Blogs
      • Developer Journals and Magazines
      • Developer's Tools
      • Database Development
      • ​Developer Conference and Events
  • Tech
    • Latest Articles on Technology Development
  • Health
  • Money
  • Services
    • Modern Website Design
    • Web Maintenance of Existing Websites Service
    • Corporate Business Consulting Service
  • About
  • Contact
  • Art
  • 中文部落格

Taming the Wild Wild Web Development Tools like NPM, Bower, Gulp, Grunt and Node with Visual Studio 2015

5/26/2016

0 Comments

 
Picture
​If you are new to Visual Studio 2015 and wonder why all these external web development tools, such as Bower, NPM, or Grunt, were included in the new Visual Studio, then this article is for you.  There are tons of articles written on how to use specific tools and recommendations on which one is better than others.  In this article, we want to try to describe the ecosystem of these modern web development tools in a big picture and how tools have become complicated over time.  The quick and straightforward examples shown here will help you to get started with these tools and understand the reason behinds.

As the ASP.NET developers, we are used to having .NET Framework version upgrades and additional features like NuGet Package Manager and more whenever a new version of Visual Studio comes out.  But this time is not like that. The familiar folder structure is gone, and the web.config file is gone. The folder structure is quite different. There is even a ghostly “Dependencies” folder which appears in the Visual Studio Solution Explorer but not in the physical folders and there are unfamiliar default files [See figure below]. People even seem to move away from using Web Essentials, the Visual Studio Extension, which was a way to use the external tools outside of Visual Studio.  And even the use of NuGet Package Manager is discouraging, and instead, we are seeing more command line tools flourishing in the web development landscape as it seems like we were going backward to early DOS age after all these years of advances.  Are we going back to square one and what’s going on?
Picture
Showing Solution Explorer in Visual Studio 2015
To understand this, we must look at from the web development ecosystem perspective and cannot just look at Visual Studio itself or thought that Visual Studio just want to add some newer tools like NPM or Node.js into their product. We must recognize first that the software development as a whole is now undergoing a rapid growth phase.  New tools or upgrades are coming out on a weekly or even daily basis.  We have never seen such fast pace in the web development when comparing in the past years.   From staying competitive from a product perspective, Visual Studio needs to acquire new external tools and adopt latest web development trend to modernize its product and maximize the number of users. 

Moving away from NuGet

As the Visual Studio users, we are used to let NuGet manage our dependencies, and there is no doubt that it was a great tool.  However, NuGet is gearing toward for the Microsoft .NET ecosystem, and not all client-side libraries are submitted to the NuGet repository.  The Visual Studio users may cut from the outside world and unable to obtain the latest packages or new technologies.  As a result, Visual Studio needs to align itself to adopt the thriving development community. They do not have the resource to chase the trend and reinvent the wheels.  With the time constraint, Visual Studio still finds ways to integrate these new tools into the web development.
 
There are two popular package managers, Bower and NPM, tend to replace the NuGet tool, at least for the non-.NET component such as JavaScript or CSS.  You just need to choose one or both to manage your dependencies. NPM can be used for both server-side node packages and client-side packages.  Bower is more popular client side package manager..

If you use Visual Studio 2015, NPM, Bower will be installed by default.  And you can manage these tool versions from Tool --> Options --> Project and Solutions --> External Web Tools  
Picture
​This list shown on the right from the Option window tells Visual Studio where to find dependencies starting from top to bottom. So the Visual Studio program looks for node_modules\bin folder from your project first, and if it cannot find it, it will look for the folder under C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External and so forth.
​If you do not use Visual Studio, then you need to install them yourselves in this order.
1. Install node.js from nodejs.org, and it will also install npm by default
2. Install with a command line to install bower by using npm [npm install bower –g]
3. Install Git by using http://msysgit.github.io/  and use Git to download packages from GitHub.  

​Where are the confusions?

​For Windows users, we are so used to have no-brainer installation in the Windows environment.  Just double click and install. But to install a web development tool without Visual Studio 2015, there are so many steps just to install these tools, and we have not even talked about how to use them yet.  Life is easier in Visual Studio 2015.  Before we talked about how to use them in VS 2015, let’s compare Bower and NPM since they are doing the similar things like package managers, but it really dependent on your needs.  For example, if you need to keep two versions of jQuery in the production, then you need to use NPM, but if you need only one single copy of jQuery, you should use Bower since it just installs the designated version packages that you specified. So initially NPM is used for installing Node.js modules, and Bower.js is leaning toward on the use of managing the front end components like CSS, JS, etc. 

Here is how npm works:
 
There is a registry on the internet (npmjs.org) where tool developers can publish their works, and it is powered by the CouchDB database.  Once you installed the node.js on your local machine, from a command line, you can invoke npm.exe to manage your packages.  In your project folder, you will need a meta file named package.json that instructs npm on what to do.  The npm will go to the npm registry to find your missing packages and bring them into node_modules folder on your local machine. 
Picture
​So in Visual Studio 2015, all you need to do is to open the package.json file, and add the name of the package and its version under the devDependencies section, and as soon as you hit the save button, Visual Studio will act as a proxy to npm to grab those packages for you. 
Picture
Showing the content of package.json used by npm.exe
But if you preferred doing it manually, you can do it in the Package Manager Console inside the Visual Studio.  
Picture

​The Build System

​As you may have notice that each package manager has its own destination folder for the packages that it stores. Bower stores in the bower_components folder and NPM stores in the node_modules folder. In this case, we need to have another build step to copy those packages into our web development or production folder from the package folder.  For example, if we use AngularJS in the development, our AngularJS files may be located in node_modules folder if we use NPM, and we want packages to be located in our wwwroot/js folder.  Grunt and Gulp are the two of the most popular build systems out there to do these tasks. However, NPM can act as a build tool as well if you use its createReadStream function.  Nevertheless, if you need more complex build process, many people will likely choose either Grunt or Gulp since it has a lot of plugins to choose from.  In Visual Studio, these tasks located inside the Grunt or Gulp script can be managed via Task Runner Explorer.  You can do more inside the Task Runner Explorer when you right click on the task.
Picture
Conclusion
 
In this article, we have seen how these little tools such as the npm, grunt, and many others, are quite powerful, and they can do a lot of things for us as developers.  The tools help us from managing our dependencies to our build process, and they could also help us test and do continuous integration if we spend some time to configure them with scripts and a workable deployment pipeline can be built at the end. However, because of these tools live in an open source environment, there is no one to supervise and manage, it has its advantages, and there are some disadvantages as well.  When you need a tool's plugin to do something, you may find that you need more dependencies after dependencies, and sometimes it may add unwanted file size to your project.  There are more tools to fill the gaps of other tools. There are management tools to manage other management tools.  There are fixes and upgrades within the tools, configuration scripts may work for a few months and may not work if you upgrade certain tools.  It is an age of disruptor overboard, and it is quite a chaos if you think about it.  Regardless of the frustration that some developers may have experienced, we need to do our part of finding the right tools by testing and prototyping the workflows that fit our needs.  We should always have backup copies of these tools stored somewhere you can access since the process often assumes that you have an internet access.  On the security issue, we should also be alert to the risk of having such an easy but powerful tool like the npm.  Since node.js was already installed on our side, and this is always a vulnerability of allowing the malicious package to come in without any supervision.  Hopefully, the technology will become more mature and reliable sooner. ​The developers can spend more time on building great software and spend less time on finding the right tools for the right jobs and then figuring out how to use the tools to their best interests.  Perhaps, Visual Studio can tame the modern web development tools in the future version.
0 Comments

Understanding the Old and New .NET Technologies Through the Journey of C# Source Code to Executable Machine Code

4/27/2016

0 Comments

 
​The goals of this article go from viewing the .NET technologies from a big picture to details on how new .NET Core Native works under the hood.  I've broken it into three smaller parts:
  • The New Era for Microsoft Software Development 
  • Understanding the New .NET Core Technologies
  • ​Understanding .NET Native Tool Chain Under the Hood
0 Comments

Supercharge the Web Development Workflow with LESS or SASS (CSS Preprocessor)

2/26/2016

0 Comments

 
​The thought of adding another step to the already lengthy workflow on web development is discouraging.  You probably have been seen "LESS" or "SASS" somewhere for a long time but you have been tried to ignore it due to already lengthy workflow in your web development. If you are a web developer and has experience working with CSS, you probably have spend countless hours of copy and pasting section of CSS code from place to place and there are just so many repeating code lines and no one has thought of making it programmable and substituting repeating elements into variables, just like any other programming languages out there.  Actually, this was the reason inspired other developers to resolve this problem by creating new programmable CSS syntax languages called "SASS", Syntactically Awesome Stylesheets.  However, since browsers only understand regular CSS, a special type of preprocessor will be needed to convert this SASS files into CSS files before deployment.
How CSS Preprocessor works Flow chart
LESS is another type of language that was influenced by SASS, and both were written in Ruby.  Later, LESS was rewritten by using JavaScript instead.  The goals of these languages are to reduce duplication in the process of writing the CSS so no more repeating steps or DRY as in Don't repeat yourself. Another goal is to act more like CSS in their syntax. For LESS, it was redesigned to be as close to CSS as possible.  In one instance, you can include the less.js JavaScript file to convert the LESS code on-the-fly. Another way is to render the LESS code into regular CSS using the preprocessor. 
 
Besides less coding in using this method, your CSS code will be easier to be maintained and organized.  There are many frameworks built on top of CSS preprocessing languages that help you further in the front-end coding, such as making sprites, compliant CSS3, reusable patterns, managing vendor prefixes, and faster CSS writing.  The popular frameworks are Compass, Bourbon, Susy, Stylus, CSS-Crush, Myth, and Rework.  There are other less known CSS Preprocessors, such as Brunch, Switch CSS, DtCSS, Clay and CSS Preprocessor.  There is LibSass which does not required the Ruby.
Picture
If you prefer to use programs that acts as a compiler, instead of using the command line, there are several ones to choose from. The differences are that some accept both SASS and LESS, or just one, and some work on both Mac and Windows.  Here are the list of such programs.
 
1. CodeKit
2. Prepros App
3. Mixture
4. LiveReload
5. Koala
6. Compass.app
7. Scout
8. Crunch
9. WinLess
10. SimpLess
​11. Gulp
12. Ghostlab
 
Here are the list for old fashioned command line:
Grunt -  http://gruntjs.com/
 
In any ways you select from above, for Sass, you must install Ruby if you are on Windows since Mac already comes with Ruby preinstalled.  For LESS that is written in javascript, you will need NodeJS to run it.  
0 Comments

Introduction to Programming: Understand Programming objects and Programming Languages

2/18/2016

0 Comments

 
Programming SimplifiedProgramming Simplified
This is our second lesson (How to Program) from the first series courses on How to become a web developer from scratch. 
Please watch our first lesson, Learn from Arthur's Burger Drive Thru, if you have not watched yet.
 
In the first lesson, we learned a great deals of identifying what are the programming objects.  In this lesson, we are going to show you how these objects are created, converted, displayed, and transferred and then how you can do programming by yourself.  But before we dive right into this topic, I want to describe to you on how we structure this lesson. We basically divide this lesson into 2 parts.  Since as you may have heard, there are just so many different programming languages and scripts out there.  It could be very confusing especially for people who are new to programming as it has become very diverse and continues to evolve in a really fast pace especially in the past 5 years.  But the good news about it is that you don't need to learn the old and inefficient ways of developing web applications and you can start learning the easier stuff since programming is evolving in a direction of becoming simplistic but powerful at the same time. 
 
On one hand, the hard part about being a web developer is that you cannot just learn one programming language and expect to do everything you need to do.  On the other hand, you don't need to learn every single language out there but you just need to learn a handful of languages to do the job.  It may be overwhelming at first, but I'm confident that after today's lesson you will have a big picture of what you need to learn. 
In a similar fashion, you can pick and choose certain programming languages and scripts from company like Microsoft or from programming communities to develop your web applications as long as they are compatible with each other!
 
So in the first part of this lesson, we will find out where we can see these programming objects from a browser, and how these objects are created and how the same object are manifest or represented by different programming languages with some sample codes. In the last part of the lesson, we will focus on one popular object- oriented programming language.  Once you master one language, it will be easier for you to master the other language since the concept is similar and only the grammatical syntax may be different.



​Part 2: Find Programming objects from web browser (See Below)
This video demonstrates how the web browser uses static information received from web server to make web page dynamic with its programming component hiding insides the html code. 

Part 3: How web browser works in terms of programming objects?
​This video show you how web browser works and manages to display various programming objects send from web server to the users.  It describes HTML, CSS, and JavaScript in terms of how they present the same information in their own ways and how they are able to manipulate information.

Part 4: Inline and External files style sheet and JavaScript
This video demonstrates two ways of writing the style sheet and JavaScript in web pages and discuss the advantages and disadvantages.  It shows the solution of browser's caching problem.

Part 5: Explain JSON and XML & Group Popular Programming Languages
This video describes data transfer objects and attempts to categorize all popular programming languages in terms of front end and back end and client-side/server-side and discuss about node.js as well.
I hope you already see some patterns about programming codes and you feel more comfortable of learning how to program next.
0 Comments

Demystify Programming by Learning From Arthur's Burger Drive Thru

2/7/2016

0 Comments

 
If you have not watched the introduction video to the courses, please watch How to Become a Web Developer from Scratch? first.

​In this very first lesson, we'll give you the power of seeing the world differently just like a programmer. We will learn how to define input and out and identify various objects in the object oriented programming language. 

​Learn from Arthur's Burger Drive Thru Part 1: Demystify Programming
In the second part of the lesson, we will translate what we see in the real world into a written format.
We now know how simple and easy the programming code can be written.  We will also define function in programming language and understand are functions, input and output, and how the equal sign is used in the programming language.
Picture
In Part 3 of the lesson, Use Case & Data Flow,  we learn how to document what we see in the real world.  Using Use Case Model diagram and data flow chart to document the interactions we see.  
In Part 4 of the lesson, we learn the concept of Systems.  We learn how to define the concept of system, framework, library of objects, and enterprise system in the programming world.  
In Part 5 of the lesson, we take a closer look at the object itself.   We learn how to identify an object's property and its attributes and actions.
In the last part of the lesson, we learn the need for storing data. We learn to understand the roles of database and tables in a database in programming.  Learn how programming objects are stored and retrieved from the database.
0 Comments
<<Previous

    Arthur Wang

    @ArthurWangLA
    MCSD App Builder
    MCSD Web Applications
    ​Member of Windows Insider Program & HoloLens Developer Community & Dev Center Insider Program

    Over 17+ years of  experience in web-based software development & management.  Specialized in Microsoft technology with c# language and its architecture design.  MCSD, MCSE, Microsoft Specialist, MCP + Internet, and B.S. from UCLA

    Archives

    August 2018
    March 2018
    January 2017
    December 2016
    May 2016
    April 2016
    March 2016
    February 2016
    April 2014

    Categories

    All
    API
    Arduino
    ASP.NET
    Cognitive
    CSS
    Database
    Deep Learning
    DevOps
    Electronics
    Flexbox
    HTML5
    IoT
    Katana
    Machine Learning
    Management
    .NET
    .NET Core
    Neural Network
    OWIN
    Programming
    Programming Tools
    Recognition
    Security
    SQL Server
    UWP
    Visual Studio
    Web API
    Web Developer

    RSS Feed

    Latest Articles

© 2014-2020 ArthurWiz.com All Rights reserved. | Home | About |
Protected by Copyscape