Tag Info

Hot answers tagged

76

It isn't a problem. It is a known technique. These are higher order functions (functions that take functions as parameters). This kind of function is also a basic building block in functional programming and is used extensively in functional languages such as Haskell. Such functions are not bad or good - if you have never encountered the notion and ...


30

They're not just used for functional programming. They can also be known as callbacks: A callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. The invocation may be immediate as in a synchronous callback or it might happen at later time, as in an ...


10

This is not a bad thing. In fact, it is a very good thing. Passing functions into functions is so important to programming that we invented lambda functions as a shorthand. For example, one may use lambdas with C++ algorithms to write very compact yet expressive code that allows a generic algorithm the ability to use local variables and other state to do ...


10

One of the advantages of REST is the ability to cache the requests via traditional http caches (assuming that these are cacheable requests). When you have single, larger, less frequently used, and possibly different requests (I'm going to fetch items a,b,c,d this time and items a,b,d,e next time) you make the request more likely to be a cache miss and get ...


7

Your intuition is somewhat correct -- by and large making fewer requests is certainly preferable; chunky APIs tend to be better. Especially with spotty connectivity where you can see some work and some fail creating nightmarish fallback scenarios as nothing can rely upon anything. There is one big caveat -- you can get way too chunky and your calls and ...


6

As already said, it isn't bad practice. It is merely a way of decoupling and separating responsibility. For example, in OOP you would do something like this: public void doSomethingGeneric(ISpecifier specifier) { //do generic stuff specifier.doSomethingSpecific(); //do some other generic stuff } The generic method is delegating a specific task ...


4

You are trying to compare two very differing technologies. Like comparing apples and oranges. It's a valid question to ask when to use REST based or SOAP based web service. For your case, I don't think there is a need of creating a RESTful web service.


4

You want to you 403 Forbidden. From the HTTP specs 403 Forbidden: The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. You shouldn't use 409, it implies that the client might be able to resolve the conflict, which in the case of over booking the client can't do as the ...


3

In general, there's nothing wrong with passing functions to other functions. If you're making asynchronous calls and want to do something with the result, then you'd need some sort of callback mechanism. There are a few potential drawbacks of simple callbacks though: Making a series of calls can require deep nesting of callbacks. Error handling can need ...


3

REST does not mean to not use URL params at all. Your example demonstrates this very well. You can still see a 'search' as a REST resource. You implement a controller for it, though it only has one or two actions. (But details do not matter much in this case) Everything data needed to perform the search can then be sent by using params. There is nothing ...


2

In short: Your approach is somewhat correct and could benefit from a wrapper Service. This service will combine existing single calls into one service side method. Doing that by combining calls from client to service side & utilizing all single, atomic, restful calls that you probably have in place by now. Thus, you would continue to have benefit from ...


2

To disagree with the accepted answer: using the Authorization header seems like the right thing to do. It's the entire purpose of the Authorization header. From http://tools.ietf.org/html/rfc7235#section-4.2 : The "Authorization" header field allows a user agent to authenticate itself with an origin server -- usually, but not necessarily, after ...


2

If I want to add support for Protobuf then I have create new method in processor and copy-paste almost all the business logic NO! An object oriented approach ItemProcessor "has all the business logic". Don't pollute the class, keep it strictly business logic Your data/response structure is universal. JSON, XML, protobuf are just different syntactical ...


1

In my humble opinion the answer is both Yes and No. My current work experiences are dealing with a JavaScript front end (using ExtJS & Sencha Touch) and all my data connections are to a .Net Web API 2.0 RESTful back-end. But my application is internal and so I do not have as much concerns for Security and Authentication & State, plus I am hosting ...


1

To me the best solution seems to be a method that takes an optional parameter that allows the caller to determine whether or not to include the follower data. In this way the caller can determine if it is appropriate to include the follower data in the call. In a worst case scenario you have a few extra lines of code that never matter because the call ...


1

I wonder each input parameter is different or not. Anyway you may be able to return result as Object and cast it. Also you may be able to get parameter as Object. You may be looking for that how to generate methods in runtime. http://stackoverflow.com/q/6680674 I recommend you'd better make all methods. I think It may be good for readability.


1

First of all, whatever you do, please use unique ids. In your current scheme you can only reference an entity through the exact path through the tree, that is generally annoying to work with. What happens if a person is moved from one department to another? Or if there is a department restructure? Nothing will retain its handle. Second, don't make entities ...


1

Check out this Dropbox Tech Blog article. There they describe in detail on why and how they implemented exactly the solution you proposed for retrieving the thumbnails for all your pictures. It should be said that they do measure performance to see if it's worth the trouble, and apparently it is. Short summary: The Dropbox website has to load hundreds of ...



Only top voted, non community-wiki answers of a minimum length are eligible