breaking the eggshell: from .net to node.js

Post on 27-Jul-2015

402 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Breaking the eggshell: From .NET to Node.js

Barbara Fusinska@basiafusinska

barbarafusinska.com

About me

ProgrammerGeek

Sweet tooth

Objectives

Agenda

• When, why & what?• But… Windows• Application building crash course– Development environment setup– Creating the web application– Async library– Working with databases

• Managing the application– Testing– Debugging

What is Node.js?

An open-source platform built on JavaScript runtime that

uses an event-driven, non-blocking I/O model for

easily creating lightweight server-side and networking

applications.

Why is it so cool?

• Platform independent• Scalable• Faster• Lightweight• Optimised

JavaScript

If you still don't think JavaScript has won the web, please read on.

Is JavaScript tragically important?

Any application that can be written in JavaScript will eventually be written in

JavaScript

It’s a cancer (Node.js)

Prototype approach support

• Easy onboard• Simple programming

model• Simple solution that

works

A bit of an architecture…

How to choose?

• CLR – multithreaded engine, CPU heavy operations

• Node.js – single thread, leightweight I/O heavy systems, async everything

Cross platform

Simplicity

Community

• .NET – well established, Patterns & Practices

• Node.js – considered simpler, just works

But… Windows

• Node runs on Windows• Node can run inside IIS• Node can run on Windows Azure

• Cross-platform handling:– VM– Containers

Node Tools for VS

VS Code

Installation & configuration

Package Management

• NuGet -> npm• .nuget/packages.config

-> packages.json• packages ->

nodes_modules

npm

Development environment

• IDE• Running the app• Organising the project• Dependencies

Running Node.js app

Nodemon

Task runners

• Why? -> automation

• What?:– Tests– Building css files– Loading libraries– Running– Deployment

Gruntfile

Updating statuses

How

API Web AppGET api/events

POST api/events/:username

Creating web app

ASP.NET MVC,WebAPI Express

Razor

SignalR

Vash.js

Socket.io

Creating express app

Express vs. Asp.NET MVC

Organising the code

App.js

Routing

Passing model

Jade

Callbacks

Async

Async solution

Databases

• MongoDB• Cassandra• CouchDB• ElasticSearch• Redis• PostgreSQL• MySql• MS Sql Server• Oracle

Set up the connection to MySql

Querying MySql

Testing

• Testing– Jasmine– Mocha– Expresso (no longer maintained)– Should– Karma

• Mocks– Sinon– Mock– NodeMock

Jasmine

Mocks

Tests in task manager

Running tests

Debugging – node-inspector

node-inspector debugging

Debugging – VS Code

Summary

• Why consider Node.js?• Introduction– Development environment– Building the application– Node concepts– Maintenance

Questions?Barbara Fusinska@basiafusinskabarbarafusinska.com

https://github.com/BasiaFusinska/FromNet2Node

top related