Posts

Post not yet marked as solved
0 Replies
862 Views
Given that I have a function that does not need to share and store state; should I use a static class/struct/enum to hold the function? I have read in many places that it is a bad design to use static functions to hold code, as static function do not adhere to the SOLID principles and are considered procedural code. Testability seems to be there as I can isolate the parent class with the injected static Enums by injecting mock static enums. E.g. I can encapsulate and have polymorphism by using protocols for static functions: Static Protocol Approach enum StaticEnum: TestProtocol { static func staticMethod() { print("hello") } } enum StaticEnum2: TestProtocol { static func staticMethod() { print("hello2") } } protocol TestProtocol { static func staticMethod() } class TestClass { let staticTypes: [TestProtocol.Type] init (staticTypes: [TestProtocol.Type]) { self.staticTypes = staticTypes } } class TestFactory { func makeTestClass() -> TestClass { return TestClass(staticTypes: [StaticEnum.self, StaticEnum2.self]) } } vs Object Oriented Approach class InstanceClass: TestProtocol { func staticMethod() { print("hello") } } class InstanceClass2: TestProtocol { func staticMethod() { print("hello2") } } protocol TestProtocol { func staticMethod() } class TestClass { let instances: [TestProtocol] init (instances: [TestProtocol]) { self.instances = instances } } class TestFactory { func makeTestClass() -> TestClass { return TestClass(instances: [InstanceClass(), InstanceClass2()]) } } The static version still allows for protocol polymorphism as you can have multiple enums adhere to the static protocols. Furthermore no initialisation is needed after the first dispatch call to create the static function. Is there any drawback in using the Static Protocol approach?
Posted
by Reckoned.
Last updated
.
Post not yet marked as solved
2 Replies
2.0k Views
I would like to know if what is meant by " geo-restricted to those locations" for gambling app. from guideline 5.3.4. Is it sufficient for the app to only be placed in that countries appstore or do I have to make sure the app from the location of the user or ip cannot run the app?5.3.4 Apps that offer real money gaming (e.g. sports betting, poker, casino games, horse racing) or lotteries must have necessary licensing and permissions in the locations where the App is used, must be geo-restricted to those locations, and must be free on the App Store. Illegal gambling aids, including card counters, are not permitted on the App Store. Lottery apps must have consideration, chance, and a prize.
Posted
by Reckoned.
Last updated
.