Guillermo Rodas
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.
@garethderioth
Medellin, November 27, 2015
Explains the architecture used to develop the software product, providing an overview of the entire system, identifying the main components that would be created for the product.
READ
ASK
WRITE
Your analysis will be ready when you start coding without getting up, asking or checking anything else.
If a bear eats you, your analysis works as clear code instructions for any developer.
Helps developers maintain consistent coding styles between different editors.
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
.editorconfig
Editor
https://plugins.jetbrains.com/plugin/7294
https://github.com/sindresorhus/editorconfig-sublime
https://atom.io/packages/editorconfig
plugins
A style guide is a set of standards for the writing and design of documents.
https://github.com/airbnb/javascript
Use object destructuring for multiple return values, not array destructuring.
https://github.com/airbnb/javascript/blob/master/README.md#destructuring
Why? You can add new properties over time or change the order of things without breaking call sites.
JavaScript Styleguide
// bad
function processInput(input) {
// then a miracle occurs
return [left, right, top, bottom];
}
// the caller needs to think about the order of return data
const [left, __, top] = processInput(input);
// good
function processInput(input) {
// then a miracle occurs
return { left, right, top, bottom };
}
// the caller selects only the data they need
const { left, right } = processInput(input);
JavaScript Styleguide
http://sass-guidelin.es/
Selector nesting offers a way for stylesheet authors to compute long selectors by nesting shorter selectors within each others.
http://sass-guidelin.es/#selector-nesting
Sass Styleguide
.foo {
.bar {
&:hover {
color: red;
}
}
}
// will generate this CSS:
.foo .bar:hover {
color: red;
}
Sass Styleguide
The problem with selector nesting is that it ultimately makes code more difficult to read.
Always avoid it.
.foo {
color: red;
&:hover {
color: green;
}
&::before {
content: 'pseudo-element';
}
}
Sass Styleguide
Linter is any tool that flags suspicious usage in software written in any computer language.
http://eslint.org/
Shadowing is the process by which a local variable shares the same name as a variable in its containing scope.
http://eslint.org/docs/rules/no-shadow
ESLint Linter
/*eslint no-shadow: 2*/
/*eslint-env es6*/
var a = 3;
function b() {
var a = 10;
}
error a is already declared in the upper scope.
ESLint Linter
.eslintrc
{
"extends": "airbnb"
}
https://github.com/airbnb/javascript/tree/master/linters
ESLint Linter
https://github.com/brigade/scss-lint
https://github.com/brigade/scss-lint/blob/master/lib/scss_lint/linter/README.md#importantrule
Avoid using !important in properties. It is usually indicative of a misunderstanding of CSS specificity and can lead to brittle code.
Scss Linter
//Bad
p {
color: #f00 !important;
}
//Good
p {
color: #f00;
}
Scss Linter
http://sass-guidelin.es/#scss-lint
.scss-lint.yml
# For SCSS-Lint v0.32.0
linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false
BorderZero:
enabled: true
ColorKeyword:
enabled: true
Comment:
enabled: false
DebugStatement:
enabled: true
DeclarationOrder:
enabled: true
DuplicateProperty:
enabled: false
ElsePlacement:
enabled: true
style: same_line
EmptyLineBetweenBlocks:
enabled: true
ignore_single_line_blocks: false
EmptyRule:
enabled: true
FinalNewline:
enabled: true
present: true
HexLength:
enabled: true
style: short
HexNotation:
enabled: true
style: lowercase
HexValidation:
enabled: true
IdSelector:
enabled: true
ImportPath:
enabled: true
leading_underscore: false
filename_extension: false
Indentation:
enabled: true
character: space
width: 2
LeadingZero:
enabled: true
style: include_zero
MergeableSelector:
enabled: false
force_nesting: false
NameFormat:
enabled: true
convention: hyphenated_lowercase
allow_leading_underscore: true
NestingDepth:
enabled: true
max_depth: 3
PlaceholderInExtend:
enabled: true
PropertySortOrder:
enabled: false
ignore_unspecified: false
PropertySpelling:
enabled: true
extra_properties: []
QualifyingElement:
enabled: true
allow_element_with_attribute: false
allow_element_with_class: false
allow_element_with_id: false
SelectorDepth:
enabled: true
max_depth: 3
SelectorFormat:
enabled: true
convention: hyphenated_lowercase
class_convention: '^(?:u|is|has)\-[a-z][a-zA-Z0-9]*$|^(?!u|is|has)[a-zA-Z][a-zA-Z0-9]*(?:\-[a-z][a-zA-Z0-9]*)?(?:\-\-[a-z][a-zA-Z0-9]*)?$'
Shorthand:
enabled: true
SingleLinePerProperty:
enabled: true
allow_single_line_rule_sets: false
SingleLinePerSelector:
enabled: true
SpaceAfterComma:
enabled: true
SpaceAfterPropertyColon:
enabled: true
style: one_space
SpaceAfterPropertyName:
enabled: true
SpaceBeforeBrace:
enabled: true
style: space
allow_single_line_padding: true
SpaceBetweenParens:
enabled: true
spaces: 0
StringQuotes:
enabled: true
style: single_quotes
TrailingSemicolon:
enabled: true
TrailingZero:
enabled: true
UnnecessaryMantissa:
enabled: true
UnnecessaryParentReference:
enabled: true
UrlFormat:
enabled: false
UrlQuotes:
enabled: true
VendorPrefixes:
enabled: true
identifier_list: base
include: []
exclude: []
ZeroUnit:
enabled: true
Scss Linter
Editor
plugins
https://plugins.jetbrains.com/plugin/7494
https://github.com/roadhump/SublimeLinter-eslint
https://atom.io/packages/linter-eslint
https://github.com/attenzione/SublimeLinter-scss-lint
https://plugins.jetbrains.com/plugin/7530
https://atom.io/packages/linter-scss-lint
// npm install --save-dev load-grunt-tasks
require('load-grunt-tasks')(grunt);
grunt.initConfig({
eslint: {
target: ['file.js']
},
scsslint: {
allFiles: [
'test/fixtures/*.scss',
],
options: {
bundleExec: true,
config: '.scss-lint.yml',
reporterOutput: 'scss-lint-report.xml',
colorizeOutput: true
},
}
});
grunt.registerTask('default', ['eslint', 'scsslint']);
var gulp = require('gulp'),
eslint = require('gulp-eslint'),
scsslint = require('gulp-scss-lint');
gulp.task('lint', function () {
return gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('scss-lint', function() {
return gulp.src('/scss/*.scss')
.pipe(scsslint());
});
gulp.task('default', ['lint', 'scss-lint']);
module.exports = {
module: {
loaders: [
{
test: /\.js$/,
loader: "eslint-loader",
exclude: /node_modules/
},
{
test: /\.scss$/,
loader: "scss-lint-loader"
}
]
}
}
var eslint = require('broccoli-eslint'),
scssLint = require('broccoli-scss-lint');
tree = 'app';
tree = eslint(tree, {
config: './eslint.json'
});
tree = scssLint(tree, {
config: '.config.yml'
});
module.exports = tree;
Testing is important because we want to rest over the weekend to ensure the quality of the product.
(Acceptance tests)
http://qa-matters.com/2014/12/28/layers-of-test-automation/
Manual and exploratory tests
(Integration tests)
(CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
(CD) is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time. It aims at building, testing, and releasing software faster and more frequently.
The problem shifts as you need to make hot deployments, and this may affect live users.
The good news is that there are a lot of solutions for that.
Blue-green deployment is a release technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic.
Blue/Green deployment
Security helps us to protect the data and resources contained in and controlled by our software.
https://www.owasp.org/index.php/Main_Page
https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project
https://www.youtube.com/watch?v=u81pS05W1JY
You are writing a cloud application that executes custom code on behalf of your users. You need to protect one user's data from another's, and you must ensure fair access to computing resources among your users, without imposing undue constraints on their code.
A1 - Injection
Slow sites apps lead to a bad user experience.
In order to know the location of the performance issue we need to monitor our apps.
http://newrelic.com/webinar/frontend-backend-monitoring-150827
Understanding how your backend applications perform is traditionally the center of performance monitoring efforts. Response times, errors, and transactions are all essential elements you need to measure in order to keep your digital business open.
New relic
Browser | 3.46 s |
---|---|
App server | 226 ms |
*This is just an example of data.
http://browserdiet.com
npm install -g psi
Just do it.
For everything.
Because the bears are real, and the programmers are yummy.
http://www.seguetech.com/blog/2013/09/12/why-documentation-important-developers
And copy one of this:
http://usejsdoc.org/
/**
* Represents a book.
* @constructor
* @param {string} title - The title of the book.
* @param {string} author - The author of the book.
*/
function Book(title, author) {
/* ... */
}
http://usejsdoc.org/about-getting-started.html
JSDoc
http://sassdoc.com/
http://sassdoc.com/annotations/
SassDoc
Fully styled HTML document
SassDoc
https://atom.io/packages/jsdoc
https://github.com/spadgos/sublime-jsdocs
https://www.jetbrains.com/webstorm/help/creating-jsdoc-comments.html
# Install SassDoc globally
npm install sassdoc -g
# Run SassDoc on your project
sassdoc source/
A guideline is a set of statements that says how to execute an action plan.
Initial documentation
Business rules, Application instalation, Code deployment
Styleguides
Programming, Paradigms, Workflow in each area
Advices for working
Leads names, key people, values
A Guideline should have:
In science and philosophy, a paradigm is a distinct set of concepts or thought patterns, including theories, research methods, postulates, and standards for what constitutes legitimate contributions to a field.
In software engineering, don’t repeat yourself (DRY) is a principle of software development, aimed at reducing repetition of information of all kinds, especially useful inmulti-tier architectures.
Single responsibility principle
a class should have only a single responsibility (i.e. only one potential change in the software's specification should be able to affect the specification of the class)
Open/closed principle
“software entities … should be open for extension, but closed for modification.”
"Keep it simple, stupid" design principle.
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
Software architecture refers to the high-level structures of a software system. It involves a series of decisions based on a wide range of factors, and each of these decisions can have a considerable impact on the quality, performance, maintainability, and overall success of the application.
Always asking/research about them, because they change quickly.
Git allows a team of people to work together, even using the same files.
"Baby steps" is making a lot of commits per feature in order to do easy code reviews and bug fixing.
Helps to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers' skills.
Pull request and approve
By Guillermo Rodas
Improving the development process for the FE team
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.