#This was meant to be VisualEffect class but...

1 messages · Page 1 of 1 (latest)

civic kayak
#

I have a problem with classifying/naming class that I've written. Initially, it was supposed to be a base class for visual effects, so VisualEffect seems obvious, but not entirely.

This class is so abstract that it can be used for many other things. The closest fit seems to be either process or task.

State:

Limiter - determines the object's duration, can be a counter, timer, or signal.

Update - method of performing updates (in steps with time intervals, via signal, or reading from the given update function, which will return whether a modifier should be applied),

Union/Variant:
signal we wait for to update (we'll receive a modifier in the signal),

pointer to a function from which we'll know when the next update will take place and what modifier to apply now,

predefined constant steps (number of steps and time interval between each of them) for using modifiers defined by default,

predefined time intervals with modifiers for each of them.

Pause - whether the object is temporarily paused or not,

Activity - whether the object has started or is already in the process of stopping,

Keep alive - whether, after the limiter signals that the duration has ended, we leave the object alive or delete it,

Validity - whether the object was correctly created (may change during execution if, for example, the method that updated the object suddenly returns incorrect modifiers),

Initialization method callable - it is called at startup, should restore the object to the expected state, an important element in repetitions.

Functionalities:

Start,
Update,
Pause,
Resume,
Restart,
Stop,
Finish,

Additionally:

Die,
Finish repetitions,
Set a new limit,
Change the method of updating/initialization.

ChatGPT suggested the name Task or Process. I also add Base, Framework, Controller, Executor, Handler, and other nonsense. Does Task fit here? How would you name such a base class?

vocal eagle
#

Seems like it does a lot. Is everything used by derived classes? Could you break it down into individual classes or utilities (and thus SRP), available for mixins? Naming things can be a tough (one of the classic 3 programming problems!) and if nothing is obvious, it could mean a design issue. Feels like a static utility class?

civic kayak
civic kayak
#

It's abstract class and I believe that it serves single purpose.

#

To be initialized, updated with ability to stop it, pause, resume and finish execution completely.

#

Modifiers are also typed and type is classification for modifier that is given on creation. During creation it's validated and if it fails, type is invalid. This way you ensure that modifiers apply to specific process update.

#
VisualEffects.add(self, FadeVfx.new([2.0, 40], Color(randf_range(0, 1), randf_range(0, 1), randf_range(0, 1), 1)), 60.0)```

Add new visual effect to yourself (as owner), visual effect being FadeVfs. It's cycle is 2 seconds, it has 40 steps which means that time between updates is 0.05s. 

Vfx setting is color it's going to fade to which is chosen randomly but it's visible. 

60 seconds is lifetime of whole effect.

Lets say that changing from color A to B will take 2 seconds in 40 steps, updated each 0.05 seconds, in 60 seconds we will perform 30 repetitions/full cycles of this effect. Then it will be removed/freed.