- In the world of open-source development where most of the code is shared, code clarity and readability is important.
- Object-oriented code architecture allows for much higher clarity and readability than procedural one, especially in complex code.
- Clean and eloquent code is easier to review and independently reviewed code is more reliable and secure.
- Code clarity largely influences the code's reusability for other purposes and by other people.
- Consistency in a coding standard allows for cleaner and more comprehensible documentation.
- Although it requires some tedious work, the usage of semantic checks on a massive scale pays off with more reliable code.
- Adapting some of the familiar conventions that are used for method naming, parameter ordering, and method behavior from othe languages is better than making up new ones.
- Unvarying return types with a fixed type for every method is better than varying return types when a value of one type can be mistaken for a value of another type.
- Underscores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
init: function(elevators, floors) { | |
var waiting = []; | |
elevators.forEach(function (elevator) { | |
elevator.on("idle", function() { | |
var i = waiting.length; | |
while (i-- > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package j2p; | |
import japa.parser.JavaParser; | |
import japa.parser.ParseException; | |
import japa.parser.ast.CompilationUnit; | |
import japa.parser.ast.ImportDeclaration; | |
import japa.parser.ast.PackageDeclaration; | |
import japa.parser.ast.body.BodyDeclaration; | |
import japa.parser.ast.body.ClassOrInterfaceDeclaration; | |
import japa.parser.ast.body.FieldDeclaration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class Java { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
while (s.hasNextInt()) { // <-- blocking read | |
int i = s.nextInt(); |
NewerOlder