This may seem like an odd post, but bare with me here.
I’m assuming most, if not all of us here had some experience with OO languages, so it’s normal to hear terms like object, has-a, or is-a.
- When you use a
NamedTuple
, is it correct to say that we have an object?
Fruit = @NamedTuple(name::String,Type::String, color::String)
ambrosia::Fruit = (name = "Ambrosia", Type="Apple" color = "Red")
Is it correct to say ambrosia
is a object of Fruit?
- If we really wanted to go deeper, fruits obviously have certain attributes, name, colour, places of origin, etc…
It’s easy to see the has-a relationship and model a NamedTuple
or struct
this way, but is it correct to think of it that way?
- If we go deeper, we could model our fruits this way
AbstractFruit
>Apple
, in the documentation it uses the word subtype, soApple
would be a subtype ofAbstractFruit
.
It’s easy to see the is-a relationship, so, is it correct to think of it that way?
I only ask this because, on the surface, it might be easy to explain that a variable name is like a box to store a value, and in languages such as Java and C# that might be true, but that thinking breaks down in languages like Python and Julia.
I’m not asking how to do OOP in Julia, but rather how do we take certain OO concepts and think about them the Julia way.