Repository navigation
Conversation
|
I haven't run this yet, but having a look over the code, here are my initial thoughts. All of this is meant as constructive criticism in order to make the best public API and most maintainable library we can have while solving the problems this is meant to address. I will run it now and see what else I can learn & understand about the design.
I will keep digging, because I don't totally understand the wins with this approach yet (though I'm sure they are there). I'm not sure that offsets the above but happy to be proven wrong / enlightened. |
|
To put 90% of my concerns another way, consider what the documentation to these new classes would look like, even at a narrative level ("The standard delegate is for foo. Simplestyle is blah, and the simplestyle delegate is for bar" etc. Then consider the primary use case for the library, which is to bring easy |
|
Minor feedback / probing question: what happens when |
|
Love how well this handles the example cases, and the style of the testing app for showing that. Big win towards #47. |
|
@incanus Cool. First off, I'd recommend that you run the code to calibrate your sense of how well these ideas work. I'm expecting you'll be favorably impressed. This is a pretty radical take on changing how MBXMapKit works, but I think it's justified by the results on screen. Without getting too deep into all those points, a potentially useful idea is that I did a lot of stuff based on
The concept of these three delegate protocols is probably the key to unlocking my way of thinking about the issue61 branch:
Those protocols fix the tileJSON problems from #36.
My goal was to provide a less restrictive way of implementing the delegate proxying functionality without requiring a bunch of boilerplate in people's view controllers. By less restrictive, I mean all someone needs to do for implementing alternate behaviors is make a view controller like and then implement those protocols, and do whatever they want. They could also subclass |
|
Cool. As I just commented, I love the demo. Maybe I need to chew on it. Will keep digging. |
|
Dunno if you saw my edit, but point number 4 is also a huge goal... it's possible to do really slick stuff with MKMapKit, but it requires you to do things skillfully at the view controller level in a way that matches your visual intent. We don't know what people's intent will be, so trying to make assumptions in code is probably going to be counterproductive. However, we can demonstrate ways of realizing various intents in the sample app. The desire to teach effective practices is a key reason why I'm in favor of having the view controller / app delegate be more complicated (but not cluttered up with boilerplate). |
|
Also, I'm expecting that the whole MBXCacheManager thing will need to be gutted and re-implemented along the lines of #67 (comment). |
MKMapView already provides the means to manipulate layers. Obviously not everybody knows about that, but I think education (sample apps, docs, links, etc ) is probably the best way to approach that lack of understanding. Also, see @boundsj's comment about this: #24 (comment) |
Yes, that's every bit as bad as you describe, and it needs to change. It's there as a temporary expedient with the significant benefit being that it performs well for testing purposes and I didn't have to spend any time thinking about it while I was working on other more challenging aspects of the design. My intention is to re-implement the network code with something which is based on NSURLCache, assuming that we decide to go forward with this general approach to re-factoring.
My thinking on this is that the current implementation needs to go away and get replaced with something that uses NSURLCache. In that case, NSURLCache would be responsible for such things on its own.
Not to my way of looking at it, because that code only gets called if the developer explicitly chooses to set an MBXStandardDelegate as the delegate for their edit: The whole MBXStandardDelegate thing could be avoided by copying and pasting the contents of MBXStandardDelegate.m into the Mac demo app's app delegate and the iOS app's view controller. That has the disadvantages of duplicating code and requiring boilerplate in view controllers, but perhaps that is a lesser evil than the potential to confuse people about why MBXStandardDelegate exists. |
|
We can discuss more on voice, but have you considered simplifying all of the multiple delegate stuff by moving to a completion block pattern, much like Apple's frameworks like |
Like we talked about, no, I haven't really considered that. However, one thing I really like about the delegate approach is that it's possible to break The example I mentioned earlier was, say an app tries to load a mapID with TileJSON that centers the map on Washington DC, and for some reason that connection takes a long time. Suppose that in the mean time, the person running the app gets impatient and switches to a map of Los Angeles (which loads immediately). What happens if the completion block for the first map tries to center the MKMapView on Washington DC 15 seconds after the person running the app has started scrolling around Los Angeles? The existing code in my demo app will fully disconnect the first tile overlay layer, so that it's not possible for it to interfere with the MKMapView once it has been removed. Any other mechanism which supports that same capability without adding any significant additional complexity would be perfectly acceptable as far as I'm concerned. |
|
Ok, I've spent some quality time with the branch and have much more substantive feedback over my last round. I will note upfront that, like before, I do focus a bit more on the public API (though not at the expense of the actual workings), but here's why. When compared to Apple's default toolkit, IMHO we need every detail sweated on the API side to compare favorably to their free alternative. You should be able to glean 50% or more of the usage just from scanning the headers and/or header-based docs. This comes across in method names, argument wording, various and designated initializers, and protocol methods, not to mention the volume of public API. We will have detailed docs, guides, sample apps, etc., but we have to make things as frictionless, as well as Apple-like, as we can, despite working with different constraints (styling options, server-based configuration, increased flexibility). So I put a great deal of value into these first impressions by way of API "self-documentation". It should be every bit as carefully considered as the inner workings of the classes. On the functionality side, now that I've spent some time with this refactor, I greatly appreciate the planning, foresight, and overall elegance of the refactor. And I can see how the goal of leaving Larger stuff
Smaller stuff
Minor stuff
|
|
@incanus I like that. It will take a while to digest all of that, but my first impression is, this is good:
and specific suggestions like
are very helpful. My experience with C goes back to about 1995, while my experience with Apple API's goes back to late 2012, so it's a lot easier for me to make things function well than to know what someone who has spent years in Cocoa would expect them to be called. I agree that nailing both of those things is important. |
|
Some further thoughts...
I think it's important to make the distinction between a) conventions which are useful for working around bugs in MKMapKit at the view controller level, and b) things which implement the internals of the MXMapKit API. To my mind, the whole setting the delegate to nil thing falls mostly into the first category as it is intended to address more or less the same crashing issue which is discussed at #26 and #31. We never came up with a very satisfactory solution to that: #26 (comment). As such, the goal in my mind isn't so much to "cancel" anything. Rather the objective is to do what's necessary to avoid bugs in MKMapKit which can crash the app or produce serious visual glitches. That said, I will spend some more time looking for alternative approaches. I think we may have no choice but to do some kinda ugly stuff in order to avoid bugs, but I think there is also potentially a lot of room for making things cleaner and clearer.
I think the whole caching system needs to be re-worked to be based on an NSURLCache performance cache alongside of a new class which provides persistent offline storage for map tiles. It should be possible for |
|
This all sounds pretty good.
Just keep in mind that the biggest win we have with this project over the SDK is really simple configuration, which we want to continue. |
Yeah, I think that would happen with what I have in mind. I need to see what the code looks like once I start playing with it, but I'm imagining the existing surface area of the API in my issue61 branch getting drastically reduced as a consequence of incorporating NSURLCache. |
|
Ayup. |
Just opening an official pull for @wsnook's
issue61branch as a possible way to fix #61.