Properties, Parameters, Fields
-
These three words get tossed around randomly at times. Often interchangeably. I get really confused by some articles To me they have three different definitions. Here is my take, what is yours. 1. A Property can be either a Parameter or Field. 2. Parameters have get and set. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. I know this may be oversimplified this is gist of it.
So many years of programming I have forgotten more languages than I know.
It may depend on the language in use, but what you list is not entirely correct for C#. Edit: 1. A Property can be either a Parameter or Field. -- No, a Property may or may not be backed by a field, but has nothing to do with parameters 2. Parameters have get and set. -- No, that's Properties. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. -- Sorta, but a field may be any type. (Though there may be restrictions I'm not thinking of right now.)
-
It may depend on the language in use, but what you list is not entirely correct for C#. Edit: 1. A Property can be either a Parameter or Field. -- No, a Property may or may not be backed by a field, but has nothing to do with parameters 2. Parameters have get and set. -- No, that's Properties. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. -- Sorta, but a field may be any type. (Though there may be restrictions I'm not thinking of right now.)
I was talking about C#
So many years of programming I have forgotten more languages than I know.
-
I was talking about C#
So many years of programming I have forgotten more languages than I know.
Then you have more studying to do. Members - C# Programming Guide | Microsoft Docs[^] You'll notice that "Parameters" is not on that list -- parameters are not members.
-
Then you have more studying to do. Members - C# Programming Guide | Microsoft Docs[^] You'll notice that "Parameters" is not on that list -- parameters are not members.
This mostly comes from Microsoft's website and not the books on C#. There are some discrepancies.
So many years of programming I have forgotten more languages than I know.
-
I was talking about C#
So many years of programming I have forgotten more languages than I know.
-
This mostly comes from Microsoft's website and not the books on C#. There are some discrepancies.
So many years of programming I have forgotten more languages than I know.
What books?
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
These three words get tossed around randomly at times. Often interchangeably. I get really confused by some articles To me they have three different definitions. Here is my take, what is yours. 1. A Property can be either a Parameter or Field. 2. Parameters have get and set. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. I know this may be oversimplified this is gist of it.
So many years of programming I have forgotten more languages than I know.
And then there's arguments...
Nothing succeeds like a budgie without teeth.
-
And then there's arguments...
Nothing succeeds like a budgie without teeth.
Is that the five minute argument, or the full half-hour? :-D
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
These three words get tossed around randomly at times. Often interchangeably. I get really confused by some articles To me they have three different definitions. Here is my take, what is yours. 1. A Property can be either a Parameter or Field. 2. Parameters have get and set. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. I know this may be oversimplified this is gist of it.
So many years of programming I have forgotten more languages than I know.
Coming from C#, parameters don't exist (the way you describe them). There's fields & properties with properties having getters/setters and fields being just member variables. I personally use fields as much as possible (KISS principle), but switch to properties if needed, i.e. when I need a private setter and a public getter or override getters in derived classes. The difference is more on the syntactic side of things. Semantically, both properties & fields are variables-this-object-exposes and whatever the object does with those variables, that's the object's own business.
-
These three words get tossed around randomly at times. Often interchangeably. I get really confused by some articles To me they have three different definitions. Here is my take, what is yours. 1. A Property can be either a Parameter or Field. 2. Parameters have get and set. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. I know this may be oversimplified this is gist of it.
So many years of programming I have forgotten more languages than I know.
Please read the Lounge posting guidelines, and post technical question in an appropriate forum.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
-
Please read the Lounge posting guidelines, and post technical question in an appropriate forum.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
It is not meant to be a technical argument. It is just general usage of ambiguous terms. After all, no semicolons were harmed by it.
So many years of programming I have forgotten more languages than I know.
-
These three words get tossed around randomly at times. Often interchangeably. I get really confused by some articles To me they have three different definitions. Here is my take, what is yours. 1. A Property can be either a Parameter or Field. 2. Parameters have get and set. 3. Fields are declared and that is it. Mostly simple atomics but can be instances of enums or lists or etc. I know this may be oversimplified this is gist of it.
So many years of programming I have forgotten more languages than I know.
As shown by others, this is not correct for C#. But it did bring one question to mind. When talking about a method signature, what are the inputs given to the method considered to be? Parameters or arguments? Those are the two most common that come to my mind, though I can think of others. Are parameters and arguments just completely synonymous? Does it matter how they're being used? Maybe describing the definition of the method compared to describing being executed at runtime? What are they called when using one as a value or reference within the method? Or do they just just turn into "variable" at that point and the original term is meaningless? I've thought about this too much now while writing this and can only contradict my own thoughts now. Does anyone have a clear way of thinking about this case?
-
As shown by others, this is not correct for C#. But it did bring one question to mind. When talking about a method signature, what are the inputs given to the method considered to be? Parameters or arguments? Those are the two most common that come to my mind, though I can think of others. Are parameters and arguments just completely synonymous? Does it matter how they're being used? Maybe describing the definition of the method compared to describing being executed at runtime? What are they called when using one as a value or reference within the method? Or do they just just turn into "variable" at that point and the original term is meaningless? I've thought about this too much now while writing this and can only contradict my own thoughts now. Does anyone have a clear way of thinking about this case?
Arguments is an old term that is not used much any more. You still find arguments in many references. Parameters is the newer term for the same thing. This is where words get confusing. When you use get/set many consider it a kind of super argument/parameter. That is why many references consider things with get/set use the term parameters. My whole point in this rant is no one is right or wrong. They are not terms with rigid meanings cast in syntax stone. They are all just general concepts.
So many years of programming I have forgotten more languages than I know.