编程时使用空白的最佳方法是什么? [英] What is the best way to use whitespace while programming?

查看:102
本文介绍了编程时使用空白的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程还很陌生,从学习中学到了格式化代码,注释等格式的各种方法;

I'm fairly new to programming and from learning I have seen different ways of formatting code, comments, etc; and have been recommended on different techniques.

我主要使用C#,C ++和Java编程,所以我想知道什么是布局代码的最佳方法,以便其他人在哪里经历它,它的简单性和易理解性会给他们留下深刻的印象。

I mostly program in C#, C++, and Java so I want to know what is the the best way to layout code so that if other people where to go through it, they would be impressed by how simple and easy to understand it is.

推荐答案

最好的规则遵循的规则是:(也许是每个人都会同意的唯一规则)

The best rule to follow is: (and probably the only rule everyone will agree on)


要保持一致!

选择一种样式并坚持使用。始终将牙套放在同一位置。使用类似的命名约定。请勿混用制表符和空格等。

Pick one style and stick with it. Always put your braces in the same place. Use similar naming conventions. Don't mix tabs and spaces, etc...

话虽如此。尝试遵循一种语言的约定通常也是一个好主意。

That being said. It is also usually a good idea to try and follow the conventions already in place for a language.



团队,请确保所有人都同意并坚持使用。如果不这样做,通常一个开发人员会使用其自动格式化程序重新格式化文件,然后您可能会遇到数百个仅由空白引起的小冲突。


When working on a team with people, make sure that you all agree upon a style and stick with it. If you don't, often times one developer will reformat a file with their auto-formatter, and then you can have hundreds of little conflicts that were just caused by whitespace.

这篇关于编程时使用空白的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