開發紀錄 (lab0)
contributed by <ianbig
>
On Progree
- Linked List implementation
- integrate clang-format to vscode
Things to learn in lab0
Goal
Requirement
special case for NULL
- null queue: pointer with type queue_t point to null
- empty queue: member head pointer in type queue_t point to null
make test
coding style
- use
white space
over tab
- the
tab
have different behavior on different system –> but I think is ok, since the system environment is set by users; hence, the behavior must be the most suitable one for them
- easy for code review on course
- a line of character < 80 characters
- switch and case aligned
for fucntion:
- white space
- usually in linux kernel white space appear after keyword, such as,
if
, while
, do
, else
, for
, switch
case
- But the the following it do not:
sizeof
, typeof
, alignof
, attribute
- add
whitespace
around some binary operation e.g. = + - < > * / % | & ^ <= >= == != ? :
- but do not add whitespace around 一元操作符, such as
++, --
- pointer
- the naming of variable
- local variable or function (such as static): be concise
- global variable of function: be decriptive
git Hooks
commit message
- why a good commit message is important
- help other programmers to better understand the logic of project
- make the process of code review easier
- what do a good commit message comprised of
- style: Markup syntax, wrap margins, grammar, capitalization, punctuation
- content: what information should be included or not included
- metadata: how tracking issue, pull request numbered be referenced
- 7 tips for writing commit message
- Separate subject from body with a blank line
- this can be useful for some tools (e.g. convert git message to e-mail)
- Limit the subject line to 50 characters
- can be 72 character (if subject line > 72, the remaining would be truncated)
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- If applied, this commit will your [subject line here]: this can be a rule of thumb to see whether the commit message is proper
- Wrap the body at 72 characters
- Use the body to explain what and why (i.e. focus on why and what, how can be explaned by code)
- example
Learning
Public-key cryptography
- a.k.a asymmetric cryptography
- message encrypted by recevier's public key
- recevier decrypted the public key with its own private key (this can ensure only recevier can decrypted the message)
- think about symmetry cryptography
- the key need to be send through a secure channel (very hard to accomplish in the world of web)
- reference:https://zh.wikipedia.org/wiki/公开密钥加密