This document discusses eliminating "codejunk", which is unnecessary code that does not contribute meaningful information. It provides examples of codejunk like unused variables, pointless comments, and overly specific variable names. The document encourages maximizing the data to ink ratio in code by removing frills and getting to the essential points. It also notes that what constitutes codejunk depends on context like programming language and project type.
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Codejunk Ignitesd
1. Chartjunk is ink that does not
tell the viewer anything new.
Maximize the data:ink
ratio.
Kill the frills and
get to the point!
2. The present letter is a very long
one, simply because I had no
leisure to make it shorter.
Code is read much more
often than it is written.
It's harder to read
code than to write it.
7. codejunk: gratuitous super()
public class Foo {
public class Foo {
int n;
int n;
public Foo(int n) {
public Foo(int n) {
super();
this.n = n;
this.n = n;
}
}
}
}
8. codejunk: superfluous this
public void increment() { public void increment() {
this.total++; total++;
this.notifyListeners(); notifyListeners();
} }
11. codejunk: pointless comments
/**
* @return the bar
*/
public int getBar() { public int getBar() {
return bar; return bar;
} }
/** public void setBar(int bar) {
* @param bar the bar to set this.bar = bar;
*/ }
public void setBar(int bar) {
this.bar = bar;
}
12. codejunk: commented-out code
int three() {
int three() {
int i;
int i;
i = 1;
i = 1;
//System.out.println(i);
i += 2;
i += 2;
return i;
return i;
}
}
13. codejunk: unused variables
int three() {
int three() {
int i;
int i;
int n;
i = 1;
i = 1;
i += 2;
i += 2;
return i;
return i;
}
}
14. codejunk: scope end labels
for (int i : array) { for (int i : array) {
sum += i; sum += i;
count++; count++;
} // end for }
15. codejunk: excessively specific
variable names
public int countCapitals(String mixedCaseString) {
int count = 0;
for (char c : mixedCaseString.toCharArray())
if (Character.isUpperCase(c))
count++;
return count;
}
public int countCapitals(String string) {
int count = 0;
for (char c : string.toCharArray())
if (Character.isUpperCase(c))
count++;
return count;
}
16. codejunk: change comments
for (int i : array) {
for (int i : array) {
// changed 01/20/09 cjm
sum += i;
sum += i;
count++;
count++;
}
}
18. codejunk: long temporary variable names
for (int index = 0; index < array.length; index++)
sum += array[index];
for (int i = 0; i < array.length; i++)
sum += array[i];
19. Let your IDE help
Eclipse detects:
• unused imports
• unused variables
• unread variables
• unnecessary else statements
• unnecessary casts
20. my point
It's not that "anyone It's that you can benefit
who uses braces is by being conscious of
evil", or that "you should codejunk and
not be writing what I methodical in its
consider codejunk." definition and
application to your
projects.