Closed9
refactor-bsq [42project]
ピン留めされたアイテム
What's new for me
- use constant variables
Naming
-
long name > short name
A long descriptive name is better than a short enigmatic name
-- Uncle Bob Martin - use verb/action for func names
-
if name includes
and
, split function (doing to many things in a function)
ex)check_and_execute
->check
,execute
Reminder
-
One responsibility per function
-
avoid
tmp
andretval
-
do NOT abbreviate when not sure
Funcs
- no more than 2 levels of nasting
- do NOT repeat yourself
Tips
- naming (
void swap_if_needed()
) - naming (
char *to_pop
)
リンカエラー
original code
ft.h
int g_max;
int g_col;
int g_row;
makesquare2.c
extern int g_max;
extern int g_col;
extern int g_row;
refactored code
ft.h
extern int g_max;
extern int g_col;
extern int g_row;
makesquare2.c
int g_max;
int g_col;
int g_row;
ヘッダファイルで宣言すると、あらゆるファイルで宣言される。
ld: 24 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [bsq] Error 1
参考 >>>
For Review
-
:set bin noeol
改行の削除
このスクラップは2022/12/12にクローズされました