-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renaming, Reorganization, PrimitiveObjectStore, new ParseEncoder #13
Conversation
@pranjalsatija I skimmed this and it lgtm so far. Just to let you know, we are working in parallel, I'm adding the unit testing in for Object, User, and login which all need URLMocking, so I'm adding that too. I'll try to finish it before yours so we can use it verify your changes keeps everything intact. My guess is we will touch very few if any of the same files, but will need to switch the unit tests I add over to ParseObject, etc. |
Simple storage is done, but not tested yet. I'll wait on @cbaker6's tests to land before I write any new ones so we don't step on each other's toes. Also, while I'm doing cleanup / reorg stuff, a few more things than originally planned come to mind. @cbaker6 @TomWFox or anyone else, I'd like your thoughts:
|
I would say equality should be determined solely by object ID. That's the purpose of an "identifier". How are the Parse Android / JS SDK comparing, for consistency?
Makes sense. I think an important factor here is performance, whatever the solution is, especially when it comes to large objects / arrays with thousands of entries. In Parse Server, JSON encoding in the storage adapter is a significant bottleneck.
Could we use it to reduce our LOC? I don't think a 0 dependency SDK is a goal to strive for per se if a dependency can be expected to be well maintained in the future and it reduces our code. |
@pranjalsatija I'm still working on the tests. I hope to have them done soon. Below is my input on some of the things you brought up:
I think it matters how parse and the other SDKs handle this. I agree with @mtrezza response and we can check the obj-c framework as well
I don't think we should be in a rush to remove this as it's not hurting anything right now. AnyCodable gives us the ability to do [Any] and since we are working with JSON this can definitely be valuable. If at some point in the future we find we don't need it, then I think we can remove it, but LOC for this I don't believe is an issue.
I agree here, but sometimes it may lead to more development time and a dependency may be optimized for the specific thing it's designed for. @mtrezza I believe what @pranjalsatija is referring to is a comment from Flo which said something along the lines with 0 dependencies. As we've seen with the obj-c framework, the Bolts dependency became a major hurdle. Flo pointed out that
I don't believe
I haven't looked into ParseEncoder in a way of thinking of optimizing it, but merely to get everything up to spec. I also "assumed" that it worked from the manual tests. I do know Flo cited the JSON encoder for the ParseEncoder design. I don't think he intended to keep it fully aligned with the JSONEncoder, but merely "Parsify" what was there. I do think it makes sense to improve code, but I think we should establish some barriers before we attempt to make major changes. For example, there's no test cases around ParseEncoder and some of the other parts of the framework. IMO if we want to make a major change in the early stages of framework, we should write the unit tests for the current working cases (maybe some of the unit tests show the limitations of the current) and then write the new version and run those same tests against the new version. By doing major overhauls without unit tests we can run into big problems with breaking code |
I looked at
I agree. I'll do what @cbaker6 said and write some unit tests for the current
@cbaker6 mentioned this, but the original idea was that relying on Bolts and other stuff ended up becoming a problem later on. I don't personally see where / how we could use |
@pranjalsatija a quick note about |
@cbaker6 There's a lot of overlap in what you and @mtrezza said, so I'll just address a few of the things you mentioned:
That's fine with me. We can leave it in until we have a release, then evaluate whether or not we're using it and decide later.
This makes a lot of sense. We can adapt them however we need to, and again, if we find we don't need them after building out some functionality, we can get rid of them then. As for
I'll write some tests for it. Should I wait until after your tests are up? Regardless, I'll test it and include benchmarks so we can compare the 2 implementations. In the mean time, I was able to cut down on some duplication by reusing some stuff from public typealias DataEncodingStrategy = JSONEncoder.DataEncodingStrategy
public typealias DateEncodingStrategy = JSONEncoder.DateEncodingStrategy
public typealias OutputFormatting = JSONEncoder.OutputFormatting
public typealias NonConformingFloatEncodingStrategy = JSONEncoder.NonConformingFloatEncodingStrategy |
I think our positions are |
@mtrezza Sweet! Just to clarify with you and @cbaker6, we're OK with removing the Just to recap, this is what I plan on doing next and including in this PR (we really need a board or some other way to track / assign tasks):
|
Not sure about that, as I said before, how does the Parse Android / JS SDK handle this, so we can be consistent? Edit: I just checked in the Android SDK, |
JS has an Android and ObjC do more or less what I'm proposing:
I think having a Edit: |
I like it, plus we have consistency with the Parse Android SDK. |
The progress on tests is awesome! As for testing |
What are your thoughts on the ParseEncoder tests? From a coverage standpoint it’s at 53%. If you look at the file in Xcode it should show what parts aren’t being covered |
Here's what the report is showing as untested: ParseEncoder
_ParseEncoderKeyedEncodingContainer
_ParseEncoderSingleValueEncodingContainer
_ParseEncoderUnkeyedEncodingContainer
I'll add tests for the parts that make sense. It should get us well beyond 53% but not quite 100%. |
@pranjalsatija if you can get 100, that would be great, but don't feel like that "has" to be the case. For now, covering the important areas that will know will be used is most important. Based on what you mentioned, in some of those cases I think you can simply test the failure case in your test, though I never tested a fatalError directly, I assume there should be an XCTAssert that can catch it if needed. |
Why would that be an issue? Is there a discussion somewhere about the minimal iOS version this SDK should support? I guess that would be interesting. As far as I can see, when you look at the actual devices compatibility, almost every devices that are using iOS 12 can update to iOS13. |
Making this SDK modern is a fair point. One can argue if someone needs a Parse SDK that works on older devices they should use the Obj-C SDK which seems reasonable. This would allow this one to switch to iOS 13 and up. I don't know if there's an actual performance gain unless you are talking about devices that can run iOS 13+ are automatically faster than those that can't. There are somethings that be handled in a modernized way using Combine... There was no direct discussion I've seen about this topic except that the Xcode project was made with iOS 8+. I can see people beginning to design there apps with the Swift SDK start complaining they need a lower device target, but I can see this be less frequent than most and as I mentioned we can recommend they use the Obj-C SDK. My last tidbit is that we currently have it working with iOS 8+ and don't require anything in iOS 13+ so far. The only two possible things I've seen that we can use (but not require) is Identifiable and Combine. I'm sure there will be others in the future, but right now the SDK is flexible across devices. |
These numbers are subjective. iOS adoption stats really depend on region, demographic and audience. We should especially consider developing countries where adoption and device distribution can be significantly different from a - say European or North American market. For example iOS <13.x adoption can be >12% in some West Asian countries. So I agree that keeping a low minimum target should be preferred if increasing the target version would just be for coding aesthetics and not introduce any technological advancement. |
@mtrezza true. |
But, we (Parse) have two maintained frameworks. There's nothing wrong with the obj-c SDK and it currently has more features and is battle tested. Developers needing older devices can use that one. If we decide now that the Swift one will be iOS13+ (iOS 13 seems to be a good bifurcation point) we shouldn't have trouble adopting newer features from Apple in the future. I think we are in a unique position to design in a futuristic way without limiting the users since we have two... |
Sure, if the ObjC SDK keeps getting updated with the same features as the Swift SDK I think that's valid. The gap I'd be concerned about is from when the ObjC SDK starts getting less attention but there is still a significant number of iOS <13.x devices out there. If we time this properly I think that gap can be made negligibly small. |
I agree with this in principle. My only concern here though is that it's already hard to find maintainers for the obj-c code, and that's unlikely to improve over time. Developer time is a real bottleneck here. EDIT: To illustrate, my Sign in with Apple PR has been hanging since the beginning of the year basically. Things don't move fast. |
True, but currently anyone who has been doing iOS Parse has to be using the Obj-C SDK (ignoring web-based apps). The Swift SDK is definitely not a drop in replacement for the Obj-c one as it's designed differently and will take time for a developer to convert. When considering that we are talking about an SDK that supports older devices, we already know that the Objc SDK works on iOS 13 (and essentially 14) and below. That should buy us a significant amount of time IMO and that's assuming Objc SDK development completely stopped today, which I don't see happening anytime soon. |
Agreed 🙂. Yeah it could well work out. |
@mtrezza I think it may be hard to keep the features in sync. For example, the Obj-C is way ahead of Swift for now and definitely has more robust testcases. My guess is from skimming the SDKs is that some are able to leverage the latest parse-server features better than others. Doesn't the JS SDK leverage the query abilities of parse-server better than the Obj-c SDK? If this is true, from a query standpoint, the Swift SDK may jump ahead of the Obj-C one soon as it may be straightforward to port the JS query features. I don't think the Swift SDK should be limited by the Obj-C one in these cases |
Definitely not, I agree. It depends on the feature. For example, the ObjC SDK should not become unusable for example due to iOS API changes and lack of maintenance, before we reach a significantly higher number of iOS 13 adoption. I would also say, as long as there is a workaround, such as using the JS SDK via a Cloud Code function, it's also fine, regarding your query example. |
@cbaker6 so I got into writing more tests for |
Still working on those new tests! I actually found a couple of pretty major bugs when encoding more complex objects (thanks @cbaker6 for suggesting more tests) and I'm working on fixing them. It's been a busy week at work but I'll have them done in the next day or two. |
Sorry for the delay; I kept trying to figure out how to increase coverage even more, but I'm having a hard time. Coverage is up to 60%, and I'm not sure what other tests to add to increase it further. @cbaker6 / anyone else, if you have ideas, I'd love to hear them and give them a shot! If not, this is done from my end and ready for another review / merge. |
@pranjalsatija can you bump the codecov to 52 in the yml? |
This is a WIP, but I wanted to open it and start getting feedback. I still plan on:
ParseObject
around so that each protocol is implemented as an extension on `ParseObject.ParseUser
.Coding/Miscellaneous.swift
under aParseCoding
namespace or something. Calls to the globalgetJSONEncoder
andgetParseEncoder
functions feel weird.PrimitiveObjectStore
protocol, extendingKeychainStore
to implement it, and using the new store to persist the current user.