matheusmessora / dreams Goto Github PK
View Code? Open in Web Editor NEWthink-out-of-the-box
think-out-of-the-box
Based on The ThoughtWorks Anthology: Essays on Software
1- One level of Identation per method
public void method() {
int a = 0;
if(a > 0) {
if(a > 10) {
a++; // This is WRONG
}
}
}
2- Do not use the 'else' keyword.
When a given method provides one behavior for the if branch, and another behavior for the else branch, then it means that this particular method is not cohesive. It has got more than one responsibility, dealing with different behaviors.
public boolean method() {
int years = 35;
if(years > 21) {
return true;
} else { // This is WRONG
return false;
}
}
3- Wrap primitive types and strings
Basically, if a variable of a primitive type has behavior, consider creating a class for it.
public class Bank {
int balance; // Wrong
Balance balance; // Correct
}
4- Use only one dot per line
Based on the Law of Demeter. "Only talk to your friends"
public class Bank {
Balance balance;
public Balance getBalance(){ return balance; }
public void method() {
this.getBalance().isPositive(); // WRONG
this.isBalancePositive(); // Correct
}
...
}
5- Do not abbreviate
6- Keep your classes small
A class should have 50 statements. This excludes blank lines, comments and structure closing lines.
The code should be visible inside the text editor of your IDE.
7- Do not use classes with several instance variables
A class should have only 2 instance variables.
8- Do not use static methods
Can you simple mock a static method without frameworks?
https://dzone.com/articles/why-static-bad-and-how-avoid
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.