Edited, memorised or added to reading queue

on 16-Nov-2014 (Sun)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 149625811

Tags
#bloch-effective-java-2ed #java
Question
When should you be alert to memory leaks in an object? When it does what?
Answer
when it manages its own memory

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625822

Tags
#bloch-effective-java-2ed #java
Question
WeakHashMap is useful only if the desired lifetime of cache entries is determined by external references to the [key or value]
Answer
key, not the value

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625833

Tags
#bloch-effective-java-2ed #java
Question
A good way to prevent memory leak from listeners and other callbacks is to store them as [...] in [...] for example
Answer
keys in WeakHashMap

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625854

Tags
#bloch-effective-java-2ed #java
Question
is super.finalize(); called automatically?
Answer
no

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625870

Tags
#bloch-effective-java-2ed #equality #java
Question

Suppose we have a class that tries to cooperate with String. What is wrong with it?


public final class CaseInsensitiveString {

    private final String s;

    @Override public boolean equals(Object o) {
        if (o instanceof CaseInsensitiveString)
            return s.equalsIgnoreCase(((CaseInsensitiveString) o).s);
        if (o instanceof String)
            return s.equalsIgnoreCase((String) o);
       return false;
    }

    // rest of the code
}
Answer
It violates symmetry of equality - "BlaBla".equals(whatever) will do case-sensitive comparison, even if whatever is CaseInsensitiveString (in which case the result is false)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625881

Tags
#bloch-effective-java-2ed #equality #java
Question

Suppose we have a class


public class Point {
    private final int x;
    private final int y;

    @Override public boolean equals(Object o) {
	if (!(o instanceof Point))
	    return false;
	Point p = (Point)o;
	return p.x == x && p.y == y;
    }
    // Remainder omitted
}

and a subclass

public class ColorPoint extends Point {
    private final Color color;
    // Remainder omitted
}

what are the consequences of NOT implementing equals() method on ColorPoint?

Answer
equals() contract is not violated, but all color information is ignored in equality comparisons

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149625984

Tags
#bloch-effective-java-2ed #java
Question

Suppose we have a class


public class Point {
    private final int x;
    private final int y;

    @Override public boolean equals(Object o) {
	if (!(o instanceof Point))
	    return false;
	Point p = (Point)o;
	return p.x == x && p.y == y;
    }
    // Remainder omitted
}

and a subclass

public class ColorPoint extends Point {
    private final Color color;

    @Override public boolean equals(Object o) {
      if (!(o instanceof ColorPoint))
         return false;
      return super.equals(o) && ((ColorPoint) o).color == color;
     }

    // Remainder omitted
}

what are the consequences of implementing equals() method on ColorPoint like above?

Answer
It violates symmetry. You get different results when comparing a point to a color point and vice versa.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626013

Tags
#bloch-effective-java-2ed #java
Question

Suppose we have a class


public class Point {
    private final int x;
    private final int y;

    @Override public boolean equals(Object o) {
	if (!(o instanceof Point))
	    return false;
	Point p = (Point)o;
	return p.x == x && p.y == y;
    }
    // Remainder omitted
}

and a subclass

public class ColorPoint extends Point {
    private final Color color;

    @Override public boolean equals(Object o) {
	if (!(o instanceof Point))
	    return false;
	// If o is a normal Point, do a color-blind comparison
	if (!(o instanceof ColorPoint))
	    return o.equals(this);
	// o is a ColorPoint; do a full comparison
	return super.equals(o) && ((ColorPoint)o).color == color;
    }
    // Remainder omitted
}

what are the consequences of implementing equals() method on ColorPoint like above?

Answer

It violates transitivity, for example:


ColorPoint p1 = new ColorPoint(1, 2, Color.RED);
Point p2 = new Point(1, 2);
ColorPoint p3 = new ColorPoint(1, 2, Color.BLUE);

Now p1.equals(p2) and p2.equals(p3) return true, while p1.equals(p3) returns false, a clear violation of transitivity. The first two comparisons are “color-blind,” while the third takes color into account.


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626024

Tags
#bloch-effective-java-2ed #java
Question

What are the consequences of implementing equals() method like this (using getClass() instead of using instanceof)?


