72
Ofer Zelig @oferzelig http://fullstack.info Pearls and Must-Have Tools for the Modern Web / .NET Developer

Pearls and Must-Have Tools for the Modern Web / .NET Developer

Embed Size (px)

DESCRIPTION

We are all flooded with information: blogs, videos, millions of open source projects. In this presentation I share my insights: what are the must-know and must-have tools, frameworks and techniques you can use today (or at least know about) in order to be up-to-date.

Citation preview

Page 1: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Ofer Zelig

@oferzelig

http://fullstack.info

Pearls and Must-Have

Tools for the Modern

Web / .NET Developer

Page 2: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Quick Housekeeping• It’s just a sample - don’t expect to see everything

• It’s just MY opinion

• Aimed for .NET developers, but many things are cross platform

• Quick, condensed, presentation will be uploaded

• Those of you who read it in 2015+, please consider the fact it’s written in 6/2014

Page 3: Pearls and Must-Have Tools for the Modern Web / .NET Developer

RESPONSIVE DESIGN

Page 4: Pearls and Must-Have Tools for the Modern Web / .NET Developer

• Two approaches:

• Start wide and change flow as you get narrow

• Start narrow and change flow as you get wide

• Bootstrap 3+ : Mobile friendly (start narrow)

• More about Bootstrap later

Responsive Design

Page 5: Pearls and Must-Have Tools for the Modern Web / .NET Developer

• Don’t know how to start? It’s very easy

@media (min-width: 768px) { /* your CSS rules */ }

• There’s a good boilerplate code for all common

resolutions

• A very few gotchas:

• Handling images (proportions etc.)

• Collapsible menus require a bit of JS

• As always, you need to test multiple browsers/platforms

Responsive Design

Page 6: Pearls and Must-Have Tools for the Modern Web / .NET Developer

• Is it a new project?

Don’t hesitate – use Bootstrap

• Don’t know what Bootstrap is?

Responsive Design

Page 7: Pearls and Must-Have Tools for the Modern Web / .NET Developer
Page 8: Pearls and Must-Have Tools for the Modern Web / .NET Developer

• Now seriously. Bootstrap is:

• Premade CSS rules for full responsive design, starting

from mobile and growing to large desktops

• Styles for forms, controls & states, warning/info

messages, images & thumbnails, menus, progress bars

and a lot more

• Scripts for common functionality: modal dialogs,

button behavior, drop downs & menu effects, tooltips,

carousels…

