More Related Content Similar to Smell your Code! @ Free Dimension (20) Smell your Code! @ Free Dimension2. These slides are based on an
internal presentation I gave
@ Free Dimension (FD)
www.free-dimension.com 2
4. FD agreed to publish it online under
a CC BY-NC-SA license…
www.free-dimension.com 4
8. What? Why? How?
www.free-dimension.com 8
9. If you can take away only 1 lesson…
www.free-dimension.com 9
11. This rule is so important I have to
break it
www.free-dimension.com 11
13. What? Why? How?
www.free-dimension.com 13
21. What? Why? How?
www.free-dimension.com 21
23. Software
Quality
Code Quality
Code Smells
not to scale
www.free-dimension.com 23
27. One path to cleaner code goes
through code smells
www.free-dimension.com 27
28. What? Why? How?
www.free-dimension.com 28
33. They’re some of the smells I smelled
while working here
www.free-dimension.com 33
35. 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
www.free-dimension.com 35
37. 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
www.free-dimension.com 37
44. class MessagesController extends AppController {
function zebra_inbox() {
// inbox code
}
function zebra_view($id = null) {
// view message code
}
}
δ www.free-dimension.com 44
45. class MessagesController extends AppController {
function zebra_inbox() {
// inbox code
}
function elephant_inbox() {
// inbox code
}
function zebra_view($id = null) {
// view message code
}
function elephant_view($id = null) {
// view message code
}
}
δ www.free-dimension.com 45
46. But then came the penguin, the
dolphin, the chimp,…
δ www.free-dimension.com 46
48. class MessagesController extends AppController {
function zebra_inbox() {
$this->setAction('inbox');
}
function elephant_inbox() {
$this->setAction('inbox');
}
function inbox() {
// inbox code
}
function zebra_view($id = null) {
$this->setAction('view', $id);
}
function elephant_view($id = null) {
$this->setAction('view', $id);
}
function view($id = null) {
// view message code
}
}
δ www.free-dimension.com 48
57. public abstract class AProvider
{
public abstract void AddToFamily(int familyId, string firstName, string sex,
string photo, DateTime? birthDate, string birthCountry, string birthCity,
bool living, DateTime? deathDate, string country, string city, string email,
string homepage, string mobilePhone, string biography, string jobTitle,
string maritalStatus, string spouse, int order, int? fatherId);
public abstract void UpdateInFamily(int id, int familyId, string firstName,
string sex, string photo, DateTime? birthDate, string birthCountry,
string birthCity, bool living, DateTime? deathDate, string country,
string city, string email, string homepage, string mobilePhone,
string biography, string jobTitle, string maritalStatus, string spouse,
int order, int? fatherId);
}
δ www.free-dimension.com 57
60. public abstract class AProvider
{
public abstract void AddToFamily(Person person);
public abstract void UpdateInFamily(Person person);
}
δ www.free-dimension.com 60
63. Not following a coding
convention/standard/style
consistently
www.free-dimension.com 63
64. Not following a coding
convention/standard/style
consistently
www.free-dimension.com 64
68. “Commented-out code is an
abomination.”—Uncle Bob
photo used with permission of Uncle Bob
www.free-dimension.com 68
73. What? Why? How?
www.free-dimension.com 73
74. I may have come off as an a$$
www.free-dimension.com 74
75. My code smells as bad as everyone
else’s.. sometimes even worse
www.free-dimension.com 75
77. I try my best to prevent them
www.free-dimension.com 77
81. If you want to sniff more…
www.free-dimension.com 81