전체 글

전체 글

    Trailing closure - 후행 클로저

    struct widget: Widget { let kind: String = "widget" var body: some WidgetConfiguration { IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in widgetEntryView(entry: entry) } .configurationDisplayName("My Widget") .description("This is an example widget.") } } 스위프트로 위젯 익스텐션을 추가 중 특이한 문법을 발견했다. IntentConfiguration(kind: kind, intent: ConfigurationInten..

    [코딩테스트 cheatsheet] 서로소 집합 (Disjoint set)

    개념 서로소 집합 : 공통 원소가 없는 두 집합 서로소 집합 자료구조 : 서로소 부분 집합들로 나누어진 원소들의 데이터를 처리하기 위한 자료구조 스택, 큐가 pop, push 연산을 사용하는 것 처럼 서로소 집합은 union, find 연산을 이용함 find - 속한 집합이 어떤 집합인지 찾기 union - 두 개의 집합을 합치기 싸이클인지 구하기 find해서 같다면 cycle 다르면 union 코드 # find - 부모 찾기 def find_parent(parent, x): if parent[x] != x: parent[x] = find_parent(parent, parent[x]) return parent[x] # union 두 집합의 부모를 비교, 더 작은 쪽을 부모로 대입 def union_par..

    Effective Dart 읽어보기 1 - Style

    https://dart.dev/guides/language/effective-dart Effective Dart Best practices for building consistent, maintainable, efficient Dart libraries. dart.dev 두 가지 중요한 주제 Be consistent - formatting, casing 과 같은 것들은 주관적, 정답이 없음, 일관되게 짜는 것이 도움이 된다. Be brief - Dart는 많은 기능이 있다. 간결하게 작성하자. Identifiers UpperCamelCase, lowerCamelCase, lowercase_with_underscores 세가지가 쓰임 UpperCamelCase - class, enum, typedef, t..

    [담타 - 리팩터링] 필요 없는 주석 제거

    성격 때문인지 실력 때문인지 주석을 잘 못지우겠다. 차라리 기능에 대한 부가 설명을 써놓은 주석이라면 좋겠지만, 내 주석은 거의 DateTime standardDate = DateTime(year, month); // print('standard date ${standardDate}'); int totalDays = daysInMonth(standardDate); // print('totalDays : ${totalDays}'); 이런 print 디버깅을 사용하고 잠시 주석처리 해놓은 것이거나 // child: Center( // child: Badge( // // shape: BadgeShape.square, // // borderRadius: BorderRadius.circular(10), // //..

    [담타 - 리팩터링] 테마 및 컬러 관리

    자주 쓰이는 값을 한번에 관리하기 위해 혹은 틀리면 안되는 값을 조금 더 엄격하기 위해 상수를 사용한다. 내 프로젝트에서는 아래와 같이 관리했는데, common 폴더에 theme.dart 를 만들고 appTheme 클래스를 이용해서 상수를 설정해주었다. 앱 내의 색이 들어가는 모든 것들에 대해 변수를 만들어주고 거기서 또 할당해주었다. 이렇게 한 이유는 색이 들어가는 모든 것들에 각각의 변수를 주어서 하나의 파일에서 모든 색을 수정할 수 있게 하고 싶어서였다. // /common/theme.dart class appTheme { static const Color mainGreen = Color(0xFF111111); static const Color white = Colors.white; static c..