ability, then you do not (and should not) have guilt. But how do you
find your ability? By trying.
- Jeff Hunt (Paraphrased)
Anything that interests me finds place here. Software dominates my interests and hence a good part of this blog as well.
- Jeff Hunt (Paraphrased)
So choose to take decisions influenced by your virtues.
- Jeff Hunt (paraphrased)
| Hard Links | Symbolic Links |
| Each hard link is a reference to the same i-node number (a key in the i-node table - inode entry for a file can be viewed using stat<<filename>>). | Each symbolic link contains the pathname of the source file. |
| Source cannot be a directory | Source can be a directory |
| Source & destination must be in the same file systems (because inode numbers are unique only within one file system) | Source and destination can reside anywhere |
| Singular property | Simple property | Class Singer implements Performer { private String name; public Singer(String n) { this.name = n; } } | <bean id=”xyz” class=”com.Singer”> <constructor-arg value=”xyz”/> </bean> |
| Class Singer implements Performer { private String name; public void setName(String n) { this.name = n; } } | <bean id=”xyz” class=”com.Singer”> <property name=”name” value=”xyz”/> </bean> | ||
| Property referencing another bean | Class Drummer implements Performer { private Drum drum; public Drummer(Drum d) { this.drum = d; } } | <!-- Tabla implements Drum --> <bean id=”tabla” class=”com.Tabla”> </bean> <bean id=”xyz” class=”com.Drummer”> <constructor-arg ref=”tabla”/> </bean>
OR
<bean id=”xyz” class=”com.Drummer”> <constructor-arg> <!-- nested bean --> <bean class=”com.Tabla”> </constructor-arg> </bean>
| |
| Class Drummer implements Performer { private Drum drum; public void setDrum(Drum d) { this.drum = d; } } | <!-- Tabla implements Drum --> <bean id=”tabla” class=”com.Tabla”> </bean> <bean id=”xyz” class=”com.Drummer”> <property name=”drum” ref=”tabla”/> </bean>
OR
<bean id=”xyz” class=”com.Drummer”> <property name=”drum”>
<!-- nested bean --> <bean class=”com.Tabla”> </property> </bean> | ||
| Plural Property | Collections |
Class Drummer implements Performer {
// REFERENCE TYPE private Collection<Drum> drums; OR private List<Drum> drums; OR private Set<Drum> drums; public setDrums( Collection<Drum> drums) { this.drums = drums; }
// SIMPLE TYPE private Collection<String> names; public setNames(Coll... names) { this.names = names; } } | <bean id=”drum1” … /> <bean id=”drum2” … /> <bean id=”xyz” class=”com.Drummer”>
<!-- REFERENCE TYPE --> <property name=”drums”> <list or set> <ref bean=”drum1” /> <ref bean=”drum2” /> <bean class=”com.ADrum”/> <null /> </list or set> </property>
<!-- SIMPLE TYPE --> <property name=”names”> <list or set> <value>Name1</value> <value>Name2</value> <null /> </list or set> </property> </bean> |
| Name value pairs |
Class Drummer implements Performer {
// Key and values are objects private Map<String, Drum> drums; public setDrums(Map... drums) { this.drums = drums; }
// key & values are strings private Properties notes; public setNotes(Properties note) { this.notes = note; } } | <bean id=”drum1” … /> <bean id=”drum2” … /> <bean id=”xyz” class=”com.Drummer”>
<property name=”drums”> <map> <entry key or key-ref=”drum1” value or value-ref=”drum1”/> <entry key=”drum2” value-ref=”drum2”/> </map> </property> <property name=”notes”> <prop key=”Note1”> lala </prop> <prop key=”Note21”> lolo </prop> </property> </bean> |
| Boolean | add(E o) | Methods to add elements to collection |
| Boolean | addAll(Collection<? Extends E> c) | |
| Void | Clear() | Methods to remove elements from collection |
| Boolean | remove(Object o) | |
| Boolean | removeAll(Collection<?> c) | |
| Boolean | retainAll(Collection<?> c) | |
| Boolean | contains(Object o) | Methods to check if specific element(s) exist in collection. |
| Boolean | containsAll(Collection<?> c) | |
| Boolean | IsEmpty() | Methods to check collection at a higher level |
| Int | Size() | |
| Iterator<E> | Iterator() | Methods to transform the whole collection to other representations |
| Object[] | ToArray() | |
| <T> T[] | toArray(T[] a) |
Helios - 3.6.0 - Released 2010
Galileo - 3.5.2 - 2009
Ganymede - 3.4.2 - 2008
Europa - 3.3.2 - 2007
Abstraction is based on concept of invariance - a boolean condition that
should be true at all times. Each method defines pre-conditions
(invariants the method assumes) and post-conditions (invariants that the
method satisfies).
Encapsulation is hiding of the implementation details of an object. An
object's client is not interested in the implementation details as long
as the implementation complies to the external contract.
Abstraction and Encapsulation are complementary concepts. Abstraction
focuses on the external behavior and encapsulation focuses on the
implementation that gives rise to the external behavior.
You need to keep finding yourself, a little more each day, that real, unlimited Fletcher Seagull. He’s your instructor. You need to understand him and to practice him.
- Richard Bach in “Jonathan Livingston Seagull”
“I don’t understand how you manage to love a mob of birds that just tried to kill you.”
“Oh, Fletch, you don’t love that! You don’t love hatred and evil, of course. You have to practice and see the real gull, the good in every one of them, and to help them see it in themselves. That’s what I mean by love. It’s fun, when you get the knack of it.”
- Richard Bach in “Jonathan Livingston Seagull”
Freedom is the very nature of ... being...whatever stands against that freedom must be set aside, be it ritual or superstition or limitation in any form
- Richard Bach in “Jonathan Livingston Seagull”
You have the freedom to be yourself, your true self, here and now, and nothing can stand in your way. It is the Law
- Richard Bach in “Jonathan Livingston Seagull”
…Jonathan said the time had come to return to the Flock.
“We’re not ready!... We’re not welcome! We’re Outcast! We can’t force ourselves to go where we’re not welcome, can we?”
“We’re free to go where we wish and to be what we are,” Jonathan answered
Jonathan’s students found “it was easier… to practice high performance than it was to understand the reason behind it”.
- Richard Bach in “Jonathan Livingston Seagull”
“…Those gulls who you came from are standing on the ground, squawking and fighting among themselves. They’re a thousand miles from heaven …they can’t see their wing tips! Stay here. Help the new gulls here, the ones who are high enough to see what you have to tell them.” Jonathan replied “What If Chiang (the master expert gull) had gone back to his old worlds? Where would you have been today?”
…Jonathan found himself thinking time and again of the Earth from which he had come. If he had known there just a tenth, just a hundredth, of what he knew here, how much more life would have meant! He stood on the sand and fell to wondering if there was a gull back there who might be struggling to break out of his limits, to see the meaning of flight beyond a way of travel to get a breadcrumb from a rowboat. Perhaps there might even have been one made Outcast for speaking his truth in the face of the Flock. And the more Jonathan practiced his kindness lessons, and the more he worked to know the nature of love, the more he wanted to go back to Earth. For in spite of his lonely past, Jonathan Seagull was born to be a instructor, and his own way of demonstrating love was to give something of truth that he had seen to a gull who asked only a chance to see truth for himself.
“It’s strange. The gulls who scorn (to despise) perfection for the sake of travel go nowhere, slowly. Those who put aside travel for the sake of perfection go anywhere, instantly….”
- Richard Bach in “Jonathan Livingston Seagull”
Good instincts usually tell you what to do long before your head has figured it out.
- Michael Burke
“All the art of living lies in a fine mingling of letting go and holding on.”
- Henry Ellis through Julie911
“The mind can go in a thousand directions, but on this beautiful path, I walk in peace. With each step, the wind blows. With each step, a flower blooms.”
- Thich Nhat Hanh through Julie911
“Slow down and enjoy life. It’s not only the scenery you miss by going too fast — you also miss the sense of where you are going and why.”
- Eddie Cantor through Julie911
“Why is patience so important? Because it makes us pay attention.”
- Paulo Coelho through Julie911
“How people treat you is their karma; how you react is yours.”
- Wayne W. Dyer through Julie911
“The most significant gifts are the ones most easily overlooked. Small, everyday blessings: woods, health, music, laughter, memories, books, family, friends, second chances, warm fireplaces, and all the footprints scattered throughout our days.”
- Sue Monk Kidd
“That’s what learning is, after all; not whether we lose the game, but how we lose and how we’ve changed because of it, and what we take away from it that we never had before, to apply to other games. Losing, in a curious way is winning.”
- “The Bridge Across Forever” by Richard Bach through Julie911
Download word document file here.
| Target | Purpose |
| compile | generate class files from .java files |
| test | Run test cases. If need be compile main and test source (all source in ${base-dir}/src/test/java confirming to **/*Test.java, **/Test*.java **/*TestCase.java and excludes **/Abstract*Test.java and **/Abstract*TestCase.java |
| test-compile | Compile only test source and not execute it |
| package | Make the jar/war/ear, deploy into target directory |
| install | deploy the jar/war/ear (build if necessary) into the local repository (~/.m2/repository) |
| clean | Removes target directory |
| eclipse:eclipse | Generate eclipse .project files |
Wildcards:
Consider the a method that prints all the elements of a collection (pre 1.5 code):
private static void printCollection(Collection objectCollection)
{
for (Object element: objectCollection)
{
System.out.println( element );
}
}
The above code when invoked as follows:
printCollection( Arrays.asList( new String[] {"test", "another test"} ) );
gives the following output:
test
another test
Lets write the same method using generics:
private static void printCollection(Collection<Object> objectCollection)
{
for (Object element: objectCollection)
{
System.out.println( element );
}
}
But now the same invocation ( printCollection( Arrays.asList( new String[] {"test", "another test"} ) ); ) will lead to a compile time error! :
PrintCollection.java:8: printCollection2(java.util.Collection<java.lang.Object>) in PrintCollection cannot be applied to (java.util.List<java.lang.String>)
printCollection2( Arrays.asList( new String[] { "test", "another test" }) );
^
1 error
This is because when the String[] is converted to a List, it returns a List<String>. And a List<String> is not a List<Object> (although String is a Object. Why? Read this)
To resolve this issue, we could use…wildcards as follows:
private static void printCollection2(Collection<?> objectCollection)
{
for (Object element: objectCollection) // compiler error will result for objectCollection.add(anything). Because Collection<?> specifies an unknown element type<terminology>. And the compiler has no way to check the type of “anything” against the unknown type. Null is exception.
{
System.out.println( element );
}
}
List<Student> is NOT a List<Person>.
Isa relationships do not apply for generics. Why? Check the following listing:
1 List<String> nameList = new ArrayList<String>();
2 List<Object> objectList = nameList; // Now objectList is an alias for nameList
3 obecjtList.add( new Student() ); // a Student would have been added to a List<String>
Assuming the above code snippet would compile (it will not), it has introduced a Student object into a List of Strings. This violates one of the very basic reasons for having generics (type checking). So Isa relationships do not work with generics.
BTB, the above code will fail compilation with the following compiler error:
NoIsaInGenerics.java:8: incompatible types
found : java.util.List<java.lang.String>
required: java.util.List<java.lang.Object>
List<Object> objectList = nameList; // Now objectList is an alias for nameList
^
NoIsaInGenerics.java:9: cannot find symbol
symbol : variable obecjtList
location: class NoIsaInGenerics
obecjtList.add( new Student() ); // a Student would have been added to a List<String>
^
2 errors
A custom parametrized type:
Consider the following oversimplified DAO interfaces:
public interface StudentDAO
{
Student getStudent( Long studentId );
}
class Student
{
private Long id;
private String name;
// accessors and mutators
}
The above interface is specific for Student. But the same interfaces will hold good for other entities too, like Professor, Course etc... If the interfaces like the above are to be implemented, then there would be a Professor getProfessor( Long professorId ), Course getCourse( Long courseId). This is redundant, violates the DRY (Do not Repeat Yourself) principle. Since there is a getEntity() method is all the cases, the above interface can be written using generics as follows:
public interface DataAccessInterface<T> // 1 Parameterized type 2 T is formal type paramter
{
T getEntity( Long EntityKey ); // 3 T can be used where ordinary types can be used
}
The above DAO interface will be used as follows:
DataAccessInterface<Student> studentDAO; // 4 Student is actual type argument
Now, DataAccessInterface<T> is a parameterized type, T is the name of the formal type paramter. After T has been declared in the interface declaration, it can be used instead of normal types throughout the interface declaration.
When a reference to a parameterized type is declared (at 4 above), the actual type to be passed to the formal types is also specified. At this time, all occurrences of the formal type (T) will be replaced by the actual type (Student).