public class Point {
     @Override public boolean equals(Object o) {
     if (o == null || o.getClass() != getClass())
         return false;
     Point p = (Point) o;
     return p.x == x && p.y == y;
 }
}
Answer
Liskov substitution principle is violated. For example, we cannot mix Points and objects of any subclass of Point in collections, because Points and objects of any subclass of Point will never be equal, even if subclassing is NOT adding any value field.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626035

Tags
#bloch-effective-java-2ed #java
Question

What is a better way of implementing ColorPoint to avoid problems with equals() method?

public class Point {
    private final int x;
    private final int y;

    @Override public boolean equals(Object o) {
	if (!(o instanceof Point))
	    return false;
	Point p = (Point)o;
	return p.x == x && p.y == y;
    }
    // Remainder omitted
}
public class ColorPoint extends Point {
    private final Color color;

    // Remainder omitted
}
Answer

Use composition, not inheritance:

public class ColorPoint {
    private final Point point;
    private final Color color;

    // Remainder omitted
}

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626046

Tags
#bloch-effective-java-2ed #equality #java
Question
Under what circumstances you can add equals() method to a subclass without causing problems?
Answer
When the superclass is not instantiable (abstract)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626165

Tags
#bloch-effective-java-2ed #java
Question
How to compute hashcode of a long?
Answer
(int) (f ^ (f >>> 32))

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626507

Tags
#bloch-effective-java-2ed #java
Question
How to calculate hash code of a double?
Answer
Double.doubleToLongBits(f) and then calculate hash code of the resulting long.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626518

Tags
#bloch-effective-java-2ed #java
Question
How to combine hash codes from different fields of an object?
Answer
Initially, result = 17; // any non zero value
then result = 31 * result + hashCodeOfAField; // for each field

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626529

Tags
#bloch-effective-java-2ed #java
Question
clone() creates an object without [...]
Answer
without calling the constructor

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626566

Tags
#bloch-effective-java-2ed #java
Question
what does the Object's clone() method return? Describe 2 cases
Answer
it returns a copy of the object of the correct (runtime) class and copies fields as if by (assignment) = operator if actual class implements Cloneable, otherwise it throws CloneNotSupportedException.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626577

Tags
#bloch-effective-java-2ed #java
Question
the clone architecture is incompatible with normal use of [...] fields referring to mutable objects
Answer
final

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626604

Tags
#bloch-effective-java-2ed #java
Question
what methods does Cloneable interface have?
Answer
none, not even clone() - you are expected to provide public clone() though on classes that implement Cloneable

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626624

Tags
#bloch-effective-java-2ed #java
Question
Because of its many shortcomings, some expert programmers simply choose never to override the clone() method and never to invoke it except, perhaps, to copy [...]
Answer
arrays

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626651

Tags
#bloch-effective-java-2ed #java
Question
What is wrong with this implementation of compareTo()?

public int compareTo(PhoneNumber pn) {
    return lineNumber - pn.lineNumber;
}

Answer
if pn.lineNumber is large and negative, int substraction can overflow silently

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626678

Tags
#bloch-effective-java-2ed #java
Question
Why is it wrong?
public static final Thing[] VALUES = { ... };
Answer
Non-zero length arrays are always mutable

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626721

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Generic classes and interfaces are collectively known as [...].
Answer
generic types

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626778

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What element can you put into Collection<?> ?
Answer
only null

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626789

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How can you use generics in class literals, e.g. XX.class or (y instanceof XX) ?
Answer
You can't. For example List<String>.class is illegal. You have to use raw types.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149626886

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How to cast raw type Set to typesafe Set using generics?

if (o instanceof Set) { // Raw type
  // here
}

Answer
Use unbounded wildcard type:

if (o instanceof Set) { // Raw type
  Set<?> m = (Set<?>) o; // Wildcard type
  // rest of the code
}


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627007

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What is the name of the property of arrays that allow us to cast Long[] to Object[], like here?

// Fails at runtime!
Object[] objectArray = new Long[1];
objectArray[0] = "I don't fit in"; // Throws ArrayStoreException

Answer
arrays are covariant

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627018

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What is the name of the property of parametrized List that causes compilation error (unlike in arrays)?

// Won't compile!
List<Object> ol = new ArrayList<Long>(); // Incompatible types
ol.add("I don't fit in");

