- If you don’t use enums in function parameter, you are forever trying to learn what possible values can the front-end send. This makes you often start the server and run the project just to know what the client side sends slowing you down.
2. Where JPA has really triumphed is the difficulty of testing native queries that are concatenated with multiple conditions
e.g if coupon != null
query += “AND coupen =’Valid'”
Adding your own concatenated string to this query makes it hard to test he entire query for all its conditions.
3. Always write tests when starting out
4. Always manually test your code before sending it to your colleague
5. Make sure you note down credentials production keys etc. You are going to forget it.
6. Do not keep code stashed in git for too long. You could lose it if git gets corrupted. It is better to comment and commit, create a separate remote branch or add a feature flag that disabled your code.
7. Using primitives in your API. If someone adds a null, your API doesn’t fail but your business logic is now flaky because a null has got introduced. Was it better for the API to fail than to accept a null? The problem with primitives is that they are often initialized to 0 when a NULL could have been ok.
8. Always abstract your code. If you are starting a jetty server inside a method. Ask yourself if you could have passed a server variable so that any server can be used and it doesn’t have to be Jetty.
fun getToDoList(user: String, listName: String): ToDoList {
val client = JettyClient()
val response = client(Request(Method.GET, "http://localhost:8081/todo/$user/$listName"))
return if (response.status == Status.OK)
parseResponse(response.bodyString())
else
fail(response.toMessage())
}