Hello! My name is Thomas and I'm a nerd. I like tech and gadgets and speculative fiction, and playing around with programming. It's not my day job, but I'm working on making it a side gig :)
If I am allowed to be a bit pedantic, a class is not just a type. A class is a bundling of code/instructions and data. If all you have is some data and no code, then it should be something like a struct or tuple or maybe even a container type such as list or hash depending on your language and use-case.
Any type is a reference to a value and operations on that value. A class is one way of expressing a type. Types are defined by the operations that can be performed on them, not just their raw value -- if one can even define a value absent of any operations on it.
The part I dislike is that classes can represent a bunch of things that don't work like value types as well. I wish these were distinct entities. I called them "service" in the language I was working on.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If I am allowed to be a bit pedantic, a class is not just a type. A class is a bundling of code/instructions and data. If all you have is some data and no code, then it should be something like a struct or tuple or maybe even a container type such as list or hash depending on your language and use-case.
I can also be pedantic and say it is a type. :)
Any type is a reference to a value and operations on that value. A class is one way of expressing a type. Types are defined by the operations that can be performed on them, not just their raw value -- if one can even define a value absent of any operations on it.
The part I dislike is that classes can represent a bunch of things that don't work like value types as well. I wish these were distinct entities. I called them "service" in the language I was working on.