Skip to main content

Posts

              Don’t use Setters and Minimize Getters In the modern IDE’s, getters and setters are created automatically or in some cases including a specific library creates them automagically, injecting these accessor methods. This so-called feature of the IDE is cool but evil! We also have libraries that do this in code, like Lombok. Programmers don’t write these methods and the IDE enables us to do these incorrect things quickly. Let me take a step back for a moment. I know a lot of you are surprised by the topic name and let us get into the details of it. In an object-oriented world, an object represents a real-world entity. You always interact with the object through its behavioural methods. What these getters/setters do is that they expose the internals of the object and provide you with a mechanism to modify an object's internal state. Let us take an example. Suppose you have an employee object with the following data Employee Object
Recent posts
A date with Date, Time, Duration and Timezones Have you ever wondered, when debugging an issue in a globally distributed environment, if the events are out of sequence? Chances are that all of us would have seen it at least once in our professional career. All applications are required to deal with Date, Time and Duration. This is a very complex area, as the rules regarding time-keeping are not widely known and this causes tricky and funny (and sometimes critical ) issues. Adding to this is the additional complexity of Time zones (TZ) and the Daylight Savings! Phew! Let’s refresh our understanding of how Time zones are arrived at. Since a day is 24 hours long, the world may be split into 15 degree wide longitudinal slices (360 degrees/24 hours). Each slice represents one hour. But, life is not so simple. The International Date line creates an additional TZ and a few TZ’s differ by 30 mins /45 mins. If Greenwich (0th meridian) has the current local time as 00