Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Clean Code - princípios e práticas para um co...

Clean Code - princípios e práticas para um código sustentável

Palestra sobre Clean Code - princípios e práticas para um código sustentável " apresentada no JsDay 2017 em Feira de Santana

Andrews Medina

July 17, 2017
Tweet

More Decks by Andrews Medina

Other Decks in Technology

Transcript

  1. if (x != 0 && x != 1 && x

    != 2 && x != 3 && x > 4) { doSomething(); }
  2. if (player.hasPermission("se.block.smoke")) if (block != Material.LEVER) { if (block !=

    Material.BED) { if (block != Material.BED_BLOCK) { if (block != Material.CACTUS) { if (block != Material.BRICK_STAIRS) { if (block != Material.BIRCH_WOOD_STAIRS) { if (block != Material.BREWING_STAND) { if (block != Material.CAKE) { if (block != Material.CAKE_BLOCK) { if (block != Material.CAULDRON) { if (block != Material.CHEST) { if (block != Material.CLAY) { if (block != Material.SAND) { if (block != Material.BURNING_FURNACE) { if (block != Material.COBBLESTONE_STAIRS) { if (block != Material.FENCE) { if (block != Material.FENCE_GATE) { if (block != Material.FIRE) { if (block != Material.GRAVEL) { if (block != Material.IRON_DOOR_BLOCK) { if (block != Material.IRON_FENCE) { if (block != Material.IRON_DOOR) {
  3. if (block != Material.BURNING_FURNACE) { if (block != Material.COBBLESTONE_STAIRS) {

    if (block != Material.FENCE) { if (block != Material.FENCE_GATE) { if (block != Material.FIRE) { if (block != Material.GRAVEL) { if (block != Material.IRON_DOOR_BLOCK) { if (block != Material.IRON_FENCE) { if (block != Material.IRON_DOOR) { if (block != Material.LADDER) { if (block != Material.MELON) { if (block != Material.LEAVES) { if (block != Material.LOCKED_CHEST) { if (block != Material.SANDSTONE_STAIRS) { if (block != Material.SMOOTH_STAIRS) { if (block != Material.SPRUCE_WOOD_STAIRS) { if (block != Material.TNT) { if (block != Material.WOOD_DOUBLE_STEP) { if (block != Material.WOOD_DOOR) { if (block != Material.WEB) { if (block != Material.ICE) { if (block != Material.SNOW_BLOCK) { if (block != Material.SNOW) { if (block != Material.WATER_LILY) { if (block != Material.TORCH) {
  4. if (block != Material.RAILS) { if (block != Material.POWERED_RAIL) {

    if (block != Material.DETECTOR_RAIL) { if (block != Material.DEAD_BUSH) { if (block != Material.GRASS) { if (block != Material.NETHER_BRICK_STAIRS) { if (block != Material.NETHER_FENCE) { if (block != Material.NETHER_WARTS) { if (block != Material.HUGE_MUSHROOM_1) { if (block != Material.HUGE_MUSHROOM_2) { if (block != Material.BROWN_MUSHROOM) { if (block != Material.GLASS) { if (block != Material.JUNGLE_WOOD_STAIRS) { if (block != Material.WATER) { if (block != Material.SUGAR_CANE_BLOCK) { if (block != Material.WOOD_DOUBLE_STEP) { if (block != Material.WALL_SIGN) { if (block != Material.WOOD_PLATE) { if (block != Material.STONE_PLATE) { if (block != Material.STONE_BUTTON) { if (block != Material.WOOD_STAIRS) { if (block != Material.TRAP_DOOR) { if (block != Material.TRIPWIRE) { if (block != Material.TRIPWIRE_HOOK) { if (block != Material.WOOD_STEP) { if (block != Material.THIN_GLASS) { if (block != Material.REDSTONE_TORCH_OFF) { if (block != Material.REDSTONE_TORCH_ON) { if (block != Material.SAPLING) { String s = new SerializableLocation(loc).unpack().toString(); this.plugin.Blindeness.add(s); this.plugin.Blindeness.save(); if (this.String1 == this.plugin.getConfig().getString("_Block_Blindeness")) { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] You Created a" + ChatColor.DARK_RED + " BlindenessEffectBlock" + ChatColor.DARK_GREEN + " at " + ChatColor.RED + s); } else { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] You Created a" + ChatColor.DARK_RED + " BlindenessEffectBlock" + ChatColor.DARK_GREEN + " at " + ChatColor.RED + s); } } else { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else
  5. if (block != Material.RAILS) { if (block != Material.POWERED_RAIL) {

    if (block != Material.DETECTOR_RAIL) { if (block != Material.DEAD_BUSH) { if (block != Material.GRASS) { if (block != Material.NETHER_BRICK_STAIRS) { if (block != Material.NETHER_FENCE) { if (block != Material.NETHER_WARTS) { if (block != Material.HUGE_MUSHROOM_1) { if (block != Material.HUGE_MUSHROOM_2) { if (block != Material.BROWN_MUSHROOM) { if (block != Material.GLASS) { if (block != Material.JUNGLE_WOOD_STAIRS) { if (block != Material.WATER) { if (block != Material.SUGAR_CANE_BLOCK) { if (block != Material.WOOD_DOUBLE_STEP) { if (block != Material.WALL_SIGN) { if (block != Material.WOOD_PLATE) { if (block != Material.STONE_PLATE) { if (block != Material.STONE_BUTTON) { if (block != Material.WOOD_STAIRS) { if (block != Material.TRAP_DOOR) { if (block != Material.TRIPWIRE) { if (block != Material.TRIPWIRE_HOOK) { if (block != Material.WOOD_STEP) { if (block != Material.THIN_GLASS) { if (block != Material.REDSTONE_TORCH_OFF) { if (block != Material.REDSTONE_TORCH_ON) { if (block != Material.SAPLING) { String s = new SerializableLocation(loc).unpack().toString(); this.plugin.Blindeness.add(s); this.plugin.Blindeness.save(); if (this.String1 == this.plugin.getConfig().getString("_Block_Blindeness")) { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] You Created a" + ChatColor.DARK_RED + " BlindenessEffectBlock" + ChatColor.DARK_GREEN + " at " + ChatColor.RED + s); } else { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] You Created a" + ChatColor.DARK_RED + " BlindenessEffectBlock" + ChatColor.DARK_GREEN + " at " + ChatColor.RED + s); } } else { player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else player.sendMessage(ChatColor.DARK_GREEN + "[SpecialEffects] Can't" + ChatColor.DARK_RED + " create a EffectBlock" + ChatColor.DARK_GREEN + " Using this material"); } else
  6. class UserSettings { constructor(user) { this.user = user; } changeSettings(settings)

    { if (this.verifyCredentials()) { … } } verifyCredentials() { … } }
  7. class UserFriends { constructor(user) { this.user = user; } addFriends(friend)

    { if (this.verifyCredentials()) { … } } verifyCredentials() { … } }
  8. class UserAuth { constructor(user) { this.user = user; } verifyCredentials()

    { … } } class UserSettings { constructor(user) { this.user = user; this.auth = new UserAuth(user); } changeSettings(settings) { if (this.auth.verifyCredentials()) { … } } }
  9. func testeSplitHostAndPort() { let url = “jusbrasil.com.br:3333”; let {host, port}

    = splitHostAndPort(url); expect(host).toBe(“jusbrasil.com.br”); expect(port).toBe(3333); }
  10. TDD