FAQ Database Discussion Community


Why doesn't Collection Implement Stream? [duplicate]

java,lambda,java-8,api-design
This question already has an answer here: Why doesn't java.util.Collection implement the new Stream interface? 1 answer This is a question about API desing. When extension methods were added in C#, IEnumerable got all the methods that enabled using lambda expression directly on all Collections. With the advent of...

Why are Java Streams once-off?

java,java-8,java-stream,api-design
Unlike C#'s IEnumerable, where an execution pipeline can be executed as many times as we want, in Java a stream can be 'iterated' only once. Any call to a terminal operation closes the stream, rendering it unusable. This 'feature' takes away a lot of power. I imagine the reason for...

How to invoque different operations by reusing a single API function?

c++,function,switch-statement,api-design
My API function execute_api() shall perform specific operations for: method name : view / create / update / delete / update_all / delete_all method type : get / post I want my code to reuse the same logic in execute_api() but tailor the execution to implement any operations I have...

Is it a good idea to substitute Collection for Stream in return values?

lambda,java-8,java-stream,api-design
Up until Java 8, a property representing a collection of elements usually returned a Collection. At the absence of an immutable collection interface, a common idiom would be to wrap it as: Collection<Foo> getFoos(){ return Collections.unmodifiableCollection(foos); } Now that Stream is here, it is tempting to start exposing Streams instead...

Insight into the feasibility of two REST API designs [closed]

node.js,mongodb,rest,mongoose,api-design
I have developed several REST APIs in the past and am currently working on building a new one for an in-house software solution at our company. I have chosen the MEAN stack to build this and Mongoose to manage schema design and data layer validation. Good design, durability and extensibility...

Any alternatives to java.io.InputStream in Scala?

java,scala,api-design
I am designing an API where one of the methods needs to provide a way to get file content. I do not want the method to return a file location as potentially files will be stored in the database. I also do not want to return file content as Array[Byte]...

Defining a REST api

web-services,rest,api-design
I was wondering what the most correct or best practice way to define a rest api would be. Lets say I have an application that deals with cars and their parts/components. Any api will always start first with the top level car. So, in defining my api should I go...

Why don't primitive Stream have collect(Collector)?

java,java-8,java-stream,api-design
I'm writing a library for novice programmers so I'm trying to keep the API as clean as possible. One of the things my Library needs to do is perform some complex computations on a large collection of ints or longs. There are lots of scenarios and business objects that my...

Choosing between package:html, dart:html, dart:io (class HttpClient) and package:http APIs to fetch HTTP resources

android,dart,httprequest,api-design,dart-pub
I realized that currently there are at least three "official" Dart libraries that allow me to perform a HTTP request. What is more, three of those libraries (dart:io (class HttpClient), package:http and dart:html) have each a different, incompatible API. As of today, package:html does not offer this functionality, but on...

Fold multiple function-calls to single function?

c++,simd,api-design
I was thinking about a simple SIMD class, that supports overloaded arithmetic operators +-*/ etc. While implementing this as a class template to support different kinds of intrinsics, I noticed that there are some available that would do multiple operations at once (_mm_fmadd_ps for multiplication and addition). I wondered now...

Link to another resource in a REST API: by its ID, or by its URL?

json,api,rest,api-design,hateoas
I am creating some APIs using apiary, so the language used is JSON. Let's assume I need to represent this resource: { "id" : 9, "name" : "test", "customer_id" : 12, "user_id" : 1, "store_id" : 3, "notes" : "Lorem ipsum example long text" } Is it correct to refer...

PATCH multiple resources

json,rest,http,api-design,http-patch
Short: Is it standard-compliant, RESTful and otherwise good idea to enable PATCH requests to update a collection of resources, not just a single one, but still individually? Long: I'm considering exposing a method for enabling batch, atomic updates to my collection of resources. Example: PATCH /url/myresources [ { "op": "add",...

Naming java methods that return streams

java,java-8,java-stream,api-design
Is there naming convention for methods that return Stream? The only mention I found is this answer on S.O (last paragraph), but I don't see what is it based on.

How to Identify Client uniqueness?

api,rest,oauth-2.0,web-api,api-design
TL;DR; Is there any way to bind a (Bearer?) token to a unique client, and represent that in the HTTP REQ Headers? In the scenario that a user has an account to a service. The same user should be able to consume the services using different client applications (different Browsers,...