1
\$\begingroup\$

The full project is up on GitHub. The codebase is super small as it stands.

I'm brand new to reactive programming and Spring, and would mostly like insight on those two things. Asynchronous programming is also one of my weak points, because I'm really used to synchronous program structure - hence the need for help with reactive programming.

Here's a few snippets to start off with, for my specific concerns:

@Repository
public interface GuildMetaRepository extends CrudRepository<GuildMeta, Long> {
    ...
    @Override
    @Cacheable(value = "guilds", key = "#p0")
    Optional<GuildMeta> findById(Long id);
    ...
    @Override
    @CacheEvict(value = "guilds", key = "#p0.id")
    void delete(GuildMeta guild);
}

Spring caching for Repository implementations confuses me a little - is this working as I expect? Should I be using @CachePut in place of @Cacheable?

class CommandRegistry {
    ...
    CommandRegistry() throws ReflectiveOperationException {
        ...
        /* not shown: find all Command implementations with Reflections */
        ...
        // Construct an instance of each module
        for (Class<? extends Command> module : modules) {
            instantiated.add(module.newInstance());
        }
    }
    ...
}

You might need the full context of the command package for this one. Basically, Command is the abstract class that all my command modules extend from, and it has an instance variable for the command name that subclasses call super(name, ...) to identify themselves with. Since it's an instance variable, though, I need to keep an instance of each module available in a List<Command> to check against command names in chat.

That probably didn't make it much clearer, but I did my best. Like I said, there's more context to be had here. The general design pattern I have here is sub-par in my opinion, and I don't really have any ideas on how to fix it. There have definitely been some improvements over the first iteration, though; that was far messier.

I'd love to get some feedback here, whether it's on the snippets or on other code in the project - if you see a problem, hit me with it. Pull requests are always wide open as well if you feel like contributing. Thanks!

\$\endgroup\$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.