StringBuffer getText ()
{
return myText;
}
String getName ()
{
return myName;
}
Because every object variable in Java is a reference, explain why the first method has the potential to break the encapsulation of the object, while the second method does not.
template<class T>
void swap (T& a, T& b)
{
T tmp = a;
a = b;
b = tmp;
}
In Java, however, the following version of the method has no effect on the two values passed:
void swap (Object a, Object b)
{
Object tmp = a;
a = b;
b = tmp;
}
Describe two extreme programming practices from the reading given out last week, one with which you agree strongly and one with which you disagree or might find difficult to apply. For each, explain your feelings.