OOP (Object Oriented Programming) - Lua tutorial (Part 15)

  Рет қаралды 8,816

Steve's teacher

Steve's teacher

Күн бұрын

Пікірлер: 18
@liarleyev8487
@liarleyev8487 11 ай бұрын
man this is very nice, i always like the "factory functions" design pattern you used to make up for absence of classes.
@erinlane950
@erinlane950 3 жыл бұрын
Finally this makes sense! I have read and watched so many OOP Lua programming tutorials for LOVE2D specifically and I never really "got" it until now.
@KuraakaiGoro
@KuraakaiGoro Жыл бұрын
I followed your tutorial, and decided your pet should be fed only once, or you'll overfeed him. I added extra lines of code dog.feed = function(self) if self.status == "Hungry" then print(name .. " is now full") self.status = "Full" self.loyalty = self.loyalty + 5 else print(name .. " has already been fed") end end and added an extra function that lets you train him. dog.train = function(self) print(name .. " has been trained") self.loyalty = self.loyalty + 5 end I feel accomplished
@slycxi
@slycxi 4 ай бұрын
bro finlly gonna male blox fruits 💀
@AkamiChannel
@AkamiChannel Жыл бұрын
12:38 Unless I'm sorely mistaken (I'm coming from a bunch of other languages here) that is not inheritance at all. What you are doing there (in an OOP way of thinking) is instantiating a locally scoped object of the Pet class. Not really anything new or special. Your Dog class is not inheriting from your Pet class, ie, you could not use Dog.status directly as it is written. (unless I'm sorely mistaken which would be surprising to me)
@AkamiChannel
@AkamiChannel Жыл бұрын
Hmm, watching later it looks like I'm wrong. It's very strange to me though. Why does it actually inherit the class instead of just instantiating a local pet object? How does it know that you don't want to just instantiate a local pet object?
@liarleyev8487
@liarleyev8487 11 ай бұрын
you're not too wrong lol, but in absence of real classes, this is a way for "simulate" inheritance. But, for questions of "separation of concerns" i would prefer to pass the "Pet Factory Function" as a parameter instead of call it directly inside of the Dog Factory function. Sorry for my not too correct and weird english, i'm not a native speaker.
@liarleyev8487
@liarleyev8487 11 ай бұрын
@@AkamiChannel i'm not the guy of the video, but i will reply your question about "why not simply instantiate a pet object?" anyway. This will depends of your interests. Maybe you're developing a game that only will have dogs and cats, both share some common behaviours but not everything. In this case, maybe (only with you want) you can have a class/factory function for create these common behaviours and have factory functions specifically for create Dogs and Cats with its owns behaviours (or sub-functions). In this scenario, you don't want that users or other developers create any kind of pet, even with existance of a generic Pet "class". More one time, sorry for my english
@AlexPiotrowski
@AlexPiotrowski 3 жыл бұрын
Thanks for the tutorial!
@Stevesteacher
@Stevesteacher 3 жыл бұрын
Happy to help! :D
@vilser3950
@vilser3950 2 жыл бұрын
Cat "Luis" is always hungry by default and you cant change his status.
@AdrianTRYaValioCheetos
@AdrianTRYaValioCheetos 3 жыл бұрын
WOW Very nice!! :D
@malakash4716
@malakash4716 9 ай бұрын
So Lua is like Flutter & Dart Object Oriented Program?
@Stevesteacher
@Stevesteacher 9 ай бұрын
No, Lua stimulates OOP with metamethods and functions
@malakash4716
@malakash4716 9 ай бұрын
@@Stevesteacher thanks
@dankmemes8619
@dankmemes8619 Жыл бұрын
i understand the subclass of OOP and how you dont need to have say, 50 objects that need the same default thing but just 50 subclasses to save space and the like. i just dont understand HOW to make it. functions and tables and the like confuse the hell out of me.
@AkamiChannel
@AkamiChannel Жыл бұрын
Procedural programming is not functional programming. Aren't procedural and imperative programming the same?
Using Grids - TKinter Tutorial (Part 2)
8:38
Steve's teacher
Рет қаралды 86
Metamethods - Lua Tutorial (Part 16)
11:45
Steve's teacher
Рет қаралды 4,5 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
5 Tips For Object-Oriented Programming Done Well - In Python
16:08
Introduction to Object-Oriented Programming with Lua
21:52
Functions in Lua - Lua Tutorial (Part 10)
28:48
Steve's teacher
Рет қаралды 6 М.
Why Is Lua So Popular?
8:03
Awesome
Рет қаралды 105 М.
What is Object Oriented Progamming?
13:27
GnomeCode
Рет қаралды 49 М.
Tables (Arrays) - Lua Tutorial (Part 9)
15:59
Steve's teacher
Рет қаралды 14 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 992 М.
Data Types, Scopes and Variables - Lua Tutorial (Part 3)
16:35
Steve's teacher
Рет қаралды 20 М.
Object-Oriented Programming is Bad
44:35
Brian Will
Рет қаралды 2,4 МЛН
Ever wondered about LUA language usage? This info will guide you.
5:07
Jelvix | TECH IN 5 MINUTES
Рет қаралды 34 М.