Assuming they are all mandatory:
function search (haystack, needle)
function search (needle, haystack)
function placeObject (object, column, row)
function placeObject (column, row, object)
function newObject (parent, width, height, isVisible)
function newObject (isVisible, width, height, parent)
function newObject (width, height, isVisible, parent)
I think it is often a matter of personal choice which should be consistent throughout the project. But I wonder whether there is a deeper logic which would dictate the order for every case.
Try to pronounce the intended invocation.
function search (needle, haystack)
Search for needle in haystack.
function placeObject (object, column, row)
Place object at (column, row).
newObject
is tough: try to keep it consistent with your framework, if any, put the common parameters first. I'd put isVisible
last just because it's boolean, and it can be hard to infer from a boolean literal what it does. With multiple booleans, I prefer to combine them into a flags object of integer type, built with bitmasks (or a key-value dictionary, or a string, depending on the language) to obtain readability:
openFile(path, READ | LOCKED | COMPRESSED | ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With