Programming != Writing Code

28
1 PROGRAMMING =! WRITING CODE

Transcript of Programming != Writing Code

Page 1: Programming != Writing Code

1

P R O G R A M M I N G = !

W R I T I N G C O D E

Page 2: Programming != Writing Code

• A L L S L I D E S A R E I N E N G L I S H • T Y P O S M AY O C C U R

Y O U D O N ’ T K N O W E N G L I S H ?

2

Page 3: Programming != Writing Code

3

Page 4: Programming != Writing Code

• S O F T W A R E E N G I N E E R

• W E B A N D M O B I L E • R U B Y / P H P /

O B J E C T I V E C / S W I F T

• 1 1 Y E A R S O F E X P E R I E N C E

• Q U I M B I K , I N C / U S A

G U S TA V O C U N H A

4

Page 5: Programming != Writing Code

•I N F R A S T R U C T U R E ?•S U P P O R T ?

•W O R K S ?

•P R O G R A M M I N G ?

5

Page 6: Programming != Writing Code

P R O C E S S W R I T I N G T E S T I N G

M A I N T E N A N I N G [ W I K I P E D I A ]

D E F I N E : P R O G R A M ?

6

Page 7: Programming != Writing Code

• ~ 300 Programming Languages - Wikipedia

• Learn all of them? NO!

• Make mistakes is common and acceptable

• Which language should I learn?

Does the language really matters?!?!?!?!

F* NO!!!!!!7

Page 8: Programming != Writing Code

P R O G R A M M I N G I S E A S Y

8

I D O T H I S O N A D A I LY B A S I S

I N E V E R M A K E M I S TA K E S !

R E A L LY ?

Page 9: Programming != Writing Code

H T T P : / / I . I M G U R . C O M / B T J Z E D W. J P G9

Page 10: Programming != Writing Code

10H T T P : / / I . I M G U R . C O M / L Z B I E . J P G

Page 11: Programming != Writing Code

11 H T T P : / / PA S T E B I N . C O M / P T R Y 5 G 2 A

Construtor

+ 40 parâmetros

Page 12: Programming != Writing Code

PA S T I E . O R G / PA S T E S / 8 2 7 2 3 8 6

H T T P S : / / G I S T. G I T H U B . C O M /A N O N Y M O U S /

A A 4 6 E 8 D B 0 9 8 D C B D 3 B 4 2 8

12

Page 13: Programming != Writing Code

13

C O D E S M E L L

Page 14: Programming != Writing Code

14

Page 15: Programming != Writing Code

C O D E S M E L L

( … ) I S A S U R FA C E I N D I C A T I O N T H A T U S U A L LY

C O R R E S P O N D S T O A D E E P E R P R O B L E M I N T H E

S Y S T E M ( … ) K E N T B E C K

15

Page 16: Programming != Writing Code

C O D E S M E L L• Duplicate Code

• Long Method

• Large Class

• Long Parameter List

• + 10 more symptoms

16

Page 17: Programming != Writing Code

D U P L I C AT E C O D EC O D E S M E L L

17

Most common problem

Solution • Same class, different methods

• Extract code to new method • Different classes

• Sibling classes • Move code to parent class • If code is similar, but not equal, break into methods that has

same code and methods with different information • Unrelated classes

• Check design

Page 18: Programming != Writing Code

L O N G M E T H O DC O D E S M E L L

18

Hard to understand, easy to solve

Solution • Break the methods into smaller methods (subroutines) • Big method will become a method caller • Easier to maintain

Problems • Hard to read • Usually loses it’s main purpose

Page 19: Programming != Writing Code

L A R G E C L A S SC O D E S M E L L

19

Also known as Ninja Class

Solution • Break the attributes into components (like address)

• Usually, attributes with same prefix/suffix is likely to become a component

• Reduces duplicate code

Problems • Loses it’s purpose • Does more then one thing • Duplicate code (often) • Has many object-cadidates inside it

Page 20: Programming != Writing Code

L O N G PA R A M E T E R L I S TC O D E S M E L L

20

Change one of them and you will be in trouble

Solution • Remove any parameters that can be retrieved from objects already

sent

Problems • On Procedural Programming, you had to send every detail a function

needed • On Object Oriented Programming, you can send enough to get what

the method needs

Page 21: Programming != Writing Code

H T T P : / / W W W. A M A Z O N . C O M / G P / P R O D U C T / 0 2 0 1 4 8 5 6 7 2

21

F O R F U R T H E R I N F O R M AT I O N

Page 22: Programming != Writing Code

I N R U B Y…Gems • flog - Flog shows you the most torturous code you wrote. The

more painful the code, the higher the score. • flay - Flay analyzes ruby code for structural similarities.

Differences in literal values, names, whitespace, and programming style are all ignored.

• reek - is a tool that examines Ruby classes, modules and methods

and reports any Code Smells it finds • brakeman - is a static analysis tool which checks Ruby on Rails

applications for security vulnerabilities.

22

Page 23: Programming != Writing Code

H T T P : / / W W W. S L I D E S H A R E . N E T / M A R T I N T S C H / R E FA C T O R I N G - C O D E - S M E L L

23

Page 24: Programming != Writing Code

T W O M O R E T H I N G S …T W O M O R E T H I N G S …

24

Page 25: Programming != Writing Code

25

18 de abril Colégio Contato

alagoasdevday.com.br

Page 26: Programming != Writing Code

26

Page 27: Programming != Writing Code

Q U E S T I O N S ?

27

Page 28: Programming != Writing Code

T H A N K Y O U !

28

Gustavo Cunha gmmcal.com.br

[twitter|github|facebook].com/gmmcal +GustavoCunha