What makes a language Object-Oriented?

后端 未结 15 2083
无人共我
无人共我 2020-12-07 17:01

Since debate without meaningful terms is meaningless, I figured I would point at the elephant in the room and ask: What exactly makes a language \"object-oriented\"? I\'m no

相关标签:
15条回答
  • 2020-12-07 17:37

    when you can make classes, it is object-oriented
    for example : java is object-oriented, javascript is not, and c++ looks like some kind of "object-curious" language

    0 讨论(0)
  • 2020-12-07 17:38

    Simples:(compare insurance character)

    1-Polymorphism 2-Inheritance 3-Encapsulation 4-Re-use. :)

    0 讨论(0)
  • 2020-12-07 17:39

    Archetype

    The ability to express real-world scenarios in code.

    foreach(House house in location.Houses)
    {
     foreach(Deliverable mail in new Mailbag(new Deliverable[]
                  {
                  GetLetters(), 
                  GetPackages(), 
                  GetAdvertisingJunk()
                  })
     {
        if(mail.AddressedTo(house))
        {
            house.Deliver(mail);
        }
     }
    }
    

    -

    foreach(Deliverable myMail in GetMail())
    {
        IReadable readable = myMail as IReadable;
        if ( readable != null )
        {
            Console.WriteLine(readable.Text);
        }
    }
    

    Why?

    To help us understand this more easily. It makes better sense in our heads and if implemented correctly makes the code more efficient, re-usable and reduces repetition.

    To achieve this you need:

    • Pointers/References to ensure that this == this and this != that.
    • Classes to point to (e.g. Arm) that store data (int hairyness) and operations (Throw(IThrowable))
    • Polymorphism (Inheritance and/or Interfaces) to treat specific objects in a generic fashion so you can read books as well as graffiti on the wall (both implement IReadable)
    • Encapsulation because an apple doesn't expose an Atoms[] property
    0 讨论(0)
提交回复
热议问题