• Bullet-proof CSS functionality (centering, clearfix,

container pulling, accessibility substitutions…

• Cross browser (IE8+) and cross platform

Responsive Design

Page 9: Pearls and Must-Have Tools for the Modern Web / .NET Developer

A shiny new site - where do I begin?

• You don’t reinvent the wheel

• Bootstrap or one of hundreds Bootstrap-based templates

• Just make sure it’s 3.2+ or you’ll regret later

• Templates today are not what they used to be

• Good links in the slideshow notes

Templates

Page 10: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Templates• Admin interfaces

Page 11: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Templates• Admin interfaces

• Dozens of admin templates to choose from

• Based on Bootstrap and contain lots of features that

either:

• Will consume lots of your time, instead of focusing on

code to deliver to the admin interface

• You’ll skip them because of lack of time or just won’t

think about them

• Just to name a few: login, action items, menu,

dashboard with KPIs, robust tables, many inner sample

pages, graphs…

• DEMO

Page 12: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Templates

• You’ll also likely to learn a lot from these templates

• I learned:

• Client-side graph libraries

• Nice overlay techniques

• Handy CSS techniques

• Useful plugins (‘loading’ behaviours, responsive images,

parallax effects and much more)

• Font substitution for common images (fontawesome.io)

Page 13: Pearls and Must-Have Tools for the Modern Web / .NET Developer

More on responsive design

• The quickest, easiest & most charming way to see

how your site looks like in different resolutions:

Viewport Resizer

• More tools in the slideshow notes

Page 14: Pearls and Must-Have Tools for the Modern Web / .NET Developer

More on responsive design

• Device emulators

• http://www.browserstack.com/ - see your site in

dozens of real devices, run automated tests (Selenium)

against them

• Less devices (9), but the most common ones and free -

https://modern.ie/en-us/screenshots

Page 15: Pearls and Must-Have Tools for the Modern Web / .NET Developer

CLIENT SIDE MVC

Page 16: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVC

Why?

• It makes your client (web pages) really smart & rich

• Server just serves main page template and control templates (i.e. pure HTML+CSS)

• You just serve your data as Json, and the client does the rest: binds it to the right HTML, detects changes in both the HTML and the model, handling calls to the server…

• Great for SPA, but not exclusively

Page 17: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVCAnd what do all these things good for?

• Your site (app) runs much faster because logic is on the client and it only goes to the server to fetch data, not to get HTML artifacts (once initially loaded)

• You truly separate your structure (HTML+CSS) from your data

• Your server focuses on what it’s good at: serving & updating data

Page 18: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVC

OK, you convinced me.

Now: which one?

• Ember

• AngularJS

• Backbone

• Knockout

Page 19: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVC

Page 20: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVC

AngularJS

Why? Because.

• Its 2-way binding is the best

• It’s maintained by Google

• It’s designed for testing right from the beginning

• It has loads of modules, plugins & directives

• Read more about its awesomeness here

Page 21: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVCAngularJS

Where do I start?

• Dan Whalin’s famous

AngularJS Fundamentals In 60-ish Minutes video

(BTW it’s specifically based on Visual Studio)

• or its complementary PDF

• The AngularJS site has a great step-by-step tutorial on

how to build a full app

Page 22: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Client Side MVCAngularJS

• Recommended books: Mastering Web Application

Development with AngularJS, ng-book

• 17 PluralSight courses, the two I’ve seen and liked are:

• AngularJS Fundamentals

• AngularJS for .NET Developers

• Last one: 10 Angular Tips by John Papa

Page 23: Pearls and Must-Have Tools for the Modern Web / .NET Developer

PERFORMANCE

Page 24: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

• Dozens of things you can do

• 99% are really easy to implement – just Google them

• No business justification not to do them

Page 25: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

Just a few samples:

• Static content compression (GZIP)

• Remove redundant host headers (also good for security)

• Server, X-Powered-By, X-AspNetMvc-Version, X-AspNet-Version

• Minify CSS+JS

• Compress images (lossless)

Page 26: Pearls and Must-Have Tools for the Modern Web / .NET Developer

PerformanceJust a few samples:

• Make image sprites

• Use a CDN, at least for common libraries

• Put your scripts at the bottom of the page

• Embed small images as Base-64 inside your CSS

• Enable proper caching, both for dynamic and static content

Page 27: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

Where do I start?

Meet your best friends:

Page 29: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

Firefox: YSlow (link)

Page 30: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

WebDevCheclist.com

Site + Chrome Extension

(DEMO)

Page 31: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Performance

Visual Studio:

Web Essentials Extension

• Minifying JS+CSS, lossless image shrinking, right click

image-to-base64, image sprites, bundling…

• Lots more beyond performance but we’ll get to that

Page 32: Pearls and Must-Have Tools for the Modern Web / .NET Developer

LEGACY BROWSER SUPPORT

Page 33: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Legacy Browser Support

IE8 ?

• If you don’t genuinely have to, DON’T BOTHER.

• Don’t use polyfills, don’t try to tweak HTML+CSS,

don’t detect features with Modernizr – nothing

• Just put a generic “You’ve got an old browser” page

• Bonus: if you want to see why I hate IE8 so much go

read my blog post.

Page 34: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Legacy Browser SupportIE 9 + IE 10?

These are June 2014 browser stats (gs.statcounter.com):

Browser Percentage

Chrome (all) 45.36%

Firefox 5+ 17.66%

IE 11 8.67%

Safari iPad 5.77%

IE 8 5.43%

IE 10 3.22%

IE 9 3.22%

Page 35: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Legacy Browser SupportHow to test IE versions side by side?

https://modern.ie/en-us/virtualization-tools

Free Virtual Machines for Windows, Mac & Linux, with preinstalled Windows OSs:

XP + IE6 Win7 + IE10

XP + IE8 Win7 + IE11

Vista + IE7 Win8 + IE10

Win7 + IE8 Win8.1 + IE11

Win7 + IE9

Page 36: Pearls and Must-Have Tools for the Modern Web / .NET Developer

FEATURE SUPPORT

Page 37: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Feature Support• Not sure if a feature you want to use is supported

across browsers?

• Modernizr

• http://caniuse.com/

• Feature support per browser per version

• http://html5please.com/

• Also includes filtering/instructions whether you need

polyfills, can fallback, support on mobile devices & more

• http://status.modern.ie/

Page 38: Pearls and Must-Have Tools for the Modern Web / .NET Developer

All Things Client Side• https://github.com/dypsilon/frontend-dev-bookmarks

• Everything you want for the client side, continuously

updated

• JS architecture guides, build tools, bootstraps &

boilerplates, image shrinkers, unused code cleanup

tools, weekly newsletters, JS frameworks, jQuery

learning / plugin authoring material, grid design

helpers, cross-platform, email design & boilerplates,

mobile platforms, typography, widgets, memory

analysis tools, video players…

Page 39: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VISUAL STUDIO TOOLING FOR

WEB DEVELOPMENT

Page 40: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VS Tooling for Web Dev

• The one ultimate extension you’ll need:

Web Essentials

• It has soooo much….

• Just a few examples:

Page 41: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VS Tooling for Web Dev• Web Essentials - CSS:

• Intellisense: fixes errors, allows you to add vendor-specific

prefixes, font-faces, style names etc., Image URL picker

• Finds unused/redundant rules, browser support cues, font

previews, in-place color editor

• Minification & Bundling

• Conversions: RGB to HEX to color name, embed image as

Base64 string, LESS compilation

Page 42: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VS Tooling for Web Dev

• Web Essentials - JavaScript:

• JSHint

• Minification & Bundling

• Intellisense

• Go to definition

• and much more

Page 43: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VS Tooling for Web Dev

• Web Essentials - HTML:

• Image preview

• Minification

• Lorem Pixel & image placeholder generator

• Regions

• Go to definition (of CSS)

• Intellisense for most HTML tags

• Extract embedded JS/CSS to file

Page 44: Pearls and Must-Have Tools for the Modern Web / .NET Developer

VS Tooling for Web Dev

• Web Essentials - More:

• TypeScript side-by-side preview

• MarkDown editor & compiler to HTML

• robots.txt intellisense

Page 45: Pearls and Must-Have Tools for the Modern Web / .NET Developer

WEB APPS TIPS

Page 46: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsTime Zones

• Users perform actions on my web app.What time should I save in the database? server time? US time? client’s time?

NONE

• All dates & times as UTC on the code / database side

• You view these dates on each client according to that client’s time zone

• When saving – vice versa

Page 47: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

Time Zones

• But it’s awkward to look at UTC times translate to my local time all the time

Just think global. Your app doesn’t live in your home country. It’s out there for global reach. Your local time is meaningless.

That is, unless you’re in your home country, all of your potential users are from the same country, your country has only 1 time zone and you don’t have any thoughts of expanding globally.

Page 48: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

HTML (template) vs Data

• Unless SEO is relevant, strive to send pure templates to

the client, and fetch all data in subsequent Ajax calls

• You can send initial data to the client together with the

page, as a JS variable

• AngularJS is perfect for that, but you don’t have to.

Page 49: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsHTML vs Data – SEO oriented sites

• Google has a spec to crawling sites that change state

in Ajax (like what AngularJS does…)

• Basically you detect that it’s a crawler and you serve a

statically rendered page

• Completely legit!

• https://prerender.io/ allows you to do that without

much of the manual plumbing (costs $ but you can

host it yourself for free)

• As of May 2014 Google’s crawler runs your JavaScript!

Page 50: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsDeployment

• Do yourself a big favor and automate your deployment:

• Build (including minifying, bundling, config transformations, post cleanups…)

• Test

• Deploy

• You should ultimately be able to do all these with one click.• There are good tools for that (like Octopus Deploy)

• You can’t because it’s time consuming?• Your app failures due to a manual error in your deploy

process will consume more time, and will hurt more.

Page 51: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsDeployment

• Make a “System Health Check” screen in your back

office

Page 52: Pearls and Must-Have Tools for the Modern Web / .NET Developer
Page 53: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

Platform Dependency

• Try not to hook yourself to one platform (e.g. Azure)

Page 54: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

ASP.NET Performance

• Dynamic/static caching of course

• Redis of course

• Async methods everywhere

• (at least in every place that goes to the database or I/O)

Page 55: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

Browser<->Server Communication

• Scenario

Page 56: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsBrowser<->Server Communication

ClientServer

1st option: short polling

Page 57: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsBrowser<->Server Communication

ClientServer

2nd option: long polling

Page 58: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App TipsBrowser<->Server Communication

ClientServer

3rd option: WebSockets

Page 59: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Web App Tips

Browser<->Server Communication

• SingalR

• Takes care of everything, makes it transparent, falls

back to Ajax when WebSockets are not available (IE8,

IE9, old iOS, Android < 4.4)

Page 60: Pearls and Must-Have Tools for the Modern Web / .NET Developer

TESTING

Page 61: Pearls and Must-Have Tools for the Modern Web / .NET Developer

TestingServer side:

• Nunit + Moq

• Selenium – Web browser automation tool

• PhantomJS – Headless WebKit

• Nice uses:

• Detect screen regression

• Web page to PDF

• Automate load speed auditing

• Detect browser features

Page 62: Pearls and Must-Have Tools for the Modern Web / .NET Developer

TestingClient side:

• Jasmine

• QUnit

• Karma Runner

Page 63: Pearls and Must-Have Tools for the Modern Web / .NET Developer

SAAS

Page 64: Pearls and Must-Have Tools for the Modern Web / .NET Developer

SAAS

• First of all – go see Sam Kroonenburg and Peter

Sbarski’s legendary “Appfail – Story of a Melbourne

.NET Startup” (here it is).

• It will open your mind to the services you can achieve

for very cheap

Page 65: Pearls and Must-Have Tools for the Modern Web / .NET Developer

SAAS

• A/B Testing (or “Split Testing”)

• Optimizely

• Want to do it yourself anyway? FairlyCertain

Page 66: Pearls and Must-Have Tools for the Modern Web / .NET Developer

NETWORK

Page 67: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Network

• Share multiple sites from your dev machine to your

peers

• hosts file? That’s old…

• http://xip.io/

• 10.0.0.1.xip.io resolves to 10.0.0.1

• mysite.10.0.0.1.xip.io resolves to 10.0.0.1

• etc

Page 68: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Network

Is the site down just for me or for everyone?

http://isup.me

Page 69: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Network

Have my DNS changes propagated around the world?

www.whatsmydns.net

Page 70: Pearls and Must-Have Tools for the Modern Web / .NET Developer

Network

Hackers’ ping / nslookup web interface

digwebinterface.com

• Authoritative / non-authoritative lookups

• Colouring

• Short / Long / Trace

Page 71: Pearls and Must-Have Tools for the Modern Web / .NET Developer

WHAT/WHO TO FOLLOW

IN THE .NET AREA

Page 72: Pearls and Must-Have Tools for the Modern Web / .NET Developer

What/Who to Follow

• Scott Hanselman – blog & podcast

• Scott Guthrie – used to be very relevant, today it’s all

about Azure

• The Morning Brew

• Dot Net Rocks podcast

• All .NET / ASP.NET / Entity Framework team blogs

• The list can of course be much longer, I think these are

the most important for .NET devs.