63.4k views
5 votes
If I am creating a function that makes two squares, what would be the best name option?

1) createSquares
2) makeSquares
3) twoSquares
4) squareFunction

User Sobia
by
7.8k points

1 Answer

5 votes

Final answer:

The function names 'createSquares' and 'makeSquares' are both appropriate as they indicate the action of creating multiple squares. 'twoSquares' could be misleading and 'squareFunction' is too vague.

Step-by-step explanation:

When creating a function that generates two squares, the naming should aim to be descriptive and action-oriented to clearly express the function's purpose. Considering the options provided, createSquares and makeSquares are the more preferable names as they both describe the action of the function and the plural form 'squares' implies multiple squares are being created. The name twoSquares could be misleading as it might suggest the function returns two specific squares rather than creating them dynamically, and squareFunction is general and doesn't convey the quantity of squares the function deals with. Therefore, either createSquares or makeSquares would be appropriate for such a function, depending on the naming conventions used in the rest of the project or codebase.

User Yardena
by
7.7k points