Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Good Code
Search
barisdemiroz
November 21, 2013
Programming
3
140
Good Code
The presentation I made for software engineering course @{Bogazici University}
barisdemiroz
November 21, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
110
CloudflareのSandbox SDKを試してみた
syumai
0
130
KoogではじめるAIエージェント開発
hiroaki404
1
430
複数チーム並行開発下でのコード移行アプローチ ~手動 Codemod から「生成AI 活用」への進化
andpad
0
140
自動テストのアーキテクチャとその理由ー大規模ゲーム開発の場合ー
segadevtech
2
960
r2-image-worker
yusukebe
1
170
Module Harmony
petamoriken
1
120
オフライン対応!Flutterアプリに全文検索エンジンを実装する @FlutterKaigi2025
itsmedreamwalker
2
170
Tangible Code
chobishiba
3
530
エンジニアに事業やプロダクトを理解してもらうためにやってること
murabayashi
0
140
AIエージェントでのJava開発がはかどるMCPをAIを使って開発してみた / java mcp for jjug
kishida
4
380
AI 時代だからこそ抑えたい「価値のある」PHP ユニットテストを書く技術 #phpconfuk / phpcon-fukuoka-2025
shogogg
1
410
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Embracing the Ebb and Flow
colly
88
4.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
We Have a Design System, Now What?
morganepeng
54
7.9k
Visualization
eitanlees
150
16k
Statistics for Hackers
jakevdp
799
220k
The Cult of Friendly URLs
andyhume
79
6.7k
Producing Creativity
orderedlist
PRO
348
40k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Context Engineering - Making Every Token Count
addyosmani
9
380
Transcript
Barış Evrim Demiröz software engineering @boun 21.11.2013
None
None
None
None
// increments i by one i++;
itemCount++;
None
None
• Function/Variable naming • Code style – Java conventions (Eclipse
CTRL+ALT+F) – Google conventions coming soon!
None
x = a*b;
salary = hoursWorked*rate;
None
*:execute perform do carry fulfill accomplish
None
None
None
None
None
if (items.size() < 30)
if (items.size() < MAX_ITEMS_ALLOWED)
None
line.split(",");
line.split(DELIMITER);
line.split(DELIMITER);
None
None
None
None
None
None
None
None
• Should be simple • Should be fast
private void testNoCookie( Cookie[] cookies ) { when( request.getCookies() ).thenReturn(
cookies ); CookieHandler handler = new CookieHandler( request ); assertFalse( handler.hasCookie() ); handler.createOrRenew( response ); assertTrue( handler.hasCookie() ); assertTrue( handler.getUUID().length() > 0 ); }
@Test public void testNoCookie1() { testNoCookie( null ); } @Test
public void testNoCookie2() { testNoCookie( new Cookie[] {} ); }
None
public void testAdd() { assertEquals(3, calculator.add(2, 1)); assertEquals(2, calculator.add(2, 0));
assertEquals(1, calculator.add(2, -1)); }
public class Calculator { public int add(int a, int b)
{ return a + b; } }
public class Calculator { private AdderFactory adderFactory; public Calculator(AdderFactor adderFactory)
{ this.adderFactory = adderFactory; } public int add(int a, int b) { Adder adder = adderFactory.createAdder(); ReturnValue returnValue = adder.compute(new Number(a), new Number(b)); return returnValue.convertToInteger(); } }
SO • others • blogs • twitter
None
None
None
None
1
None
None
double calculate(Context foo) { checkNotNull(foo); // rest of the computation…
}
None
None
List<Integer> numbers = asList(1, 2, 3, 4, 5, 6); numbers.forEach(System.out::println);
sumAll(numbers, n -> n % 2 == 0);
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
double calculate(int foo) { if (foo < 0) return 0;
// rest of the computation… }
You Ain’t Gonna Need It
None
None
None
None
None
None
public class LongDivision { private static final long MILLIS_PER_DAY =
24 * 60 * 60 * 1000; private static final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000; public static void main(String[] args) { System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); } }
public class LongDivision { private static final long MILLIS_PER_DAY =
24 * 60 * 60 * 1000; private static final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000; public static void main(String[] args) { System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); } }
public class LongDivision { private static final long MILLIS_PER_DAY =
24 * 60 * 60 * 1000; private static final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000; public static void main(String[] args) { System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); } } overflows
public class LongDivision { private static final long MILLIS_PER_DAY =
24L * 60 * 60 * 1000; private static final long MICROS_PER_DAY = 24L * 60 * 60 * 1000 * 1000; public static void main(String[] args) { System.out.println(MICROS_PER_DAY / MILLIS_PER_DAY); } }
None
Don’t hold all the complexity in your mind
None
None
None
None