Closed mangstadt closed 9 years ago
Great, but I have no clue what most of the new context stuff does. I'll take a better look when I'm home.
It's basically an alternative to singletons. Instead of making classes like BotConfig singletons (which are more difficult to unit test), we create one instance of BotConfig and store it in AppContext (which is a singleton). Then, to retrieve our BotConfig instance, we simply get it from AppContext like so:
private static final BotConfig config = AppContext.INSTANCE.get(BotConfig.class);
It's basically a way to make certain objects globally-accessible.
So we don't have to make BotConfig a singleton because AppContext is storing it.
On Wednesday, November 26, 2014, Unihedron notifications@github.com wrote:
Great, but I have no clue what most of the new context stuff does. I'll take a better look when I'm home.
— Reply to this email directly or view it on GitHub https://github.com/Vincentyification/JavaBot/pull/20#issuecomment-64516075 .
Mike Angstadt Assistant Electronic Resources Librarian, Computer Lab Montgomery County-Norristown Public Library 1001 Powell Street | Norristown, PA 19401 610-278-5100 x141 www.mc-npl.org Like us on Facebook http://www.facebook.com/mcnplonline
Any views or opinions expressed in this e-mail are those of the sender and not necessarily coincide with those of the organization.The information in this email is confidential. The contents may not be disclosed or used by anyone other than the addressee. If you are not the intended recipient, please notify us immediately at the above address.
Recommending merge
Merging this since @Vogel612 recommends it.
BotConfig now reads its data from a "Properties" object. Also, it's no longer a singleton, though it is still treated as such. This makes it easier to unit test.
I also added the "AppContext" class for storing objects that are used throughout the application. BotConfig is stored in this object, since it is accessed in many different places thoughout the codebase.
And I added a "ROOMS" property to BotConfig, so you can define which room(s) you want the bot to join.