Query in database, not in memory

I work in a startup environment. Sometimes features are developed within 2-3 days. So developers give preference to deadline instead of performance. For past few months, I was compiling a list of code snippets where performance is ignored completely. The common culprit in such code was developers habit to query in memory instead of database. What do I mean by querying in memory? I mean instead of getting result from database, we write code to first get data from DB and then write code to extract result....

August 20, 2016 · Dinesh Sawant

Super Keyword in Java

In Java, super keyword is used to access Superclass Member in subclass.You can use super keyword in following scenarios. Syntax In Subclass Constructor super() This calls No-arguments constructor present in super class. super(parameters) This will call any matching constructor with same parameters. Call to super must be first statement in constructor. Mind It!! Otherwise you will get compile time error.It is not allowed.As stated in Java Language Specification: ConstructorBody: { [ExplicitConstructorInvocation] [BlockStatements] } Other code statements should come after explicit constructor invocation....

April 1, 2015 · Dinesh Sawant

Serialization in Java : Save and retrieve object state

Serialization lets you save an object’s state. Deserialiszation is a process of retrieving saved object state. By using serialization technique you can save an object on a file, send it over network and then use the same object state. Serializable It is a marker interface which should be implemented by class which you want to make serializable. It is used as a label. This interface does not specify any methods or constants....

December 13, 2014 · Dinesh Sawant

Sorting in java - Comparable and Comparator example

Comparable and Comparator are interfaces used during sorting of Java collections. Where Comparable is used to define default / natural ordering, Comparator is mainly used to define customized ordering. Here java.util.Collections class comes into picture with 2 important methods, sort(List list) and sort(List list,Comparator c). The best place to read about them is Javadoc. /** * Student class implements comparable interface * and applies comparison logic in compareTo method. * This logic is default logic for ordering students....

December 12, 2013 · Dinesh Sawant

Pass by Value in Java

In pass by value mechanism copy of the value is created and passed to method. Any change in value passed is not reflected on actual variable which is used to pass value. Another mechanism is pass by reference. In this mechanism reference is passed to method.So any change in values are reflected on actual variable which is used to pass value.Ok, but there is a catch, reference has a different meaning in java....

November 13, 2013 · Dinesh Sawant