Composition Over Inheritance - OOP in Roblox Studio

  Рет қаралды 23,653

B Ricey

B Ricey

Күн бұрын

Пікірлер: 69
@Immow
@Immow 3 жыл бұрын
Hi, I don't use Roblox but Love2d but this is by far the best video I found about OOP. I was looking into inheritance but this video just makes it crystal clear that this is far superior. Thank you so much for taking the time to make this.
@BRicey
@BRicey 3 жыл бұрын
That is absolutely amazing! Your very welcome! I'm glad I can get to people who are not only using roblox, but other engines
@tomsterbg8130
@tomsterbg8130 8 ай бұрын
Yep, the fact that the mentality was explained really set me on my place. It's absolutely amazing to think of inheritance of "this is this" and composition of "this has this". Just the way of thinking is completely clear and you can see that it's superior. A human is an animal? Why don't we act dumb then. A human has animal features. This makes much more sense.
@Jason-xl8fm
@Jason-xl8fm 3 жыл бұрын
Thanks for this video, been learning how to use OOP programming recently and it can get quite messy with the functions. Really nice to see someone who provides tutorials using OOP since it's really a great way to clean up your code.
@jasonmckay2769
@jasonmckay2769 3 жыл бұрын
Simply explained. Great example as opposed to abstract concepts. Well done!
@vashthestampede9999
@vashthestampede9999 3 жыл бұрын
I asked for a video on composition last year and you finally did it, just wanna say great video and I really appreciate it.
@planeman4453
@planeman4453 3 жыл бұрын
dude, this is exactly what i was looking for! Inheritance is quite limiting and composition looks so much better. Stumbled upon this from devforum, great video!
@tomsterbg8130
@tomsterbg8130 8 ай бұрын
I love this I love this I love this!!! I've just seen how Packages work and I know how Godot works so my mentality would be more like "let's use packages to construct classes instead". I want to be more visual about it instead of core-based because code requires you to read it. I want to see my structure. Anyway both your method and mine should be able to achieve the same goals - composition where by changing the components you change code everywhere. I find it much easier to understand less abstract concepts and ideas like having composition out of actual components and using them as if they are default Roblox instance classes.
@edrictigerist
@edrictigerist 2 ай бұрын
Composition Sounds super cool! Glad i stumbled onto this video : D
@rakha8812
@rakha8812 3 жыл бұрын
This is why the Knit's Component Module is so awesome
@wav8518
@wav8518 11 ай бұрын
B Ricey i love your content, after watching and learning your OOP series, what should we learn or do next? I feel stuck and honestly i dont know what to do.
@eliteengineer7340
@eliteengineer7340 Жыл бұрын
you always have what im looking for , you are amazing
@danil-old-web
@danil-old-web 3 жыл бұрын
This is the knowledge we hunger for!
@bryceblazegamingyt9741
@bryceblazegamingyt9741 2 жыл бұрын
I would love to see an updated oop video on metatables and modulescripts! And I want to see your new practices because I'm starting to get interested in Roblox development again because I never knew that Roblox was powerful enough to make abstract classes. Love your work
@He_ze
@He_ze Жыл бұрын
old videos, but timeless content lol. Currently in the process of cleaning up the code of my old game and this video was very useful
@BRicey
@BRicey Жыл бұрын
Glad I could help!
@Roxaro
@Roxaro 2 жыл бұрын
other OOP tutorials was boring but this something else
@karlmarx2704
@karlmarx2704 3 жыл бұрын
Creating Classes with other Classes you say? Hmmmmmmmm...
@BRicey
@BRicey 3 жыл бұрын
I just noticed your name lol
@stemaidev
@stemaidev 2 жыл бұрын
because of you I learned how to use Metatables in module scripts. Thanks B Ricey!!
@BRicey
@BRicey 2 жыл бұрын
Glad I could help!
@vineetsawant9074
@vineetsawant9074 Жыл бұрын
great example of how to implement OOP in Roblox!
@pfever
@pfever 7 ай бұрын
Downside of composition, you need to make tons of simple classes
@Relphy
@Relphy 3 жыл бұрын
HAPPY 2K SUBSCRIBERS!
@Mr1Lito
@Mr1Lito 4 ай бұрын
13:01 i keep getting this error: attempt to index nil with 'IsFlat', why?
@Mr1Lito
@Mr1Lito 4 ай бұрын
it works now but i have no idea why, i asked chatgpt for help and it gave me a code to copy and paste (it was the exact same as mine) but now it worked
@Passsoio
@Passsoio 2 ай бұрын
I have the same problem, for some reason the values of the tables are printing nil
@jotanews1776
@jotanews1776 3 жыл бұрын
i fucking love you homie
@PixelKingStudios
@PixelKingStudios 3 жыл бұрын
Nice video! Very informative 😄
@fusion.studioX
@fusion.studioX 2 ай бұрын
so composition is just a bunch of little inheritances
@nlaps
@nlaps 3 жыл бұрын
Great vid! I'm trying to get my habbit into OOP.
@wifinoob3083
@wifinoob3083 3 жыл бұрын
Love your videos.
@chillblox8
@chillblox8 3 жыл бұрын
holy crap thanku i lov this method
@menoitius5587
@menoitius5587 Жыл бұрын
AWESOME tutorial
@GaLzZy.
@GaLzZy. Жыл бұрын
it is kinda sad that there a no intellisense with OOP approaches in roblox studio :(
@vinicius._mb
@vinicius._mb Ай бұрын
If I wanted to access the base class (Vehicle) from one of its components (Engine, Wheel, etc.), how would I do it? The only way I can think of is by adding a property to one of these components that points to the base class, but that seems wrong for some reason. Is there a better approach?
@goose13378
@goose13378 6 ай бұрын
Tack!
@BRicey
@BRicey 6 ай бұрын
Yeah!
@axelmonogatari3175
@axelmonogatari3175 2 жыл бұрын
Its cool ... but DONT, by any means use ALWAYS composition. There are cases where it doesn't make sense and make you create lots of unnecessary modules. First check if TypeB is a TypeA (B can do all the things that A can, and can be replaced.), if not, then just extract in modules the things that you need from TypeA into TypeB. Also, you can use Both, and that's what I usually do a lot. For example: Vehicle (atributes: Name, color, speed, size) [methods: Move()] Car is a Vehicle(atributes: Engine, Wheels) Engine (Atributes: Capacity) [Methods: TurnOn(), TurnOff()] Wheel (Atributes: Color, size) Wings (Atributes: Color, size) Plane is a Vehicle(atributes: Engine, Wings) Bycicle is a Vehicle (Atributes: Wheels) In this example Vehicle is just an interface or an abstract class but the idea is that it can be upgraded with more unique methods that all vehicles will share.
@yarik_superpro
@yarik_superpro Жыл бұрын
this still very confusing to me,why it overrides itself if i make 2 of them!?Isnt this whole point of OOP!?
@Thzyr
@Thzyr 3 жыл бұрын
Can you make another perlin noise vid cuz its outdated
@BRicey
@BRicey 3 жыл бұрын
What do u mean? I don’t think the api has changed.
@Thzyr
@Thzyr 3 жыл бұрын
@@BRicey maybe try doing the script again i think i got something wrong
@ftgodlygoose4718
@ftgodlygoose4718 3 жыл бұрын
Great video, it really helped me understand. Now all I have to do, is re-code my game from scratch using OOP lol
@BRicey
@BRicey 3 жыл бұрын
just try to integrate your codebase in the future with OOP, I wouldn't rewrite your game rn
@exotic9345
@exotic9345 3 жыл бұрын
Can you make an on screen coordinates system?
@speedyg2295
@speedyg2295 9 ай бұрын
I am using your method to. create apples. But i keep getting new is not a valid member of ModuleScript "ServerScriptService.AppleModScript" - Server - appleTrigScript:2. Which coming from the SSS script called appleTrigScript on line 2 which is only 3 lines: local Apple = script.Parent.AppleModScript local A = Apple.new(workspace.farmQuestModel.AppleModel) A:Drive() Now of course the apple is not going to drive and have tires. But i put in the CFrame to move it there. But i cannot get past the not a valid member of the apple mod script which is put together just like Car in your video. where there is a: function Apple.new(appleModel). Any ideas
@speedyg2295
@speedyg2295 9 ай бұрын
Found it. I was not using Require in statement above
@kidthatcries
@kidthatcries 3 жыл бұрын
Awesome video. Just one question, is there a way to use self object on the base table? Something like this: setmetatable({ using self in this table }, metatable) on the new method
@BRicey
@BRicey 3 жыл бұрын
Sadly, you can't. The workaround is using: local self = setmetatable({}, mt), and then in a line below saying: self.Model = self:MakeModel() or something
@kidthatcries
@kidthatcries 3 жыл бұрын
@@BRicey thanks I'm gonna try that
@audrete6071
@audrete6071 3 жыл бұрын
How do you loop through a string? Like a for loop but instead of looping through a table it loops through a string
@BRicey
@BRicey 3 жыл бұрын
for i = 1, string.len(yourString) do local char = string.char(i) -- do whatever you want with it. end
@audrete6071
@audrete6071 3 жыл бұрын
@@BRicey thank you
@Ryan-ww7un
@Ryan-ww7un 3 жыл бұрын
I see someone watches Arjan Codes :)
@each1teach1
@each1teach1 2 жыл бұрын
Thanks
@niklase.h.jensen2209
@niklase.h.jensen2209 3 жыл бұрын
B ricey do you know how to make tank? If you do please tell me
@BRicey
@BRicey 3 жыл бұрын
I made a crappy one in the past but I’ll do a tutorial on one in the future
@niklase.h.jensen2209
@niklase.h.jensen2209 3 жыл бұрын
Thank you
@hello-uw2qw
@hello-uw2qw Жыл бұрын
Great video! This has helped me understand OOP in a way that no other tutorials could. A question I have, however, is how I would apply this in a practical approach. Let's say I want the car to move forwards when I press 'W', using a LinearVelocity. The thing I am stuck on is: - Detecting key presses is done on the client, so how would I call the server method of 'Drive()' on the client, when you can't pass metatables through a remote event, and sending a remote event from Client > Server isn't viable, as I would be using RunService to detect when W is held, and then increase the speed the longer it is held, and obviously sending a remote event 60 times a second is not good Obviously I am not asking you to write the code for me, but an explanation of how I could go about this would be greatly appreicated. Either way, thank you for the great video!
@BRicey
@BRicey Жыл бұрын
You could just use a proxy method, something on the server that receives the remote event and then runs the appropriate method on the class
@hello-uw2qw
@hello-uw2qw Жыл бұрын
@BRicey That's gonna cause loads of lag firing it 60 times a second, it needs to be done on the client. Atm I just don't use OOP for the client, and tbf it works fine but if I want to expand the code base its gonna be difficult
@BRicey
@BRicey Жыл бұрын
Yeah I wouldn’t fire it every second, only fire it for when it changes direction
@hello-uw2qw
@hello-uw2qw Жыл бұрын
@@BRicey i think changing it on the client is the best approach, due to the fact that tye client has network ownership so it would be lag free
@BRicey
@BRicey Жыл бұрын
@@hello-uw2qw yeah
@gabrielhallai9905
@gabrielhallai9905 2 жыл бұрын
Hello hello
@eduardomattos1561
@eduardomattos1561 3 жыл бұрын
Chunk minecraft in roblox plss ;c
@my_beautifulnoob2889
@my_beautifulnoob2889 3 жыл бұрын
E
@Revoltition
@Revoltition Жыл бұрын
can you please explain it further for me? i get how it works but i don't really get why you would need to use it and in what cases should you do so
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 997 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
What is Object Oriented Progamming?
13:27
GnomeCode
Рет қаралды 48 М.
What is the self keyword in Lua? - Roblox Studio
7:59
B Ricey
Рет қаралды 29 М.
The Entire History Of Roblox Tycoons
26:41
Founder
Рет қаралды 357 М.
Making a Game in Lua with No Experience
5:52
Goodgis
Рет қаралды 388 М.
METATABLES | What are they and how can we use them?
18:40
Crusherfire
Рет қаралды 30 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 796 М.
Fixing Lua OOP
10:27
sleitnick
Рет қаралды 30 М.
I Optimised My Game Engine Up To 12000 FPS
11:58
Vercidium
Рет қаралды 812 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН