简体   繁体   English

我怎么知道我写的代码是正确的做事方式?

[英]How do I know that the code I write is the right way to do things?

How do I know that the code I write is the right way to do things?我怎么知道我写的代码是正确的做事方式?

反应 useState 或 PropTypes

Disclaimer: I'm not a React developer免责声明:我不是 React 开发人员

As with most problems there is usually more than one way to get the code to work.与大多数问题一样,通常有不止一种方法可以让代码正常工作。 However, there are many practices and patterns that we try to adhere to to make our work easier.但是,我们尝试遵循许多实践和模式,以使我们的工作更轻松。

There are often idiomatic ways to do things in specific situations, these may depend on the language or framework that is in use.在特定情况下通常有惯用的方法来做事,这些可能取决于所使用的语言或框架。 There are also many conventions in use, such as what casing to use when naming variables, functions, classes, etc.. This is something that you will learn through experience and discussions with your peers.使用中也有很多约定,比如在命名变量、函数、类等时使用什么大小写。这是你将通过经验和与同行讨论来学习的东西。

If you would like somebody to review your code, go and take a look at Code Review .如果您希望有人审查您的代码,请查看Code Review

If you work in a company, usually senior developers will tell you what is wrong and how to write code properly.如果你在一家公司工作,通常高级开发人员会告诉你哪里出了问题以及如何正确编写代码。 But if you are at the beginning of your career and are looking for a job, I would recommend books about good practices and design patterns.但是,如果您正处于职业生涯的初期并且正在寻找工作,我会推荐有关良好实践和设计模式的书籍。 Also you can learn a lot from React docs.你也可以从 React 文档中学到很多东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM