-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 a few Swift 3 methods #3874
Conversation
I understand that |
Have we ever considered doing some sort of user testing to determine optimal API naming? I wonder if |
I'd also rather keep |
If we're going to inconsistently use |
Maybe this is crazy, but thoughts on func create<T>(_ type: T.Type, from: AnyObject) -> T
func create(_ type: DynamicType, from: AnyObject) -> DynamicObject where It results in both simpler API naming for the common case and similar methods sharing a base name. As an alternative, we could use the object schema instead of the type name. func create(_ type: RLMObjectSchema, from: AnyObject) -> DynamicObject This helps users avoid typos when using the dynamic API since they'll likely keep around a variable representing the type. let foo = realm.schema["foo"]!
realm.create(foo, from: json) This would leave us with the following, more concise API. create(_:from:)
objects(_:) |
|
Should this change also make the label name of |
@bdash Good catch on Would anyone object if I restored @JadenGeller A struct wrapper is too heavy IMO, but a typealias would be almost as good (wouldn't stop you from doing stupid things, but it would let you see the intended purpose of the string at a glance). |
Is |
It's not, but then you have |
|
Maybe we should keep |
@austinzheng A typealias could be nice, but not a replacement for the argument label. Did you have thoughts on using an |
Well, as of Swift3 |
Changes: - 'createObject(ofType:populatedWith:)' is now 'create(_:from:)' - 'createDynamicObject(ofType:populatedWith:)' is now 'createDynamicObject(ofType:from:)' - 'allObjects(ofType:)' is now 'objects(ofType:)' - 'allDynamicObjects(ofType:)' is now 'dynamicObjects(ofType:)'
@bdash @JadenGeller Changed |
@JadenGeller using the object schema instead of the string is an interesting idea, but should probably be discussed and implemented separately. |
Are these renamings still something we want to pursue? If so I'll rebase and merge, after making any further improvements that you might suggest. |
This is still something that needs to happen, and the churn of the language is one reason I've been staying away from this, though supposedly now it's mostly settled? |
I think it has mostly settled. |
Closed since the API changes are being made in #4078. |
@bdash @JadenGeller @jpsim @tgoyne
Changes: