breaking the eggshell: from .net to node.js

50
Breaking the eggshell: From .NET to Node.js Barbara Fusinska @basiafusinska barbarafusinska.com

Upload: barbara-fusinska

Post on 27-Jul-2015

402 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Breaking the eggshell: From .NET to Node.js

Breaking the eggshell: From .NET to Node.js

Barbara Fusinska@basiafusinska

barbarafusinska.com

Page 2: Breaking the eggshell: From .NET to Node.js

About me

ProgrammerGeek

Sweet tooth

Page 3: Breaking the eggshell: From .NET to Node.js

Objectives

Page 4: Breaking the eggshell: From .NET to Node.js

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

Page 5: Breaking the eggshell: From .NET to Node.js

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.

Page 6: Breaking the eggshell: From .NET to Node.js

Why is it so cool?

• Platform independent• Scalable• Faster• Lightweight• Optimised

Page 7: Breaking the eggshell: From .NET to Node.js

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)

Page 8: Breaking the eggshell: From .NET to Node.js

Prototype approach support

• Easy onboard• Simple programming

model• Simple solution that

works

Page 9: Breaking the eggshell: From .NET to Node.js

A bit of an architecture…

Page 10: Breaking the eggshell: From .NET to Node.js

How to choose?

• CLR – multithreaded engine, CPU heavy operations

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

Page 11: Breaking the eggshell: From .NET to Node.js

Cross platform

Page 12: Breaking the eggshell: From .NET to Node.js

Simplicity

Page 13: Breaking the eggshell: From .NET to Node.js

Community

• .NET – well established, Patterns & Practices

• Node.js – considered simpler, just works

Page 14: Breaking the eggshell: From .NET to Node.js

But… Windows

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

• Cross-platform handling:– VM– Containers

Page 15: Breaking the eggshell: From .NET to Node.js

Node Tools for VS

Page 16: Breaking the eggshell: From .NET to Node.js

VS Code

Page 17: Breaking the eggshell: From .NET to Node.js

Installation & configuration

Page 18: Breaking the eggshell: From .NET to Node.js

Package Management

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

-> packages.json• packages ->

nodes_modules

Page 19: Breaking the eggshell: From .NET to Node.js

npm

Page 20: Breaking the eggshell: From .NET to Node.js

Development environment

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

Page 21: Breaking the eggshell: From .NET to Node.js

Running Node.js app

Page 22: Breaking the eggshell: From .NET to Node.js

Nodemon

Page 23: Breaking the eggshell: From .NET to Node.js

Task runners

• Why? -> automation

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

Page 24: Breaking the eggshell: From .NET to Node.js

Gruntfile

Page 25: Breaking the eggshell: From .NET to Node.js

Updating statuses

Page 26: Breaking the eggshell: From .NET to Node.js

How

API Web AppGET api/events

POST api/events/:username

Page 27: Breaking the eggshell: From .NET to Node.js

Creating web app

ASP.NET MVC,WebAPI Express

Razor

SignalR

Vash.js

Socket.io

Page 28: Breaking the eggshell: From .NET to Node.js

Creating express app

Page 29: Breaking the eggshell: From .NET to Node.js

Express vs. Asp.NET MVC

Page 30: Breaking the eggshell: From .NET to Node.js

Organising the code

Page 31: Breaking the eggshell: From .NET to Node.js

App.js

Page 32: Breaking the eggshell: From .NET to Node.js

Routing

Page 33: Breaking the eggshell: From .NET to Node.js

Passing model

Page 34: Breaking the eggshell: From .NET to Node.js

Jade

Page 35: Breaking the eggshell: From .NET to Node.js

Callbacks

Page 36: Breaking the eggshell: From .NET to Node.js

Async

Page 37: Breaking the eggshell: From .NET to Node.js

Async solution

Page 38: Breaking the eggshell: From .NET to Node.js

Databases

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

Page 39: Breaking the eggshell: From .NET to Node.js

Set up the connection to MySql

Page 40: Breaking the eggshell: From .NET to Node.js

Querying MySql

Page 41: Breaking the eggshell: From .NET to Node.js

Testing

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

• Mocks– Sinon– Mock– NodeMock

Page 42: Breaking the eggshell: From .NET to Node.js

Jasmine

Page 43: Breaking the eggshell: From .NET to Node.js

Mocks

Page 44: Breaking the eggshell: From .NET to Node.js

Tests in task manager

Page 45: Breaking the eggshell: From .NET to Node.js

Running tests

Page 46: Breaking the eggshell: From .NET to Node.js

Debugging – node-inspector

Page 47: Breaking the eggshell: From .NET to Node.js

node-inspector debugging

Page 48: Breaking the eggshell: From .NET to Node.js

Debugging – VS Code

Page 49: Breaking the eggshell: From .NET to Node.js

Summary

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

Page 50: Breaking the eggshell: From .NET to Node.js

Questions?Barbara [email protected]

https://github.com/BasiaFusinska/FromNet2Node