Skip to main content

Timeline for JSON parsing service

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Nov 27, 2020 at 8:55 history edited Martin R CC BY-SA 4.0
added 196 characters in body
Nov 17, 2020 at 10:38 comment added Martin R @Shadowrun: Defining your own type or extending an existing type both have advantages. The advantage of your own type/namespace is that you cannot have conflicts with definitions in other modules or with future extensions of the exiting type.
Nov 17, 2020 at 10:32 comment added Martin R @Shadowrun: You are completely right, an enum is sufficient and perhaps preferable if you only want a namespace (this was also discussed on Stack Overflow: stackoverflow.com/q/38585344/1187415).
Nov 17, 2020 at 10:28 comment added Shadowrun If a struct has only static methods, you could argue that it shouldn't be possible to instantiate such a struct with let foo = JSONService(). One way to prevent that is to make it an enum with no cases and only static methods. Another idea would be to avoid having a type at all, which means you also don't need to worry about naming it FooService/FooHelper/FooSomething. By making an extension on Decodable: extension Decodable { init(from fileName: String) { ... self = try JSONDecoder().decode(Self.self, from: data) ...
Nov 16, 2020 at 19:37 history edited Martin R CC BY-SA 4.0
added 135 characters in body
Nov 16, 2020 at 19:25 history edited Martin R CC BY-SA 4.0
added 200 characters in body
Nov 16, 2020 at 19:15 history answered Martin R CC BY-SA 4.0