Posts

Showing posts with the label equals

Observability Done Right: Best Practices and Anti-Patterns for Effective System Monitoring

Image
  WHAT Observability is a concept that refers to the ability to gain insights into the behavior and performance of complex systems. In the context of software engineering, observability involves the collection, analysis, and visualization of data from software applications, infrastructure, and other components of a system. In the animal kingdom, observability plays a critical role in survival, allowing animals to monitor their surroundings, detect threats, and find food. Dolphins use echolocation to observe their surroundings. They emit high-frequency sounds that bounce off objects, allowing them to create a 3D map of their environment. Thanks for reading Knowledge Cafe! Subscribe for free to receive new posts and support my work. Subscribed WHY In today's era, architectures are becoming increasingly large, complex, and fast-paced due to the faster development and deployment of software by distributed teams with the help of DevOps, continuous delivery, and agile development methodo...

Java Collections - hashCode() and equals() methods

Image
We will discuss about hashcode() and equals() methods of Object class and what role they play in an object life cycle. The methods  hashCode()  and  equals()  play a distinct role in the objects identity you insert into collections. The specific contract rules of these two methods are best described in the JavaDoc, here I will just describe what role they play, What they are used for, so you know why their implementation is important. Both equals() and hashcode()   are defined in  java.lang.Object  class and their default implementation is based upon Object information e.g. default  equals()  method return  true,  if two objects are exactly same i.e. they are pointing to same memory address, while default implementation of hashcode method return  int  and implemented as native method. Equals: This particular method is used to make equal comparison between two objects. There are two types of compari...

hashcode and equals methods

Equals and hashcode methods are two primary but yet one of most important methods for java developers to be aware of. Java intends to provide equals and hashcode for every class to test the equality and to provide a hash or digest based on content of class. Importance of hashcode increases when we use the object in different collection classes which works on hashing principle e.g. hashtable and hashmap. A well written hashcode method can improve performance drastically by distributing objects uniformly and avoiding collision. General Contracts for hashCode() in Java  1) If two objects are  equal  by equals() method then there  hashcode  returned by hashCode() method must be same. 2) Whenever  hashCode() mehtod  is invoked on the same object more than once within single execution of application, hashCode() must return same integer provided no information or fields used in equals and hashcode is modified. This integer is not required to be same during multiple execution of application th...