Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write down the first version of Code Style and Quality Guide #26

Closed
tisonkun opened this issue Jun 16, 2021 · 6 comments
Closed

Write down the first version of Code Style and Quality Guide #26

tisonkun opened this issue Jun 16, 2021 · 6 comments

Comments

@tisonkun
Copy link
Contributor

https://github.com/zz-jason/tidb-dev-guide/edit/master/contribute-to-tidb/code-style-and-quality-guide.md

@gregwebs has several excellent shares offline. I'd like to invite you to enrich this chapter.

@tisonkun tisonkun changed the title Write down the first version of Write Document Code Style and Quality Guide Write down the first version of Code Style and Quality Guide Jun 16, 2021
@tisonkun
Copy link
Contributor Author

tisonkun commented Jul 1, 2021

Hi @gregwebs I can see from the document there are two suggestions valid left

  • Modularity and Package size
  • Errors with stack traces

Do you plan to add them, too?

@gregwebs
Copy link
Contributor

gregwebs commented Jul 1, 2021

No to packages- too unconventional.

We definitely need a guide to error handling. I am not sure if something like that already exists for TiDB

@tisonkun
Copy link
Contributor Author

tisonkun commented Jul 1, 2021

IIRC @disking ever wrote an analyze about pingcap/errors (in Chinese, though).

@disking do you know more about if something for error handling already exists for TiDB?

@djshow832
Copy link

The best practices of reporting errors:

  1. The error message should be more user-friendly. Bad case: The table 101 exceeds table size. Good case: The table tbl exceeds table size.
  2. Provide workarounds if necessary. Bad case: The table tbl exceeds table size. Good case: The table tbl exceeds table size. Please try to turn up the value of the system variable tmp_table_size.
  3. Define an error code when it's a general error. Bad case: The table tbl exceeds table size. Good case: Error 1001: The table tbl exceeds table size.
  4. Report the error as early as possible. If you can judge it in the preprocess phase, don't report it in the planner phase. If you can judge it in the planner phase, don't report it in the executor phase. The premise is not breaking the readability and simplicity of the code.

@tisonkun
Copy link
Contributor Author

Thanks for your comments @gregwebs @djshow832 . I think the original issue "Write down the first version of Code Style and Quality Guide" is done since we have rules on this topic. For writing down style guides of error handling. I will create another issue dedicatedly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants