What is this OOP thingy.
"Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and dat...
For further actions, you may consider blocking this person and/or reporting abuse
I would suggest changing the inheritance example to a proper is-a relationship to illustrate the point - I assume many OOP-newbies will find this article, so better not confuse them :)
There is no sense in Person extending Organization (essentially being one).
On it......tanx for the response
Thanks for the write-up Nddy.
In your third example, was the reason you chose to call
description()
inbio()
just to show us that you can call class methods in other methods of the same class or was there another reason?Also, I think you have a typo here: "I told you they were not scary, getters get's property value and setters changes our changes property value."
Thanks.
no other reason
thanks for noticing d typo.
Bad example on inheritance. Inheritance describes an IS-A relationship. Obviously a person is not an organization and such an inheritance doesn't make sense. Also "this" refers to the instance of the class not the class itself. Second description implies that changes on this would influence all instances of some class which is not the case.
you are absolutely right...
why I do agree I did use a bad example while trying to stick to the storyline,
I tried to keep it as simple as possible as I did not expect a newbie to understand instances
Keeping instructions is nice but they need to be precise otherwise a newbie could conclude that "this" is some kind of a static variable and that could make learning difficult down the road.
Just edit the "this" part, overall the article is fine.
thanks for contributing.
It sure is a bad example none-the-less, I am working on changing it and still keeping it as simple as possible
Wait, now every Person is a Father, but not every Father is a Person? I think maybe you should spend more time understanding inheritance yourself before trying to explain it to others.
A person is a Father
A Father is a person
In this case it goes both ways
I am not perfect... I get that!
you see something that doesn't feel right you let me know.
Not every Person is a Father, and that's what inheritance represents. If class B inherits from class A, it means that every instance of class B has the abilities of class A, and anywhere that expects an A can be given a B instead.
This is probably easier to understand if we add a third class to the example: Mother. Intuitively, a Mother is a Person, but not a Father; and a Father is not a Mother either. So code that expects a Father and is given a Mother won't work; but code that expects a Person can be given a Father or a Mother. So, we would write "class Father extends Person", and "class Mother extends Person".
Thanks man... I figured that out from your first response
I think this article has helped me more than it will help any reader and I made some changes which you can check out too
I'm grateful.
I like the way you wrote it, you made it look really easy.
thanks Lance, I'm glad you liked it
You have an extra "class Person {" in there...
can you be more specific pls
Seen it... tankx
Classes in JS is less syntactical sugar and more syntactical salt.
lmao
In the first example, I believe the code at the bottom should be
'Console.log(citizen.name)'
Rather than
'Console.log(a.name)'
no?
Yes you are right... I kinda changed to citize at a late hour.... forgot that one
Editing it now... tanx