Simulated Annealing

Simulated Annealing (SA) is a probabilistic technique used for finding an approximate solution to an optimization problem. To find the optimal solution when the search space is large and we search through an enormous number of possible solutions the task can be incredibly difficult, often impossible. Even with today’s modern computing power, there are still often too many possible solutions to consider. Therefore, we often settle for something that’s close enough to optimal solution when we may be not able to find the optimal solution within a certain time.

Continue reading

Advertisements

Best Practices of Java Singleton Design Pattern

Singleton Pattern

We have different approaches but all of them have following common concepts to implement Singleton pattern:

  • Private constructor which restricts instantiation of the class from other classes.
  • Private static variable of the same class that is the only instance of the class.
  • Public static method that returns the instance of the class, this is the global access point for outer world to get the instance of the singleton class.

Where do you use the Singleton pattern?

Most of the scenarios, Singleton classes are created for resources such as File System, Database connections etc…

Continue reading

HTTP Cache Headers

HTTP caching can speed up web applications. It’s standardized and well implemented in all modern browsers and results in a lower latency app and improved responsiveness.

HTTP caching occurs when an item is fully cached for faster retrieval the next time the resource is required. The browser may choose to not contact the server at all and simply use its own local copies of web resources. There are many cache headers such as “Cache-Control”, “Expires”, “Last-Modified” and “ETag”.

Continue reading