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

Code Smells: O que são e como eles afetam a saú...

Code Smells: O que são e como eles afetam a saúde do seu código

Jeziel Lago

July 17, 2019
Tweet

More Decks by Jeziel Lago

Other Decks in Technology

Transcript

  1. 2

  2. 3

  3. 4

  4. 6

  5. 7

  6. 8

  7. 9

  8. 10

  9. 11

  10. 12

  11. 13

  12. 14

  13. 15

  14. 16 abstract class AnimalLegs class Dog : AnimalLegs() class Chair

    : AnimalLegs() abstract class Legs class Dog : Legs() class Chair : Legs() refatorando...
  15. 17 fun configureGame(players: Int, game: Game?) { when { players

    == 0 -> { setEmptyGame() } players in 1..3 -> { if (game != null) { this.gameSize = Game.SMALL game.players.forEach { configurePlayer(it, game, Game.SMALL) } } } players in 4..10 -> { if (game != null) { this.gameSize = Game.MEDIUM game.players.forEach { configurePlayer(it, game, Game.MEDIUM) } } } else -> { if (game != null) { this.gameSize = Game.BIG game.players.forEach { configurePlayer(it, game, Game.BIG) } } } } } fun configureGame(players: Int, game: Game?) { when { players == 0 -> setEmptyGame() players in 1..3 -> configureSmallGame(game) players in 4..10 -> configureMediumGame(game) else -> configureBigGame(game) } } refatorando...
  16. 18 fun savePerson(firstName: String, lastName: String, age: Int, occupation: String,

    document: String, address: String){ ... } fun savePerson(person: Person) { ... } refatorando...
  17. 19 class Customer(private val phone: Phone, ...) { fun getPhone():

    String { return "("+ phone.areaCode + ")" + phone.prefix + "-" + phone.number } } class Customer(private val phone: Phone, ...) { fun getPhone(): String = phone.formattedPhone() } refatorando...
  18. 20 class User { fun getConfiguration() = userConfig.getConfiguration() } class

    UserConfig { fun getConfiguration() = config.getConfiguration() } class Config { fun getConfiguration() = loadConfiguration() } class User { fun getConfiguration() = loadConfiguration() } refatorando...
  19. 21 class Request(private val requestConfig: RequestConfig) { fun getHeaders() =

    requestConfig.getHeaders() fun getTimeoutLimit() = requestConfig.getTimeoutLimit() fun getBody() = requestConfig.getBody() } class Request { fun getHeaders() = {...} fun getTimeoutLimit() = {...} fun getBody() = {...} } refatorando...
  20. 22 class Message { fun notifyUser( userName: String, userDetail: UserDetail,

    message: String ) { val messageBody = "Hi, " + userName + "\n" + message + "("userDetail.streetName + "," + userDetail.streetNumber this.notificationService.sendSMS(userDetail.number, messageBody) } } class Message { fun notifyUser( userName: String, number: String, address: String, message: String ) { val messageBody = "Hi, " + userName + "\n" + message + address this.notificationService.sendSMS(number, messageBody) } refatorando...
  21. 23

  22. 26

  23. 27