Which is better option: Cloning or Copy constructors?

by Prasanth Gullapalli

Here is how I started writing this article. I have read this statement so many times: “Cloning becomes difficult when the object has references to mutable final fields.” And every time I google about it, understand what exactly this means and as part of the process forget about it too. So thought I would blog this so that this will serve as my immediate reference.

Cloning an object, what I could recall from my OOP course in my graduate studies, is creating a similar copy of an object which basically should conform to the following rules:

(1) x.clone() != x
(2) x.clone().getClass() == x.getClass()
(3) x.clone().equals(x) Continue reading

Object Oriented JavaScript – Part 3

by Prasanth Gullapalli

As seen in the earlier article, using Constructor pattern and Prototype chaining on their own have got few problems. We resolved those problems by defining a new pattern which amalgamates both the patterns. If we look at the way we have been creating objects so far, it is very much similar to Java. In fact using new keyword sometimes makes the code more complex which we could have avoided using alternatives like Prototypal Inheritance. So the rest of article deals with how to achieve a better form of inheritance without using any new keyword. Also it addresses the issue of redundant properties(masked by the instance properties) on Prototype we have seen in Combination Inheritance. Continue reading

Object Oriented JavaScript – Part 2

by Prasanth Gullapalli

In any object oriented language, inheritance can be achieved in two ways: 1. Interface Inheritance 2. Class Inheritance. JavaScript don’t have support for the former but supports the latter through the use of Prototype Chaining. So it is very vital to understand what Prototype Chaining is.

Continue reading

Object Oriented JavaScript – Part 1

by Prasanth Gullapalli

In this article I will discuss multiple ways of creating objects in JavaScript. And in the next part of this article, I will cover Inheritance in JavaScript.

In JavaScript, Objects can be created in two ways: Continue reading

JMX and MBeans with Spring

by Prasanth Gullapalli

JMX defines an architecture for management and monitoring of long running Java applications. Simply put, it provides an interface for interacting with a running application. So through JMX, we can check/change the state of variables or to invoke a method in a (remote) running application via a management GUI such as JConsole. Continue reading

Type Conversion in Spring

by Prasanth Gullapalli

Here are few straight cases where we need type conversion:
Case #1. To help simplifying bean configurations, Spring supports conversion of property values to and from text values. Each property editor is designed for a property of certain type only. And to put them in use, we have to register them with Spring container.
Case #2. Also when using Spring MVC, controllers binds the form field values to properties of an object. Suppose the object is composed with another object, then the MVC controller cannot automatically assign values to the internal custom type object as all the values in the form are inputted as text values. Spring container will take of conversion of text values to primitive types but not to custom type objects. For this to be taken care, we have to initialize custom editors in the MVC flow.

This article will discuss the various ways of implementing the converters for custom type objects. Continue reading