Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is an abstraction and should I care?

A while back I asked a question on what OOP was. In the beginning of his answer the guy gave a quick definition of abstraction but I do not understand what he meant. If someone could help me understand I would be so grateful. Thanks!

Additional question: Is Lua compiled into C++? Is that what abstraction is? Should I care?

1 answer

✓ Accepted answer

Essentially, the point of abstraction in OOP is to create a better understanding for programmers and make their work easier.

Thanks to ROBLOX's API, we don't have to find a way to search through all the children of an object and return the one we're looking for, because we have the :GetChildren() method provided by ROBLOX. Same goes for removing an object, we can use :Destroy() rather than realizing that we have to parent it to nil and the parent-lock it. With this abstraction, we are able to script in a much simpler manner using solely the tools that ROBLOX provides for us.

Let's say you wanted to make a large OOP game. One of the key things you would do is create a set of tools for yourself to deal with the inner workings of your structure, so working with those objects would be much easier throughout the rest of your code. By this I mean adding things such as a constructor, a tool to delete or remove objects, or anything else your game might need. This is the abstraction part, which is necessary to making an OOP game.

Let's say you're making human objects, but in your game there are lots of different creatures. The human object inherits the mammal object, which inherits the animal object.

At this point, creating a human would be a hassle. You would need to keep everything abstract so it's as simple as

class human extends mammal Human.new()

which isn't real code but you get the idea.

To your additional question, yes Lua is compiled into C++. That's not what abstraction is. You shouldn't care too much that it's compiled into C++ but I guess its good to know.

Hope this helps! :)

2 comments

0

good job

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.