Skip to content

Instantly share code, notes, and snippets.

View nunomazer's full-sized avatar
🎯
Coding ... allways

Ademir Mazer Jr [ Nuno ] nunomazer

🎯
Coding ... allways
View GitHub Profile
@nunomazer
nunomazer / if-else-aninhado-good.java
Created July 8, 2020 12:02
Boa prática com IF-ELSE aninhado
public boolean myFunction() {
boolean result = someObject.someMethod();
if (result) {
... some code ...
if (second-test) {
... code on true ...
return true
}
... code on false ...
@nunomazer
nunomazer / if-else-aninhado-bad.java
Created July 8, 2020 12:01
Má prática com IF ELSE aninhado
public boolean myFunction() {
boolean result = someObject.someMethod();
if (result) {
... some code ...
if (second-test) {
... code on true ...
return true
} else {
... code on false ...
@nunomazer
nunomazer / if-else-bad.java
Last active July 8, 2020 11:43
Má prática com IF-ELSE
public boolean myFunction() {
boolean result = someObject.someMethod();
if (result) {
... some code ...
return true;
} else {
... log error maybe ...
return false
}
@nunomazer
nunomazer / if-else-good.java
Last active July 8, 2020 11:43
Boa prática com IF-ELSE
public boolean myFunction() {
boolean result = someObject.someMethod();
if (result) {
... some code ...
return true;
}
... log error maybe ...
return false
@nunomazer
nunomazer / main.dart
Created March 27, 2020 21:50
Exemplo Dart herança
class Television {
void _illuminateDisplay() {
print ("Display ON");
}
void _activateIrSensor() {
print ("IR sensor ON");
}
@nunomazer
nunomazer / main.dart
Created March 27, 2020 21:42
Exemplo Dart getters e setters
class Rectangle {
num left, top, width, height;
Rectangle(this.left, this.top, this.width, this.height);
// Define two calculated properties: right and bottom.
num get right => left + width;
set right(num value) => left = value - width;
num get bottom => top + height;
set bottom(num value) => top = value - height;
@nunomazer
nunomazer / main.dart
Created March 27, 2020 20:41
Exemplo construtor em Dart
class Pessoa {
// atributos
String nome;
int idade;
// construtor
Pessoa (String nome, {int idade}) {
this.nome = nome;
this.idade = idade;
}
@nunomazer
nunomazer / main.dart
Created March 27, 2020 20:18
Exemplo de classe em Dart
class Pessoa {
// atributos
String nome;
int idade;
// métodos
void cumprimentar(String nome) {
print ("Olá " + nome + " me chamo " + this.nome );
}
}
@nunomazer
nunomazer / main.dart
Created March 25, 2020 22:05
Funções em Dart
// Função sem parâmetros
void escreverBemVindo(){
print("Seja bem-vindo!");
}
// Quando a função só tem um comando interno
// Substitui abertura e fechamento de bloco, e o comando return
void escreverTipoFuncao() => print("Função com um comando.");
// Função com passagem de parâmetros (podem ter quantos parâmetros quiser)
@nunomazer
nunomazer / main.dart
Last active November 16, 2020 19:06
Estruturas de repetição em Dart
void main(){
// Repetição de 0 a 5 (conhecemos o número inicial e final)
// FOR (INICIO; CONDIÇÃO; INCREMENTO)
for(int i = 0; i < 5; i++){
print("For " + i.toString());
}
// Repetição de 0 a 5
// INICIO; WHILE (CONDICAO){ INCREMENTO; }
// Teste condicional no início