Menu

Unused assignments should be removed | Sonar

Sonar code smell "Unused assignments should be removed" means, 
a dead store happens when a local variable is assigned a value that is not read by any subsequent instruction. Calculating or retrieving a value only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it’s not an error, it is at best a waste of resources. Therefore all calculated values should be used.

Noncompliant Code 

i = a + b; // Noncompliant; calculation result not used before value is overwritten
i = compute();

Compliant Solution

i = a + b;
i += compute();

SQL query to update DynamoDB records

In this post, we will look at how to alter or update records in the No-SQL DynamoDB table. The SQL language provides the UPDATE statement for modifying data. Amazon DynamoDB uses the UpdateItem operation to accomplish similar tasks.

Syntax to run the update command


UPDATE <"TableName">
SET <column name> = <value>
WHERE <column name> = <value>

e.g.

UPDATE "user"
SET enabled='true'
WHERE id='dynamoDBUser'


Here SET clause is to set the value which you want to set, and WHERE clause is to identify the right row or data from the table.

Reference:

Amazon DynamoDB SQLtoNoSQL UdateData 

Can we have multiple doGet() or doPost() in a servlet?

 No, it doesn't make sense to creating multiple doGet() or doPost() methods in a Servlet. The compiler will always execute the first one. It's better to write a different Servlet to handle the different requests.


One other way is the method overriding, we can override doGet() or doPost() in any of the methods viceversa. For more read Overriding Service, Get, and Post