打造简洁,优雅的code提示 [英] Tips on creating clean, elegant code

查看:104
本文介绍了打造简洁,优雅的code提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写简洁,优雅的code是什么使编码我很荣幸。我一直在寻找更多的方式来做到这一点。下面是我的一些战略/战术:

Writing clean, elegant code is what makes coding a pleasure for me. I'm always looking for more ways to do so. Here are some of my strategies/tactics:


  • 请大code块程序/方​​法/类的小块

  • Keep large code blocks in smaller chunks of routines/methods/classes

确保每个程序都有退出的一个点。退出与逻辑回路的循环的顶部,不断裂或某种类型的退出循环的关键字。

Be sure every routine has one point of exit. Exit loops with logic at the top of the loop, not with breaks or some type of "exit loop" keyword.

避免全局

如果你只是进行了复制/粘贴您的code,是时候建立一个例行/班/库。

If you just performed a copy/paste with your code, it is time to create a routine/class/library.

...和一个我最近一直玩弄:

...and one I've been toying with lately:


  • 尝试更换,如果/分支/选择的情况下用不同的方法签名(多态性)
    YouTube上的清洁code会谈

推荐答案

清洁code罗伯特C.马丁

替换文本

这篇关于打造简洁,优雅的code提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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