Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
As @AleCx04 reminded me to not be an insulting bitch few days ago...
What is wrong with you?
I mean it.
Inconsistent code style or as in your case just mixing all code styles together makes no sense at all.
Especially not for something so trivial as identifying a scope and the property / function belonging to it.
I could understand utilizing / mixing two to three styles, e.g.
PascalCase - class
SCREAMING_CASE - Globals / constants
Snake case - everything else
But throwing everything together and adding a form that could be easily identified as Hungarian notation but not having anything to do with Hungarian Notation at all...?
Ouch. Just ouch.
I'd highly recommend you switching to something a linter supports and can do for you automatically...
Especially if you don't want to work solo on all your projects, which I'd recommend also - being shut in in your own world is just sad. -
@IntrusionCM okay, I see your point, considering the fact that it may confused other people. I'm not reinventing anything. Those cases already exists.
You know that there are some time where a function is called without parentheses, how will a reader know it's a function and not a variable -
-
@IntrusionCM
For example this python thread using the runCommand() function.
Thread(target=runCommand).start() -
Root797672yAdd those lovely Hungarian notation warts and be happy.
Really though: PascalCase for objects, and SCREAMING_SNAKE_CASE for constants is pretty standard, and all that you really need.
You could prefix local vars with an _, but gets tiring pretty quickly. -
@Ohiorenua You could simply NOT omit the parentheses from function calls, so then you wouldn't have to make up an additional convention to identify them.
What you're suggesting is a violation of the rule of least surprise. When someone reads your code, they should be able to expect it will follow standard conventions, ideally of the language at hand, but if not then at least some other standard that is easily understood. -
@NotJeckel You're wrong.
@Ohiorenua
Whats lacking here is the understanding of function declaration vs reference.
def function():
....
vs
use_callback_function(reference=function)
A function and a reference are not the same.
The reason why this works is that everything - be it method / function / ... is generally an object.
So calling function with parentheses is directly invoking the function, passing the function without parentheses is a reference so that the function can be called whenever it seems appropriate (in the method the reference got passed on). -
@IntrusionCM My bad, I thought the poster was talking about calling a function, not declaring or passing one.
But, still, if we're talking about passing a function reference, then there's still no need for extra naming conventions as in that case it's clear that it's a function being passed. -
Most frameworks have their own notation. One should not go ahead and decide how to case code elements by what better suits them. It’s important to read about best practices and how to case properly. Today you may be working alone but tomorrow you may be working in a team, today you may be the one creating the code base from scratch tomorrow you may be the one to be included in an ongoing project, so it’s important to use standards. Happy coding!
Related Rants
-
JannikHv2When you realize that you're googling an error message you've implemented yourself
-
inf3cti0n955That's exactly how I started, am I a Machine!? ... learning Machine Learning
-
PieInOblivion5Teacher: "Whats that key thingy?" Class: "You mean the keyboard?" Teacher: "Yes, that one!" I shit you not, s...
Imagine that I have written 1000 lines of code and imported many libraries. Sometimes I get confused when trying to use a name I defined earlier. In my mind is this name a class or a method, is it a local or global variable, is this a constant. So I came up with a way and it totally works, although my ide complains, but who cares, I use it anyway.
I use PascalCase for class.
camelCase for methods.
snake_case or lowercase for global variables.
kebab-case I don't use this
UPPER_CASE for constants
snake_caseL or lowercaseL with a capital letter L at the ending for local variable.
I hope this is helpful 😊🤔
rant
pascal case
kebab case
programming cases
snake case
camel case
confused
upper case