Answer
generics are invariant

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627064

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create an array of generic type, e.g. new List<E>[] ?
Answer
No

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627082

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create array of a parametrized type new List<String>[] ?
Answer
No.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627093

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Is it legal to create array of a type parameter new E[] ?
Answer
No.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627104

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Give an example how type safety could be compromised if it was legal to create arrays of parametrized types (but it is not legal).
Answer
  1. You could create an array of lists of strings:
    List<String>[] stringLists = new List<String>[1]; // this part is not legal and wouldn't compile
  2. Because arrays are covariant, you can store the array into a variable of Object[] type and then store an element of type List<Integer> (or really List<anything>) as an element of the original array without causing ArrayStoreException because at runtime List<String> and List<Integer> are simply lists
  3. So, we are in trouble - List<Integer> is stored where the compiler thought it was List<String>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627115

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Types such as E, List<E>, and List<String> are technically known as nonreifiable types. Intuitively speaking, a non-reifiable type is one whose [...]
Answer
runtime representation contains less information than its compile-time representation.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627126

Tags
#bloch-effective-java-2ed #java #java-generics
Question
The only parameterized types that are reifiable are [...]. It is legal, though infrequently useful, to create arrays of such types.
Answer
unbounded wildcard types such as List<?> and Map<?,?>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627141

Tags
#bloch-effective-java-2ed #java #java-generics
Question
For generic methods, the type parameter list, which declares the type parameter, goes [...].
Answer
between the method’s modifiers and its return type

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627152

Tags
#bloch-effective-java-2ed #java #java-generics
Question

public interface Comparable<T> {
   int compareTo(T o);
}

The type bound <T extends Comparable<T>> may be read as [...]
Answer
for every type T that can be compared to itself (mutual comparability)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627167

Tags
#bloch-effective-java-2ed #java #java-generics
Question

// Wildcard type for parameter that serves as an E producer - produces Es onto a Stack from external Iterable
public void pushAll(Iterable<...> src) {
  for (E e : src)
    push(e);
}

what kind of bounded wildcard do we need here for Iterable (producer)?
Answer
Iterable<? extends E>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627180

Tags
#bloch-effective-java-2ed #java #java-generics
Question

// Wildcard type for parameter that serves as an E consumer - it consumes from the Stack to external collection
public void popAll(Collection<...> dst) {
  while (!isEmpty())
    dst.add(pop());
}

what kind of bounded wildcard do we need here for Collection (consumer)?
Answer
Collection<? super E>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627375

Tags
#bloch-effective-java-2ed #java #java-generics
Question
What does PECS mnemonic stand for?
Answer
producers extend, consumers super - it is about wildcard types

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627386

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Which is a better version?

public static <E> Set<E> union(Set<? extends E> input1, Set<? extends E> input2)  { /* .. */ }

public static <E> Set<? super E> union(Set<? extends E> input1, Set<? extends E> input2) { /* .. */ }

Answer
The first one is better. Do not use wildcard types as return types. Rather than providing additional flexibility for your users, it would force them to use wildcard types in client code.

public static <E> Set<E> union(Set<? extends E> input1, Set<? extends E> input2)  { /* .. */ }


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627401

Tags
#bloch-effective-java-2ed #java #java-generics
Question
If type inference does not work, like here:

public static <E> Set<E> union(Set<? extends E> s1, Set<? extends E> s2) { /* ... */ }

Set<Integer> integers = ... ;
Set<Double> doubles = ... ;
Set<Number> numbers = Union.union(integers, doubles); // does not compile

How can you make the program compile?
Answer
Use explicit type parameter:

Set<Number> numbers = Union.<Number>union(integers, doubles);


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627412

Tags
#bloch-effective-java-2ed #java #java-generics
Question
How would you fix the declaration using PECS rule?
public static <T extends Comparable<T>> T max(List<T> list)
Answer
public static <T extends Comparable<? super T>> T max(List<? extends T> list)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627423

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Comparables are always consumers, so you should always use [...] in preference to Comparable<T>.
Answer
Comparable<? super T>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627434

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Why would List<ScheduledFuture<?>> be rejected by a method:
public static <T extends Comparable<T>> T max(List<T> list)
but accepted (as intended) by this:
public static <T extends Comparable<? super T>> T max(List<? extends T> list)
?
Answer
java.util.concurrent.ScheduledFuture does not implement Comparable<ScheduledFuture>. Instead, it is a subinterface of Delayed, which extends Comparable<Delayed>. In other words, a ScheduledFuture instance isn’t merely comparable to other ScheduledFuture instances; it’s comparable to any Delayed instance, so we have to say Comparable<? super T>. Delayed is super of ScheduledFuture. It seems that the second part, List<? extends T> as a producer does not make any difference.

