404 Not Found or Bad Request?

404 is your best response. According to the HTTP RFC, http://www.ietf.org/rfc/rfc2616.txt, A 400 Bad Request means: The request could not be understood by the server due to malformed syntax. Whereas, 404 states: The server has not found anything matching the Request-URI. The entire URI is your resource identifier, and you’re not finding a matching resource … Read more

Identify item by either an ID or a slug in a RESTful API

Of the three I prefer the third option, it’s not uncommon to see that syntax; e.g. parts of Twitter’s API allow that syntax: https://dev.twitter.com/rest/reference/get/statuses/show/id A fourth option is a hybrid approach, where you pick one (say, ID) as the typical access method for single items, but also allow queries based on the slug. E.g.: GET … Read more

Why can’t AtomicBoolean be a replacement for Boolean?

Boolean is an immutable value object. It was designed to be unchanging and made final in order to enforce that. java.lang.Boolean has been around since 1.0. AtomicBoolean is mutable, and designed to get updated so that the updated value is visible across threads. AtomicBoolean was introduced with Java 5. These are entirely different concepts, which … Read more

Why Java does not allow overriding equals(Object) in an Enum?

Anything but return this == other would be counter intuitive and violate the principle of least astonishment. Two enum constants are expected to be equal if and only if they are the same object and the ability to override this behavior would be error prone. Same reasoning applies to hashCode(), clone(), compareTo(Object), name(), ordinal(), and … Read more

API design and jQuery [closed]

.load() is overloaded with entirely different behavior depending on the arguments passed .toggle() is overloaded with entirely different behavior depending on the arguments passed too much overloading of the jQuery() function perhaps. the .attr() you mentioned. The distinction from properties should have been immediate IMO. .map( key,val ) but $.map( val,key ), and the this … Read more

When should we create our own Java exception classes? [closed]

From Best Practices for Exception Handling: Try not to create new custom exceptions if they do not have useful information for client code. What is wrong with the following code? public class DuplicateUsernameException extends Exception {} It is not giving any useful information to the client code, other than an indicative exception name. Do not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)