24
Single Page Applications Mónica Rodrigues 26/05/2017

Iseltech17 - Single Page Applications

Embed Size (px)

Citation preview

Page 1: Iseltech17 - Single Page Applications

Single Page ApplicationsMónica Rodrigues

26/05/2017

Page 2: Iseltech17 - Single Page Applications

Who am I?

26/05/2017Single Page Applications Mónica Rodrigues

Mónica Rodrigues

Degree in Computer Science Engineer at ISEL

Software Engineer since 2010

Keywords: Web Applications, ASP.NET MVC, ASP.NET Web Api, REST, Javascript,

Angular, Best practices, Design patterns, Clean Code, SQL Server

Page 3: Iseltech17 - Single Page Applications

Contents

26/05/2017Single Page Applications Mónica Rodrigues

What is SPA?

Motivations / Considerations

Multiple Page Applications vs Single Page Applications

Frameworks Javascript / SPA Samples

What I need to begin?

Best practices / Recommendations

Page 4: Iseltech17 - Single Page Applications

First page – Long time ago

26/05/2017Single Page Applications Mónica Rodrigues

Page 5: Iseltech17 - Single Page Applications

Today

26/05/2017Single Page Applications Mónica Rodrigues

Page 6: Iseltech17 - Single Page Applications

Challenge

26/05/2017Single Page Applications Mónica Rodrigues

Users want a central place to view or take

actions on most or all content so they don’t

have to waste time navigating between pages.

Page 7: Iseltech17 - Single Page Applications

Solution

26/05/2017Single Page Applications Mónica Rodrigues

Go to a SPA

Page 8: Iseltech17 - Single Page Applications

Solution

26/05/2017Single Page Applications Mónica Rodrigues

Use modern web development techniques to build a single-page app that doesn’t need to reload itself as

the user browses through it.

SPASingle Page Application

Page 9: Iseltech17 - Single Page Applications

Motivations

26/05/2017Single Page Applications Mónica Rodrigues

ReachWeb app may be accessible on different platforms and devices

Round tripWeb app not require many round trips between client and server

Better user experience

Separation of responsibilities between client and server

Page 10: Iseltech17 - Single Page Applications

Considerations

26/05/2017Single Page Applications Mónica Rodrigues

The first time that the application loads is slow

Maintain Navigation, Deep linking and History

SEO (Search engine optimization) is complicated

Page 11: Iseltech17 - Single Page Applications

Multiple page application

26/05/2017Single Page Applications Mónica Rodrigues

Page access

Returns

rendered page

Page

rendering

Page 12: Iseltech17 - Single Page Applications

Single page application

26/05/2017Single Page Applications Mónica Rodrigues

Requests data

Returns data

DOM processing

and

manipulation

Page 13: Iseltech17 - Single Page Applications

SPA and Multiple Page Application (Mix)

26/05/2017Single Page Applications Mónica Rodrigues

Products Page

Mini SPA

Categories Page

Mini SPA

Request Data

Request Data

Response Data

Response Data

Page 14: Iseltech17 - Single Page Applications

Some Javascript Frameworks and Libraries

26/05/2017Single Page Applications Mónica Rodrigues

Page 15: Iseltech17 - Single Page Applications

SPA Samples

26/05/2017Single Page Applications Mónica Rodrigues

Page 16: Iseltech17 - Single Page Applications

What I need to begin?

26/05/2017Single Page Applications Mónica Rodrigues

Choose a framework or library

Depends, what do you want to do?

Choose a IDE and structure your folders

Think about your application, namely HTML structure and CSS

Lets start with Javascript

Don’t forget the best practices !!!!

Page 17: Iseltech17 - Single Page Applications

Recomendations

26/05/2017Single Page Applications Mónica Rodrigues

Best practices in Javascript

Join and minify CSS files and Javascript files

Use a task runner like Gulp

Learn MVVM pattern

App.js

App-users-controller.js

site.min.js

Page 18: Iseltech17 - Single Page Applications

Javascript Patterns

26/05/2017Single Page Applications Mónica Rodrigues

Functions as abstractions

Functions to build modules

Functions to avoid global variables

Page 19: Iseltech17 - Single Page Applications

Functions as abstractions

26/05/2017Single Page Applications Mónica Rodrigues

Page 20: Iseltech17 - Single Page Applications

Functions to build modules

26/05/2017Single Page Applications Mónica Rodrigues

Revealing module

pattern

Page 21: Iseltech17 - Single Page Applications

Functions to build modules

26/05/2017Single Page Applications Mónica Rodrigues

What’s the matter with previous code?

There are two global variables

worker

createWorker

There variables can be redefined in other files

Page 22: Iseltech17 - Single Page Applications

Functions to avoid global variables

26/05/2017Single Page Applications Mónica Rodrigues

Reduce to 1 global

variable

But, how can I get 0global variables?

Page 23: Iseltech17 - Single Page Applications

Functions to avoid global variables

26/05/2017Single Page Applications Mónica Rodrigues

Page 24: Iseltech17 - Single Page Applications

Thank You!

26/05/2017Single Page Applications Mónica Rodrigues

Mónica Rodrigues

Email: [email protected]

Blog: http://mrodiguesblog.azurewebsites.net/

@Monica85Rodrig

https://pt.linkedin.com/in/monicascrodrigues

https://github.com/monica85rodrigues