SlideShare a Scribd company logo
Angular Coding Standards.
The purpose of the Angular coding standards document istocreate abaseline for collaboration andreview within various aspects of the HTML project
andthis document will helpdevelopers tounderstand how he/she canwrite better code, sothat other developers canbetter understand it.
Do’s
Rework the defaultdirectory structure:
It’s helpful toknow that you canrestructure Angular’s default
directories. The default directories you’re given will depend on the
type ofsoftware you’re writing.
Keep presentation logic out of controllers:
InanMVC architecture, every module isseparated intoeither the
model, viewor controller. The view iswhere your presentation logic is
coded. The presentation isanything todowith the DOM. Ifyou need
tochange avalue inanyHTML element, youshould only usethe
presentation layer todoit.
.
Use dependency injection:
Dependency injection isawaytodecouple parts ofyour application
from the mainlogic.
Use angularjs-specific testing tools:
There are options when it comes totesting, but be sure tochoose
carefully. Chrome comes with itsown developer tools, and many
developers useFirefox plugins totestJavaScript code. But AngularJS is
ahighly modified formof JavaScript. Because Google developed
AngularJS, the most common (andprobably the safest) tool touse is
the Chrome extension ng-inspector.
Keep controllers simple:
Controllers are meant todefine your scope variables and encapsulate
view relatedlogic. Please don’t use controllers for DOM interactions
or data manipulation.
Business logic belongs to models:
Data processing should always be kept inmodels, that way they can
easilybe shared between controllers andother services. Plus it'seasier
towrite unit test for them.
Use codelyzer tool:
Codelyzer helps us suggest the best practices during writing angular
code.
Use lazy load:
Uselazyloading onsubcomponents andwhere ever possible.
Use AoT:
Usageof AoT (aheadof time)compilation isagreat steptowards
performance gains atruntime. Italsoreduces your bundle byabout
30kb (gzipped) which isaLOT of improvement. Angular 4.0+ brings
about 30% improvement inappbundles due tohow itgenerates the
AoT code.
Keep Components Focused:
Reusing components withseveral views isbrittle andgoodend-to-
end(e2e) test coverage isrequired toensure stability across large
applications.
Small Functions:
Small functions helpavoid hidden bugs that come withlarge functions
that share variables with external scope, create unwanted closures, or
unwanted coupling with dependencies
Defer Logic to Services:
Logic maybe reused bymultiple components when placedwithin a
service andexposed via afunction.
File Naming Guidelines:
Namingconventions helpprovide aconsistent way tofindcontent at
aglance. Consistency within the project isvital.
Modularity:
Modular applications makeit easytoplug andgoasthey allow the
development teamstobuild vertical slices ofthe applications androll
out incrementally. This meanswe can plug innew features aswe
develop them.
Don’ts
● Avoid NamingCollisions.
● Don’t import the full package.
● Don’t dependmuchonjQuery plugin

More Related Content

PPTX
jQuery vs AJAX Control Toolkit
PDF
Introduction to CodeRush Xpress
PPT
How ASP.NET MVC Implementation Help Enterprise Web Application Development?
PPTX
Technoligent providing custom ASP.NET MVC development services
DOCX
Built for engineers and developers
PDF
What’s new in angular 12[highlights of angular 12 features]
PDF
Testing AngularJS Applications at payworks
PPTX
Asp.net c# mvc Training-Day-5 of Day-9
jQuery vs AJAX Control Toolkit
Introduction to CodeRush Xpress
How ASP.NET MVC Implementation Help Enterprise Web Application Development?
Technoligent providing custom ASP.NET MVC development services
Built for engineers and developers
What’s new in angular 12[highlights of angular 12 features]
Testing AngularJS Applications at payworks
Asp.net c# mvc Training-Day-5 of Day-9

What's hot (7)

PDF
Facial Analysis with Angular Web App & ASP.NET Core
PDF
Automation Software Testing with Selenium & Python
PDF
apidays LIVE Paris - GraphQL: the AppSec perspective by Vladimir de Turckheim
PDF
Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...
PPTX
Top 5 Javascript Frameworks for Web and Mobile App Development
PPTX
Presentatie EPLAN
PDF
Openflexo's infrastructure - exhibitor - @models2012
Facial Analysis with Angular Web App & ASP.NET Core
Automation Software Testing with Selenium & Python
apidays LIVE Paris - GraphQL: the AppSec perspective by Vladimir de Turckheim
Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...
Top 5 Javascript Frameworks for Web and Mobile App Development
Presentatie EPLAN
Openflexo's infrastructure - exhibitor - @models2012
Ad

Similar to Angular best practices (20)

