Tag Info

Hot answers tagged

3

Although the right solution depends on your context, here is my approach: When designing classes one should always consider their single responsibility. In case of the PostsController it could probably be described "create, read update and delete" posts. Formatting of the output is a global problem of your application that should not be solved individually ...


3

The answer to your question depends on the definition of "good" in the question "what are some good ways to separate APIs from implementation of ..." If "good" means "pragmatic easy to implement for you as manufecturer of the api" this might be helpful: since you are using java where jar-libraries are loaded at runtime i would suggest a slightly different ...


2

404 indicates a resource is not found. A more appropriate response code would be a 409 with a body containing more details if the nature of the conflict.


2

It depends. Is the response an answer to a query that's more like GetListOfProducts() or GetProductIndex()? Is the result intended to be iterated over or used as a single-product lookup by id? Is the sort-order significant? If it's more like GetListOfProducts() with sort-order implications and/or the intention of iteration, like displaying the records in a ...


1

You have outlined the two main approaches, and each have their advantages and disadvantages. If you combine both in the same controller, and all you are doing is changing the output, then using a single controller makes sense. The logic is the same, but the output changes. If the logic has to change because the output is different, then go with two ...


1

404 means resource not found. Using it here would be not appropriate. Because the resource clearly exists, but cannot be manipulated. According to Quick Tips (http://www.restapitutorial.com/lessons/restquicktips.html) 409 Conflict would be a good way to go. You can of course return 200 with error message in the body. The client is still responsible for ...


1

Have you had a look at the ServiceLoader Mechanisms in Java? Basically you can specify the implementation of an interface via the manifest file in a jar. Oracle also provides some further information about plugins in Java programs.


1

Enums are a good idea If you'll provide this code via dll (good idea for me), I'd recommend not to change them into enum class and not no throw the exception, because these are C++ only features, and users will be not able to use your dll in C# for example If these enums will be used as a real register address (or offset) it would be better to initialize ...



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