From f77c35d8ead274473037165fbe67d4f7883e7c09 Mon Sep 17 00:00:00 2001 From: pgummer Date: Sat, 7 Jun 2014 07:34:25 +0000 Subject: [PATCH] Author:Peter Gummer Date:2014-06-07T07:34:25.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1379 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../ca011-too-many-arguments.wiki | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki index 6112e49d..c768347f 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki @@ -4,16 +4,12 @@ [[Property:uuid|d25e2dc7-7a95-c13a-bfa2-ceb42a084fa6]] __NOTOC__ =Description= -A feature that has too many arguments should be avoided since it makes the class interface complicated and it is not easy to use. The feature arguments may include options, which should be considered to be moved to separate features. - -Interfaces of features with a large number of arguments are complicated, in the sense for example that they are hard to remember for the programmer. Often many arguments are of the same type (such as INTEGER). So, in a call, the passed arguments are likely to get mixed up, too, without the compiler detecting it. - -Arguments where in most of the cases the same value is passed--the default value--are called options. As opposed to operands, which are necessary in each feature call, each option should be moved to a separate feature. The features for options can then be called before the operational feature call in order to set (or unset) certain options. If a feature for an option is not called then the class assumes the default value for this option. +A feature that has too many arguments should be avoided since it makes the class interface complicated and is not easy to use. The feature arguments may include options, which should be considered to be moved to separate features. :{| class="doctable" |- | '''Scope''' -| Instruction +| feature |- | '''Status''' | Enabled @@ -33,18 +29,17 @@ Arguments where in most of the cases the same value is passed--the default value =Example of violation= -my_document.print (printer_name, paper_size, color_or_not, postscript_level, print_resolution) +my_document.print (printer_name, paper_size, postscript_level, print_resolution) =Recommendation= -Replace left or right side with something else than the other element. +Detect arguments that are really options and create procedures to set them. In the example, one could write: -my_document.set_printing_size (paper_size) -my_document.set_color -my_document.print +my_document.set_paper_size (paper_size) +my_document.set_postscript_level (postscript_level) +my_document.set_print_resolution (print_resolution) +my_document.print (printer_name) -{{SeeAlso | [[CA071 - Self-comparison]]}} -