#How do you separate responsibilities in a Roblox system architecture?

1 messages · Page 1 of 1 (latest)

nimble panther
#

Hello, recently I started learning system-oriented scripting, but there are still some things I don’t fully understand yet. I’m trying to structure my code properly but I’m unsure how to separate responsibilities between modules.

For example, I have an OOP Block object with methods like UpdatePosition(). I also created a GridService that converts world positions into grid positions and helps snapping things to a grid.

My questions are:

-Should I have a separate module responsible for creating blocks (like a BlockFactory or BlockService)?
-Should another module be responsible for moving blocks?
-Or should the Block object itself handle movement logic using the GridService?

Right now I’m also unsure about the correct responsibility split. For example: My GridService can convert world position to grid position, but should it also be used directly by a system that moves blocks, or should there be another layer (like a movement/placement system) that uses the grid service and then tells the blocks where to move?

Basically, I’m trying to understand how to -properly separate:
creation of blocks
-movement/placement logic
-grid conversion logic and the block object itself

If anyone has examples, architecture explanations, or even a small system breakdown that could help me understand how to structure this properly, I would really appreciate it

fickle bolt
#

dont overcomplicate things

#

if you dont need it, you dont need it

#

why create a whole service just for 1 method

nimble panther
# fickle bolt dont overcomplicate things

Hey, thanks for your message.

The reason I structured things this way is because at first I tried splitting everything into around 4 modules, but they quickly became dependent on each other and it became very hard to maintain.

GridService is a global service because it’s used in multiple places across my project.

My system also has several modes:

-an edit mode, where I can modify the world and place blocks
-an execute mode, where blocks are run using their Start() method
-a none mode (when in the menu)
-and an erase mode, where blocks can be removed

The problem is that it quickly turned into something overly complex each module depended on the others, and making changes became really difficult.
What I ended up doing was trying to create one module per responsibility. However, aside from GridService, the other “services” I mentioned are only used internally by my system nothing else in the game interacts with them or needs access to them.
At this point, I feel like I mainly need a clearer structure to understand how to separate things properly.

An example of a clean architecture or system breakdown would really help me.

#

About OOP Roblox does support it through metatables, and in my case I need it for maintainability.

I have multiple block types with different behaviors, but they all share a common base (like EnterPreviewMode() or ShowHitbox()). Even a simple block already has around 15 methods.
Without OOP, each block type would be large, repetitive, and hard to maintain.
So I created a BaseBlock class with shared logic, and each specific block inherits from it and only implements its own behavior. This way, adding new behaviors doesn’t require rewriting everything I just extend the base class.

distant matrixBOT
#

studio** You are now Level 1! **studio

loud crow
#

Performance overhead of metatables is negligible in most cases and i think it's just a matter of preference to use them or not

turbid raven
#

metatables reduce memory usage ;o

nimble panther
#

You are talking about a different domain

nimble panther
turbid raven
#

at a point it may be worth switching to a different technique

#

or just do things directly like module.dostuff(object) instead of object:dostuff() to save the whole detour

nimble panther
#

Right ?

#

I see that you're experienced in scripting have you ever worked with system-oriented scripting?

turbid raven
nimble panther
turbid raven
nimble panther
#

I’m trying to learn it, but I’m still struggling to figure out how to properly organize my code. It does seem like it’s more maintainable for large-scale systems though

turbid raven
#

oh

#

i think you're talking about that 'turn-everything-into-a-service' pattern that i've seen people use

#

that thing is really stupid imo

#

but eh it can do a lot of heavy lifting just by following simple pattern

#

so i get why its used

#

but not good enough for what i want to make

nimble panther
distant matrixBOT
#

studio** You are now Level 2! **studio

turbid raven
#

idk try a few things and figure out different ways to do it, so then you can evaluate the pros and cons yourself?

nimble panther
turbid raven
# nimble panther Hello, recently I started learning system-oriented scripting, but there are stil...

i stopped reading after "Should I" because if you ask me, in my opinion, what I think you Should do, is give everyone in this thread all your robux. but that's just what I think you should do.
Setting aside what i just told you to do:

try a few things and figure out different ways to do it, so then you can evaluate the pros and cons yourself?
But hey what do I know, I'm not your mom and you can make your own decisions epic

nimble panther
turbid raven
#

also google some tutorials, game templates etc, roblox has lots of templates

#

simulator template

#

make stuff

#

etc

#

it takes work and no one can do the learning part for you

turbid raven