#Best practice for long function signatures ?

1 messages · Page 1 of 1 (latest)

hard shell
#

Hello, quick style question about formatting function parameters. When you have a function with many typed parameters, what's the best "official" practice / Visual ?

local function CleanupMenu(PairedMicrophonePlayer: Player?, PairedMicrophoneID: string, PairedMicrophoneIndex: number,
    MicrophoneIndex: number, Player: Player, Character: Model?, Humanoid: Humanoid?, HumanoidRootPart: BasePart?
): ()

I saw that some use 1 line for each so idk

strange merlin
#

Why can it derive it itself from the given player?

#

It surely doesn't need the player's character, humanoid, and humanoid root part

hard shell
#

It's to avoid recalculating the character when sending it, in some places where I call it, it's already calculated, in others it isn't

strange merlin
#

Function's shouldn't be hyperaware of their call site

#

Most of the time, they can be called in several places with different contexts

#

At most, if you trust certain children and properties will be valid, you can avoid FFC/WFC calls and checks

#

Think of it like RaycastParams

hard shell
#

Fair point, but there's a specific reason, the function needs the original Character reference to detect if the player respawned during execution. If I recalculate Character inside the function, I lose the ability to compare it with the current Player.Character. Some callers already have Character/Humanoid from earlier validation, others don't. Passing them avoids redundant lookups when they're already available. It's not just about avoiding FindFirstChild, it's about maintaining the reference for comparison

harsh bough
#

i do that