My first ever Maid module ive created(OUTDATED UPDATE SOON)

Hello hello everybody :D!! recently i wanted to give a shot at creating my own maid module since my oop skills have improved a lot since last year. Today im here to announce that its finally done :smiley: . Its completley free to use. You dont have to credit me or anything. All i ask is that you tell me if you find any bugs or anything that you think could be improved. All feedback is appreciated and helps out a lot (: !!

Heres the instructions on how to use it(Theyre also inside the module)

Should also point it out before someone does. I didnt know what to call the thing Maid:GiveTask() returns(Object). I was going to name it Class but im not sure if thats the right word for it.

Module link: Maid - Roblox

3 Likes

Source code please?

I don’t see a use for this over other maid
Modules.

2 Likes

You might want to call it something other than Maid to avoid confusion. For example, alternatives to the Maid module call themselves Janitor and Dumpster.

Sorry for the confusion. I meant that usually modules that are open sourced have unique names so there isn’t confusion between them. Just a suggestion though, it really isn’t that important. For personal projects you should just name things whatever is most convenient to you as @Tomarty mentioned.

Some example names might be cleaner, bin, can, trash, trunk, etc.

Class is the right word for that. A class is something like Maid (uppercase). Not to be confused with an instance of a class, which is something like Maid.new(). (Another example, in the code local newMaid = Maid.new(), newMaid is an instance of the class Maid.)

2 Likes

Would janitor be a better name?

No because there’s already a module named that. Come up with something original.

recently I wanted to give a shot at creating my own maid module since my oop skills have improved a lot since last year.

Apparently, nobody can give resources now. How else will you learn to do something, if you only use other people’s modules, then?

Plus, the source code is inside the module he has given (don’t understand why it’s private though)

I see no reason to use anything else. Maid is a great name that’s simple and ergonomic. For my project I somehow ended up calling mine “Cns” (short for “connections”.) I’ve considered renaming it to “Maid” but it hasn’t been a problem for my codebase. I type it thousands of times and it works.

At first I didn’t really use a class for it:

-- Create
local cns = {}

-- Add things that need to be cleaned
table.insert(cns, function()
    part:Destroy()
    connection:Disconnect()
    -- etc.
end)

-- Clean it up
for i = #cns, 1, -1 do
    cns[i]()
end

I have a pretty involved compile process for my project that can do tokenization and inter-module constant-folding/function-inlining, so now I use static methods:

-- '_R' is just part of my module loader defined at the top with dependencies.

-- Create.
local cns = _R.Cns.new(1) -- '1' is the preallocation amount. It compiles to use table.create.

-- Add things that need to be cleaned. This simplifies to table.insert.
_R.Cns.Add(cns, function()
    part:Destroy()
    connection:Disconnect()
    -- etc.
end)

-- Prevent adding new things by accident.
_R.Cns.Lock(cns)

-- Unlock when used with Lock, is useful for locking an object while creating a new one. I often have deeply nested connections and this prevents 99% of scope-related problems.
_R.Cns.Unlock(cns)

-- Clean it up. This simplifies to the same code as the other example.
_R.Cns.Call(cns)
3 Likes

Shoot sorry! turns out i had by accident made it private sorry. Should be free now :slight_smile:

1 Like

Please elaborate. I don’t get what you mean by this.