smell your code! @ iet-kfupm patw

Post on 25-Dec-2014

662 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

This is the presentation I gave at the IET-KFUPM Present Around The World competition (http://iet.ikfupm.com/patw2011/), for which I was the second runner-up. It is based on an earlier presentation I gave at Free Dimension, the company I work for part-time.

TRANSCRIPT

Smell your Code!

Yaser Sulaiman

1

Our road map

3

Who? What? Why? How?

4

If you can take away only 1 lesson…

5

Don’t Repeat Yourself!

6

This rule is so important…

7

I must break it!

8

Don’t Repeat Yourself!

9

Who? What? Why? How?

10

“Who are you?”

11

A scientist, not an engineer

(I probably should be doing this @ ACM, not IET)

12

13

14

15

17

19

22 logo by Yukihiro Matsumoto

“You talkin’ to me?”

23

Are you a software developer?

24

If not, do you write code?

25

If not, would you be remotely interested in writing cleaner code

and making your life easier?

26

If not, you’re free to zone out

27

“Why should I listen to you?”

28

I won’t give you the “I’m a passionate software developer” BS

29

I’ve a terminal illness

30

Make that 2 terminal illnesses

31

Perfectionism &

OCD

32

Who? What? Why? How?

34

“Code smells?! Can I smell my code?!”

35

Yes you can, but not with your nose

37

Code smells are warning signs

38

They’re surface indications of deeper problems

40

41 photo by BenChenowethWork

They’re surface indications of deeper problems

42

A code smell ⇏ a problem

43

Who? What? Why? How?

44

The bigger picture

45

Software Quality

Code Quality

Code Smells

46 not to scale

Writing HQ code should be the priority

47

HQ code = easy toread

understandchange

48

In the short term, HQ code may cost more

49

Easier to change ≈ less costly

51

In the long run, HQ code costs less

52

One path to cleaner code goes through code smells

53

Who? What? Why? How?

54

There’re many code smells

55

The following smells are just a small subset

56

They’re the ones that drives me crazy the most

57

Code Smell #1

58

DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code

59

The nastiest code smell

60

DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code DupIicated code

61

Code Smell #2

62

functions.With(just, way, too, many, parameters, and,

then, even, some, more)

63

How many is too many?

64

Steve McConnell: > 7 ± 2

65

Robert C. “Uncle Bob” Martin: > 3

66

Code Smell #3

67

Not following a coding convention/standard/style

consistently

68

69 stolen from EmacsWiki

Not following a coding convention/standard/style

consistently

70

The specifics doesn’t really matter; what matters most is consistency

71

Code Smell #4

72

// code.CommentOut();

73

Don’t get me wrong

74

When you’re experimenting, comment code to your heart's

content

75

Just remember to clean up after yourself

76

And don’t commit commented-out

code

77

“Commented-out code is an abomination.”—Uncle Bob

78 photo used with permission of Uncle Bob

Commented-out code makes Uncle Bob angry

79

It makes me angry

80

Code Smell #5

82

// This is a comment

83

redundant

Who? What? Why? How?

84

Comments should focus on

Who? What? Why? How?

85

I may have come off as an a$$

86

My code smells as bad as everyone else’s.. sometimes even worse

87

But I’m aware of my smells

88

I try my best to prevent them

89

I don’t ignore them; I deal with them

90

I smell my code

91

You should smell your code too

92

When you code, take note of your nose It should be open, not close

For an open nose leads to an open mind And that’s the best rhyme I was able to find

93

If you want to sniff more…

94

…</presentation> <questions>…

96

top related