Object Oriented Programming

So I guess you could say I am kind of new to object oriented programming, but the thing is I really want to start using it and applying it to my code but I don’t exactly know whereto start with it

What are you asking? What it is or how to apply it? For the former there is a tutorial on it.

For the latter, please, don’t force use cases for things that will probably overly complicate your code for no real reason. The paradigm sounds cool and all but you won’t be needing it as much as you think.

1 Like

Alright sounds good, but I’ve read that thread, I just want to start using it everywhere as I code, and I dont know where to start

You don’t need it everywhere. What is your use case for OOP?

1 Like

Its not that I dont need it, its that I want to use it everywhere, I dont want to mix procedural code with OOP code doesnt make any sense, and my use case is just to be as efficient as I can be

OOP isn’t any more efficient. OOP, like any other paradigm, is a tool. OOP isn’t always the right tool for the job.

Hmm, what Ive read about it makes it seem like some insane paradigm that should always be used and it looks really cool too, I just would like to use it more

It shouldn’t always be used. It is a bit overrated on Roblox. You also have yet to give a use case for wanting to use it so I can help you further. Based on your replies you only want to use it just for the sake of using it to look cool.

You’re still able to write good code without OOP.

No I dont want to use it just because it looks cool, it just seems like the cleaner option between itself and procedural code

Im a person who tends to lose focus when stuff gets too cluttered and I think OOP could really help me

OOP is not any cleaner than a procedural approach. Most Roblox-user implementations of OOP I’ve seen are actually much uglier and contain tons of indirection. If you want to learn OOP because it “looks cleaner,” then you already have an issue with organizing your code that a different paradigm won’t solve.

1 Like

if you want your code to be shorter then make use of module scripts. OOP should only be used for things you intend on using multiple times throughout your code. For example, a maid class for cleaning up connections. Some people are against the use of modules in the case where they are only required once, but I advocate for it because it allows for a single point of entry into the system and you can ensure that things are loaded in a particular order.

Similarly to what @Autterfly said, OOP is only used when a class makes things easier. OOP is only good for organizing code when you need to make custom classes. Not everything needs a custom class.

Additionally, I find that where people think OOP is necessary, it actually isn’t. If you want to organize your code better, I recommend using ModuleScripts and requiring them as necessary. For instance: a utility module script, a ui creation ModuleScript.

Unless you need something which, as an object, needs to contain personal methods which have to do with that object, do not use OOP.

1 Like