api-design

What is the gold standard for website APIs? Twitter, Flickr, Facebook, etc [closed]

荒凉一梦 提交于 2019-12-02 13:46:55
Seems like there are two categories of APIs for websites today. APIs which allow the functionality of the site to be extended like Facebook, Myspace, etc. These APIs seem to be very diverse. APIs which allow interaction with the existing site functionality like Twitter, Flickr, etc. These all claim to be REST based, but are in reality simply "data over HTTP". If you were creating a website that allowed both functional extension and outside interaction, what existing APIs would you use as a reference model? Jeff Atwood We're doing some research in this area ourselves. Not a lot out there in

In what scenarios are APIs that don't borrow preferred?

谁说我不能喝 提交于 2019-12-01 15:56:18
Rust has the concepts of ownership and borrowing. If a function doesn't borrow its parameter as a reference, the arguments to that function are moved and will be deallocated once they go out of scope. Take this function: fn build_user(email: String, username: String) -> User { User { email: email, username: username, } } This function can be called as: let email = String::from("foo@example.com"); let username = String::from("username"); let user = build_user(email, username); Since email and username have been moved, they can no longer be used after build_user was called. This can be fixed by

Why is DialogResult a nullable bool in WPF?

痞子三分冷 提交于 2019-12-01 15:44:12
Can anyone think of a good explanation for the fact that result of a dialog is a nullable bool in WPF? This has always baffled me. In WinForms it was an enum type and that made a lot more sense to me. In my opinion this was done because in most cases you don't need the generalized specialized options like Retry or Ignore. If you need more than OK/Cancel, you are supposed to use some kind of task dialog, e.g. with written-out answers. That way, you're not limited to the few enum values someone thought of some decades ago, and the DialogResult is just positive/negative for basic use and you can

In what scenarios are APIs that don't borrow preferred?

南楼画角 提交于 2019-12-01 14:43:58
问题 Rust has the concepts of ownership and borrowing. If a function doesn't borrow its parameter as a reference, the arguments to that function are moved and will be deallocated once they go out of scope. Take this function: fn build_user(email: String, username: String) -> User { User { email: email, username: username, } } This function can be called as: let email = String::from("foo@example.com"); let username = String::from("username"); let user = build_user(email, username); Since email and

Why is DialogResult a nullable bool in WPF?

蹲街弑〆低调 提交于 2019-12-01 13:49:26
问题 Can anyone think of a good explanation for the fact that result of a dialog is a nullable bool in WPF? This has always baffled me. In WinForms it was an enum type and that made a lot more sense to me. 回答1: In my opinion this was done because in most cases you don't need the generalized specialized options like Retry or Ignore. If you need more than OK/Cancel, you are supposed to use some kind of task dialog, e.g. with written-out answers. That way, you're not limited to the few enum values

Is it ok to (ab)use CoClassAttribute to provide a default implementation for an interface?

こ雲淡風輕ζ 提交于 2019-12-01 05:03:23
问题 I recently discovered that it's possible to "new up" an interface in C# by decorating the interface with the CoClassAttribute to specify a default implementation. [ComImport, Guid("579A4F68-4E51-479A-A7AA-A4DDC4031F3F"), CoClass(typeof(FooImpl))] public interface IFoo { void Bar(); } public class FooImpl : IFoo { public void Bar() { } } ... // Constructs a FooImpl IFoo foo = new IFoo(); I'm aware that this feature exists primarily to support COM-interop, but I was wondering if this would be a

What's missing in Cocoa? [closed]

馋奶兔 提交于 2019-11-30 17:38:42
If you could add anything to Cocoa, what would it be? Are there any features, major or minor, that you would say are missing in Cocoa. Perhaps there is a wheel you have had to invent over and over because of an omission in the frameworks? Quinn Taylor Built-in regular expression support (a la RegexKit ) would be extremely handy. NSRegularExpression is available on iOS 4.0+, but it is still not available on Mac OS X yet. An easy way to progressively read NSString objects from a large text file without loading the entire thing into memory. (NSInputStream and NSFileHandle just don't measure up

Why there is no getFirst(iterable) method?

ε祈祈猫儿з 提交于 2019-11-30 17:11:21
Iterables present two methods for getLast public static <T> T getLast(Iterable<T> iterable); public static <T> T getLast(Iterable<T> iterable, @Nullable T defaultValue); but only one for getFirst public static <T> T getFirst(Iterable<T> iterable, @Nullable T defaultValue); Is there are any design/implementation reason for breaking symmetry? John B I think the point is that there is no reason for a getFirst(iterable) in that this could be done with iterable.iterator().next() . Guava makes an excellent attempt to keep the API small and so does not add things that could / should be done easily

What's missing in Cocoa? [closed]

人盡茶涼 提交于 2019-11-30 16:42:53
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . If you could add anything to Cocoa, what would it be? Are there any features, major or minor, that you would say are missing in Cocoa.

How do you define a good or bad API? [closed]

守給你的承諾、 提交于 2019-11-30 06:09:27
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Background: I am taking a class at my university called "Software Constraints". In the first lectures we were learning how to build