PDF
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
PDF
AngularJS in practice
PDF
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
PDF
Real World AngularJS recipes: beyond TodoMVC
PDF
AngularJS A comprehensive beginner s guide to angular js 3nd Edition Rufus St...
PPTX
Coding standards
PPTX
Dive into Angular, part 2: Architecture
PPTX
Angular Presentation
PDF
Building scalable applications with angular js
PPTX
Building modular enterprise scale angular js applications
PDF
Tips from angular js users anonymous
PDF
Angular.JS: Do it right
PDF
Angular Architecture Best Practices.pdf
PPTX
Angular Best Practices To Build Clean and Performant Web Applications
PDF
AngularJS Best Practices
PDF
Angular js notes for professionals
PPTX
Advanced AngularJS Tips and Tricks
PDF
AngularJS Curriculum-Zeolearn
PDF
Angularjs
PDF
Top 7 Angular Best Practices to Organize Your Angular App
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
AngularJS in practice
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC
AngularJS A comprehensive beginner s guide to angular js 3nd Edition Rufus St...
Coding standards
Dive into Angular, part 2: Architecture
Angular Presentation
Building scalable applications with angular js
Building modular enterprise scale angular js applications
Tips from angular js users anonymous
Angular.JS: Do it right
Angular Architecture Best Practices.pdf
Angular Best Practices To Build Clean and Performant Web Applications
AngularJS Best Practices
Angular js notes for professionals
Advanced AngularJS Tips and Tricks
AngularJS Curriculum-Zeolearn
Angularjs
Top 7 Angular Best Practices to Organize Your Angular App
Ad

More from Allanki Srinivas (6)

DOCX
Static site best practices
DOCX
Wordpress best practices
DOCX
Ionic best practices
DOCX
Ionic best practices
PPTX
Web accessibility
PPT
Melukolupu
Static site best practices
Wordpress best practices
Ionic best practices
Ionic best practices
Web accessibility
Melukolupu

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Transform Your Business with a Software ERP System
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administration Chapter 2
PPTX
Introduction to Artificial Intelligence
PDF
System and Network Administraation Chapter 3
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Essential Infomation Tech presentation.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 2 - PM Management and IT Context
Operating system designcfffgfgggggggvggggggggg
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Transform Your Business with a Software ERP System
How Creative Agencies Leverage Project Management Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo POS Development Services by CandidRoot Solutions
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administration Chapter 2
Introduction to Artificial Intelligence
System and Network Administraation Chapter 3
Softaken Excel to vCard Converter Software.pdf
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Navsoft: AI-Powered Business Solutions & Custom Software Development
Essential Infomation Tech presentation.pptx

Angular best practices

  • 1. Angular Coding Standards. The purpose of the Angular coding standards document istocreate abaseline for collaboration andreview within various aspects of the HTML project andthis document will helpdevelopers tounderstand how he/she canwrite better code, sothat other developers canbetter understand it. Do’s Rework the defaultdirectory structure: It’s helpful toknow that you canrestructure Angular’s default directories. The default directories you’re given will depend on the type ofsoftware you’re writing. Keep presentation logic out of controllers: InanMVC architecture, every module isseparated intoeither the model, viewor controller. The view iswhere your presentation logic is coded. The presentation isanything todowith the DOM. Ifyou need tochange avalue inanyHTML element, youshould only usethe presentation layer todoit. . Use dependency injection: Dependency injection isawaytodecouple parts ofyour application from the mainlogic. Use angularjs-specific testing tools: There are options when it comes totesting, but be sure tochoose carefully. Chrome comes with itsown developer tools, and many developers useFirefox plugins totestJavaScript code. But AngularJS is ahighly modified formof JavaScript. Because Google developed AngularJS, the most common (andprobably the safest) tool touse is the Chrome extension ng-inspector. Keep controllers simple: Controllers are meant todefine your scope variables and encapsulate view relatedlogic. Please don’t use controllers for DOM interactions or data manipulation. Business logic belongs to models: Data processing should always be kept inmodels, that way they can easilybe shared between controllers andother services. Plus it'seasier towrite unit test for them. Use codelyzer tool: Codelyzer helps us suggest the best practices during writing angular code. Use lazy load: Uselazyloading onsubcomponents andwhere ever possible. Use AoT: Usageof AoT (aheadof time)compilation isagreat steptowards performance gains atruntime. Italsoreduces your bundle byabout 30kb (gzipped) which isaLOT of improvement. Angular 4.0+ brings about 30% improvement inappbundles due tohow itgenerates the AoT code. Keep Components Focused: Reusing components withseveral views isbrittle andgoodend-to- end(e2e) test coverage isrequired toensure stability across large applications. Small Functions: Small functions helpavoid hidden bugs that come withlarge functions that share variables with external scope, create unwanted closures, or unwanted coupling with dependencies Defer Logic to Services: Logic maybe reused bymultiple components when placedwithin a service andexposed via afunction. File Naming Guidelines: Namingconventions helpprovide aconsistent way tofindcontent at aglance. Consistency within the project isvital. Modularity: Modular applications makeit easytoplug andgoasthey allow the development teamstobuild vertical slices ofthe applications androll out incrementally. This meanswe can plug innew features aswe develop them. Don’ts ● Avoid NamingCollisions. ● Don’t import the full package. ● Don’t dependmuchonjQuery plugin