basically:
ScheduledFuture extends Comparable<Delayed>
where Delayed is super of ScheduledFuture

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627445

Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static <E> void swap(List<E> list, int i, int j);

How would you write it with a wildcard?
Answer
public static void swap(List<?> list, int i, int j);

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627456

Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static void swap(List<?> list, int i, int j);

How would you write it with a type parameter?
Answer
public static <E> void swap(List<E> list, int i, int j);

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627490

Tags
#bloch-effective-java-2ed #java #java-generics
Question
When a class literal is passed among methods to communicate both compile-time and runtime type information, it is called a [...]
Answer
type token

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149627501

Tags
#bloch-effective-java-2ed #java #java-generics
Question
Class was generified in release 1.5. The type of a class literal is no longer simply Class, but [...], for example object String.class is of type [...]
Answer
Class<T>, Class<String>

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







#odersky-programming-in-scala-2ed #scala
You can do anything in a trait definition that you can do in a class definition, and the syntax looks exactly the same, except:
  • a trait cannot have any “class” parameters
  • ​whereas in classes, super calls are statically bound, in traits, they are dynamically bound.
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

pdf

cannot see any pdfs




Flashcard 149632068

Tags
#odersky-programming-in-scala-2ed #scala
Question
What are the "class" parameters, the ones that traits cannot have (as opposed to classes)?
for example, in the class Point?
Answer
parameters passed to the primary constructor of a class, for example:
class Point(x: Int, y: Int)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 149632079

Tags
#odersky-programming-in-scala-2ed #scala
Question
What does it mean that whereas in classes, super calls are statically bound, in traits, they are dynamically bound?
Answer
If you write “super.toString” in a class, you know exactly which method implementation will be invoked. When you write the same thing in a trait, however, the method implementation to invoke for the super call is undefined when you define the trait. Rather, the implementation to invoke will be determined anew each time the trait is mixed into a concrete class.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







#biography #chemistry #economics #to-read
In four books written from 1921 to 1934, Soddy carried on a "campaign for a radical restructuring of global monetary relationships", [ 15 ] offering a perspective on economics rooted in physics—the laws of thermodynamics, in particular—and was "roundly dismissed as a crank". [ 15 ] While most of his proposals - "to abandon the gold standard, let international exchange rates float, use federal surpluses and deficits as macroeconomic policy tools that could counter cyclical trends, and establish bureaus of economic statistics (including a consumer price index) in order to facilitate this effort" - are now conventional practice, his critique of fractional-reserve banking still "remains outside the bounds of conventional wisdom". [ 15 ] Soddy wrote that financial debts grew exponentially at compound interest but the real economy was based on exhaustible stocks of fossil fuels. Energy obtained from the fossil fuels could not be used again. This criticism of economic growth is echoed by his intellectual heirs in the now emergent field of ecological economics. [ 15 ]
statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

Frederick Soddy - Wikipedia, the free encyclopedia
wn as The Last War and imagines a peaceful world emerging from the chaos. In Wealth, Virtual Wealth and Debt Soddy praises Wells’s The World Set Free . He also says that radioactive processes probably power the stars. Economics [ edit ] <span>In four books written from 1921 to 1934, Soddy carried on a "campaign for a radical restructuring of global monetary relationships", [ 15 ] offering a perspective on economics rooted in physics—the laws of thermodynamics , in particular—and was "roundly dismissed as a crank". [ 15 ] While most of his proposals - "to abandon the gold standard , let international exchange rates float, use federal surpluses and deficits as macroeconomic policy tools that could counter cyclical trends , and establish bureaus of economic statistics (including a consumer price index ) in order to facilitate this effort" - are now conventional practice, his critique of fractional-reserve banking still "remains outside the bounds of conventional wisdom". [ 15 ] Soddy wrote that financial debts grew exponentially at compound interest but the real economy was based on exhaustible stocks of fossil fuels. Energy obtained from the fossil fuels could not be used again. This criticism of economic growth is echoed by his intellectual heirs in the now emergent field of ecological economics . [ 15 ] Descartes' theorem [ edit ] He rediscovered the Descartes' theorem in 1936 and published it as a poem, "The Kiss Precise", quoted at Problem of Apollonius . The kissing cir