Planning An Angular Web Application
Planning An Angular Web Application
Application
By Todd Motto
WHITEPAPER
Table of Contents
Project Management / 3
Testing Methodologies / 11
Backend API / 18
Performance Strategies / 19
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 2
Planning an Angular (version 2 and above)
application is something you may have already
done, or will be soon attempting. This whitepaper
documents a high-level outline of things to
consider when planning an Angular application,
from tooling choices during development all the
way through to deployment and performance
strategies. There’s certainly a lot more to it than
meets the initial eye.
Project Management
Before you get started, you need to consider
how you’re going to get the ball rolling - and
keep it rolling. This usually starts with project
management and discussing and agreeing upon
particular toolchains to accomplish your next
application.
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 3
Software Management Tools
To manage the development of the front-end
application, you’ll minimally need to select the Software management tools Examples
Progress / KendoUI 4
Accessibility, i18n and Environments
Accessibility, i18n (internationalisation) and building for the correct environments are an essential part of any application. It’s not just deciding what to build, but
how you’re going to build and support it. Addressing these considerations at the beginning of a project will enable you to clearly vision how you’ll implement
the said features, such as accessibility concerns and i18n for example.
https://developers.google.com/web/fundamentals/getting-started/primers/
Offline-first
service-workers
Above are some examples for consideration when deciding baseline standards and types of support your application can offer. These details may
differ per project, for things such as i18n and offline strategies, it comes down to the goals of your project.
Progress / KendoUI 5
Development Process
Methodology
Typically there are a few different approaches
to development, such as Agile, Waterfall, Scrum,
Kanban and likely many more adaptations.
Tooling and
Development
Tooling has been increasingly important when
developing any kind of application for the web
or other platforms. With Angular, there are a
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 6
Package Managers
Package managers allow you to grab
dependencies from an external host, for example
using npm to fetch your dependencies for
development and also any dependencies that
will make it into production.
Progress / KendoUI 7
Task Runners
Task runners will allow you to configure
particular tasks depending on what you’re
aiming to achieve. Managing third party code
and their dependencies should not be a manual
task performed by a human, it’s not productive.
Progress / KendoUI 8
Linters and Enforcement Angular CLI
When working on a team, the goal should be The Angular CLI will allow you to do most of
that each file is written as if it were coded from the above, all in a single environment. Using the
a single developer’s mind in regards to error CLI will allow you to create new components,
prevention, formatting, and style. Three main directives, services and more via commands in
types of tools (i.e. code linters/hinters, code style your terminal. You can also serve the app, run
checker, and a code editor config file) aid this local servers, build and compress styles (Sass)
process and should be properly implemented and compile the application for best possible
and configured before coding begins. performance. I’d highly recommend checking it
out and building applications with it.
Tools Examples
Progress / KendoUI 9
UI Components
Building web applications means that you which is built on Angular, not wrapped with
are likely going to require some additional UI it. If the underlying components are not built
components beyond what the browser itself has specifically for Angular, you will lose much of the
to offer. Textboxes, labels and dropdown lists will advantages that Angular offers, such as Ahead
only get you so far. of Time Compilation, tree shaking, server-side
rendering and more.
When it comes to UI components, there are
a lot of great options. You can choose either
commercial or open-source components. The
important thing is to pick a component library
Tools Examples
Progress / KendoUI 10
Testing Methodologies
How you test and what you test is less important than the fact that you test something. It’s likely the case that you’ll want to test each module or unit of
code by writing unit tests. When all of the units of code unite to form a running application, you’ll want to do functional end-to-end testing. Below I detail
the tools required (tasking tool facilitate all this) to do cross-browser unit and functional testing.
Tools Purpose
The Jasmine test framework. provides everything needed to write basic tests. It ships with an HTML test
Jasmine
runner that executes tests in the browser.
The Angular testing utilities create a test environment for the Angular application code under test. Use them to
Angular Testing Utilities
condition and control parts of the application as they interact within the Angular environment.
The karma test runner is ideal for writing and running unit tests while developing the application. It can be an
Karma integral part of the project’s development and continuous integration processes. This chapter describes how
to setup and run tests with karma.
Use protractor to write and run end-to-end (e2e) tests. End-to-end tests explore the application as users
Protractor experience it. In e2e testing, one process runs the real application and a second process runs protractor tests
that simulate user behavior and assert that the application responds in the browser as expected.
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 11
Codebase Distribution
Strategies
Gone are the days where we can just build an For your application, you need to consider Server-side rendering
application purely for the browser environment. the initial environments you’ll be deploying to,
We’re at the stage where, without necessarily as well as any future considerations - such as Server-side rendering has a huge performance
knowing it, we’re writing code in a format that NativeScript for native mobile applications (it’ll and SEO benefit to loading an Angular application
can run pretty much nearly anywhere. Under compile your Angular code for you, reusing directly in the browser. Because the Angular
the hood, language parsers such as Babel 90%+ on average of your existing codebase). rendering core is split from the framework itself, we
or TypeScript convert our code into an AST can essentially render a view on the server. Once
(Abstract Syntax Tree). An AST is a chain of the server has rendered the initial payloads, the
commands that describe our code, at a higher Browser only client-side part of Angular can pick up where the
level. This means that we’re not limited to the server left off, hydrating it with JavaScript once
original language it was written in. People can If your application will only run in a browser, then Angular is ready. For this, you’ll need
then (and already have for most cases) write your strategy will be fairly simple. You’ll be able Angular Universal.
programs that interpret these ASTs and spit to deploy to a single environment and the code
them out in whatever language is needed. will run in the browser like any other web app
that’s “browser only”.
Via an AST, things like NativeScript exist
to transform that AST into native code on
mobile for impeccable performance and native
© 2017 Progress. All Rights Reserved.
experience.
Progress / KendoUI 12
Mobile and Desktop
Let’s talk about mobile and desktop. Here are some considerations when
thinking about using your Angular codebase on non-browser platforms.
Tools Purpose
Open source framework for building truly native mobile apps with
NativeScript
Angular, TypeScript or JavaScript.
Progress / KendoUI 13
Progressive Web Apps (PWA)
Progressive Web Apps use modern web • Discoverable - Are identifiable as
capabilities to deliver an app-like user “applications” thanks to W3C manifests and
experience. They evolve from pages in browser service worker registration scope allowing
tabs to immersive, top-level apps, maintaining search engines to find them.
the web’s low friction at every moment. Here’s • Re-engageable - Make re-engagement easy
some further information as to characteristics of through features like push notifications.
PWAs: • Installable - Allow users to “keep” apps
they find most useful on their home screen
• Progressive - Work for every user, regardless without the hassle of an app store.
of browser choice because they’re built with • Linkable - Easily share via URL and not
progressive enhancement as a core tenant . require complex installation.
• Responsive - Fit any form factor, desktop,
mobile, tablet, or whatever is next. Angular makes these much more easy to
• Connectivity independent - Enhanced with integrate, and I’d encourage you to check out
service workers to work offline or on low Angular Mobile Toolkit.
quality networks.
• App-like - Use the app shell model Or check out this four-part blog series explaining
to provide app-style navigation and the basics, intricacies and importance of PWAs.
1
interactions.
• Fresh - Always up-to-date thanks to the
service worker update process.
• Safe - Served via Transport Level Security to
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 14
Define deployment strategy JavaScript error monitoring
You need a plan to get your local code to staging A JavaScript error monitoring tool needs to be
and production (i.e. deploy local code to public selected to capture run-time errors occurring
servers). After all, not everyone can always see in staging and production code. Typically, this
your locally running application, even if you use monitoring tool is not used on development
some magic to make it happen. A continuous code. Pick one, use it.
integration server is an ideal solution for crafting
deployments regardless of whether you intend This step is probably the most commonly
to deploy to production on every code push. skipped step in building JavaScript applications.
Don’t overlook capturing runtime errors.
Let me step back for a moment from CI concepts
and talk about local development. Ideally,
anything you do during CI, you should be able to
do locally. That means, building and testing your
application should be crafted first to run locally.
In fact, I will often run a second server locally
that serves staging code on my local machine
(i.e. what gets outputted during CI process). It’s
this local testing and build process that becomes
automated once you set up your CI integration.
I’ve loosely mapped out below what this might
look like.
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 15
Style Guide, Architecture and
State Management
Defining a style for your team and project
is essential, as is deciding what architectural
practices you’ll be using.
Progress / KendoUI 16
State management
State management comes easy to Angular with
uni-directional dataflow, however using a Redux
approach to Angular development is something
to highly consider.
Tools Purpose
Progress / KendoUI 17
Backend API
The first step assumes API-first development, then be ready to evolve it as you build out the
which is an excellent method that I highly applications that use it.
recommended.
It’s worth noting that it may be assumed that
In a nutshell, API-first development means that security and authentication details will accompany
you document, build, and test your API first. the API. It is also assumed that the API developers
This means you have a relatively stable API will provide a development API to be used for
before you write any application code. Note that development. Using the same data API for both
during API construction, front-end developers development and production should never be an
should be prototyping minimal viable features option.
using the API and providing feedback to the API
engineers.
Progress / KendoUI 18
Performance Strategies
It’s worth investigating how to get the most out small payloads that, combined with module lazy-
of your Angular application before you’ve even loading, can significantly improve performance.
set foot in the codebase. Let’s investigate some
approaches. If you don’t AoT compile, you’ll ship the compiler
to the browser, which means the codebase is
heavier, thus by default you adopt a “Just-in-
Ahead-of-Time compiling Time” compilation strategy. The AoT approach
is also similar to React’s story with JSX - it’s all
Around half of Angular’s codebase makes up the preprocessing.
internal compiler, which you can absolutely strip
out with offline compilation called Ahead-of- Read more about AoT.
Time compiling. This can help you achieve very
</>
© 2017 Progress. All Rights Reserved.
</>
Progress / KendoUI 19
Bundling Lazy-loading
Bundling code allows us to eliminate dead code The Angular router allows lazy-loading of
and minify our build before we deploy, as well feature modules, which essentially will allow you
as minimising payload overheads when the to request large module chunks on-demand
browser requests the initial JavaScript file. This rather than include it any initial payloads. It can
also includes code mangling to rename variables, be removed before deployment and requested
functions and properties to get the minimum before accessing a particular route that a user
payload size possible. may not have visited yet.
Tree-shaking
Tree-shaking allows us to remove unused imports
from our codebase, thus (potentially) reducing the
bundle drastically in size. The Angular team have
put together a guide on tree-shaking that walks
you through itusing Rollup.js. Webpack supports
tree-shaking for ES2015 modules as well.
© 2017 Progress. All Rights Reserved.
Progress / KendoUI 20
Brought to You by Progress Kendo UI
We’re engineering true Angular UI components, not just wrapping About the Author
existing components like other vendors. We’re dedicated to delivering Todd is a front end engineer from
pure, high-performance Angular UI components without any jQuery England, UK. Runs Ultimate Angular, Founder of
dependencies because we won’t settle for anything less and we don’t Voux, Developer Expert at Google, conference
think you should either. The Components page contains the most up-to- speaker and open source evangelist.
date list of included UI components.
software vendors, 80,000 enterprise customers, and 2 million developers rely on Progress to
power their applications. Learn about Progress at www.progress.com or +1-800-477-6473.
Progress and Kendo UI are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the
U.S. and/or other countries. Any other trademarks contained herein are the property of their respective owners.
© 2018 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.
Rev 18/10 | 171002-0040 / RITM0029821