Java方法名称何时太长? [英] When is a Java method name too long?

查看:180
本文介绍了Java方法名称何时太长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几周里,我看到有些人使用了很长的名字来表示方法或类(50个字符),这通常是在提高可读性的前提下,我认为像这样的长名是一个指标如果我们需要这么长的名字,我们试图在方法类中做很多或者太多,但是我想知道你们怎么想它。

In the last weeks I've seen some guys using really long names for a Method or Class (50 characters), this is usually under the premise that it improves readability, my opinion is that a long name like this is an indicator that we are trying to do a lot or too much in a method class if we need such a long name, however I wanted to know what do you guys think about it.

一个例子是:

getNumberOfSkinCareEligibleItemsWithinTransaction


推荐答案

当存在同样表达方法行为的较短名称时,Java或任何其他语言的名称太长。

A name in Java, or any other language, is too long when a shorter name exists that equally conveys the behavior of the method.

这篇关于Java方法名称何时太长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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