You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the App class of the abstract-factory pattern, there are several methods which seemingly only serve to confuse readers.
Is there a point to having a method that returns a King, from a passed in KingdomFactory?
King getKing(final KingdomFactory factory) {
return factory.createKing();
}
The text was updated successfully, but these errors were encountered:
Apparently the method you mentioned is used in the tests. If you have a vision how to make the example clearer I would be glad to accept the pull request.
One way I think that would make sense, is to alter the test. The test would instead of creating 2 factories and then testing those factories with a method never actually used (and which isn't obviously useful), the test would create the 2 factories, and then create 2 versions of App, calling createKingdom for each factory, and doing the tests like assertTrue(app1.getKing() instanceof ElfKing);
One other option would be to use a singular app instance and do all the tests for a particular kingdom first, then call createKingdom for the other type. Would appreciate input as to which would be more clear. I'd be happy to update it either way, and then remove the static methods from the app class.
In the App class of the abstract-factory pattern, there are several methods which seemingly only serve to confuse readers.
Is there a point to having a method that returns a King, from a passed in KingdomFactory?
The text was updated successfully, but these errors were encountered: