I have a state-machine-like class with a single pu...
# announcements
m
I have a state-machine-like class with a single public method that takes a command interface and dispatches work to a bunch of private methods (actually private extension functions of that class right now, but it doesn't matter). As the amount of commands grow, also grows the file containing this class. If package 📦 protected scope was implemented in Kotlin K, I would be happy to put that class in a separate package from everything else (especially tests), make all the private extensions package 📦 protected and put them in a couple different files, grouped by commands that commonly call other private extensions for subsets of their required actions. How would you aproach this i Kotlin K without package 📦 protected scope? Note I want all my tests to see only that public method and not autocomplete private stuff as I have other extension methods in tests that call this public method to easily setup this state machine. Slack Conversation
g
I'm having a bit of trouble visualizing this, can you put together a gist? Are you ware of the
internal
visibility modifier?
m
@groostav Internal works across modules. I have a single module. If you really wish to have a look, I can give you access to private repo.
Basically a class with one public method containing switch / when and each case calling a private method. With package protected I could put those private methods into separate files as extension functions. In Java I could wrap them in package protected classes, achiving something similar.
This would result in these private functions not being visible anywhere outside of from each other and from that public class with single public method.