geteilt von: https://lemmit.online/post/3018791
This is an automated archive made by the Lemmit Bot.
The original was posted on /r/ProgrammerHumor by /u/polytopelover on 2024-05-26 21:23:20+00:00.
geteilt von: https://lemmit.online/post/3018791
This is an automated archive made by the Lemmit Bot.
The original was posted on /r/ProgrammerHumor by /u/polytopelover on 2024-05-26 21:23:20+00:00.
I used to like the
action
followed bydirect object
format, until some time ago when trying to find methods or variables related to a specific object. If the action comes first, scanning for the object without an IDE means first reading unnecessary information about the action. That convinced me to opt for$object-$action
in situations where it makes sense.For example in CSS, I often scan for the element, then the action, so
$element-$action
makes more sense. BEM kinda follows this. When dealing with the DOM in JS, that makes sense toobutton.fileDialogOpen()
,button.fileDialogSend()
, … makes more sense when searching.Of course one has to use it sensibly and where necessary. If you are writing a code that focuses more on actions than objects, putting the action first makes sense.
A similar thing is definition order.
I find this much easier to follow than if
main
were defined last, becausemain
is obviously the most important method and everything else is used by it. A flattened dependency tree is how these definitions make sense to me or how I would read them as newbie to a codebase.Anti Commercial-AI license
I agree with you especially on the definition order of functions. I, too, define
main()
first.