무냐의 개발일지
[OSSU] <UBCx HtC1x_How to Code> / 8a_Abstraction (중요!!!) 코드 간결하게 짜기 본문
[OSSU] <UBCx HtC1x_How to Code> / 8a_Abstraction (중요!!!) 코드 간결하게 짜기
무냐코드 2024. 5. 9. 14:07One of the things that separates good programmers from the other kind is taking the time to improve the structure of their code once it is written. This material is super important, and... it is really important to practice doing it!
Abstraction is a crucial technique for managing complexity in programs.
- One aspect of this is that it can make programs smaller if the abstract functions are used by many other functions in the system.
- Another aspect is that it helps separate knowledge domains more clearly in code.
All the work you've done understanding templates is about to give you a nice surprise !!!
이제까지는
큰 문제 -> 작은 문제로 쪼개서 푸는 방법
반복을 줄이기 ! Abstraction
반복되는 부분을 함수화하는거다
반복되는 부분을 찾아서 함수화하라!
Work Flow
test 를 먼저 해본다
코드를 고친다
template을 고친다
definition을 고친다
설명을 고친다
;;<Signature>
;; __ __ -> __
(define (map2 fn lon)
(cond [(empty? lon) empty]
[else
(cons (fn (first lon))
(map2 fn (rest lon)))]))
;;<Signature>
;; (X -> Y) (listof X) -> (listof Y)
(define (map2 fn lon)
(cond [(empty? lon) empty]
[else
(cons (fn (first lon))
(map2 fn (rest lon)))]))
'OSSU_CS coursework' 카테고리의 다른 글
[OSSU] <UBCx HtC1x_How to Code> / 10_Accumulator (0) | 2024.05.11 |
---|---|
[OSSU] <UBCx HtC1x_How to Code> / 9a_Generative Recursion (재귀함수) (0) | 2024.05.10 |
[OSSU] <UBCx HtC1x_How to Code> / 7b_Local (encapsulation) (0) | 2024.05.07 |
[OSSU] <UBCx HtC1x_How to Code> / 7a_Two One-Of Types (여러가지 경우의 수 생각해서 코드 짜기) (0) | 2024.05.06 |
[OSSU] <UBCx HtC1x_How to Code> / 6b_Mutual Reference (0) | 2024.05.05 |