13. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
Marc Donner
IBM Watson Research
Center
13
14. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
컴파일 오류 對 런타임 오류
14
15. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
형식 추론 對 형식 지정
명시적 형변환 對 암시적 형변환
15
16. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
가비지 수집 對 명시적 자원 관리
16
17. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
여러분이 잡아야 하는 진짜 버그
17
19. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
비개발자가 작성하는 코드라면?
19
20. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
값은 스택에서 바로 날리고
참조는 가비지 수집기에게 맡기자
20
21. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
추론시켜도 되는 부분은 맡기고
var s = “string”;
의미가 숨어 위험하면 드러낸다
if (p != null)
21
22. Of all my programming bugs, 80% are syntax errors.
Of the remaining 20%, 80% are trivial logical errors.
Of the remaining 4%, 80% are pointer errors.
And the remaining 0.8% are hard.
타이핑을 줄인다
22
30. 반복자
• 스테이트 머신 코드를 컴파일러가 생성
IEnumerable<T> Where<T>(
IEnumerable<T> source,
Func<T, bool> predicate)
{
if (source == null) yield break;
foreach (T value in source)
{
if (!predicate(value)) continue;
yield return value;
}
}
30
31. 초기화 문법
• 지역 변수/배열의 형식은 추론
멤버 필드/속성 초기화도 같이 작성
var list = new List<int>() { 1, 2 };
var values = new[]
{
new SomeKeyValue()
{
Name = “name”,
Value = null,
},
};
31
32. 확장 메서드
•정적 클래스의 메서드를
특정 타입의 멤버 메서드처럼 취급
static class ComponentExtensions
{
static void DoSomething(
this IComponent component,
T arg) { … }
}
ComponentExtensions.Do(component, arg);
component.DoSomething(arg);
32
33. 통합 언어 쿼리 (LINQ)
•확장 메소드 호출을 질의 문법 형태로 표기
var q = from c in categories
join p in products
on c.ID equals p.CID
orderby c.ID,
p.Price descending
group p.Price by c.ID into g
let cid = g.Key
where Predicate(cid)
select g.Average();
34. 읽을거리
• C++ 프로그래머를 위한 C#, NDC2011
http://www.slideshare.net/devcatpublic
ations/c-c-8252982
• A C# Reading List
http://www.informit.com/articles/articl
e.aspx?p=1769249
34