파일-옵션-고급-이 워크시트의 표시옵션-시트방향바꾸기 체크해제 하세요

Posted by 타다키치
,

-행복의 기원(서은국 저)


행복에 대한 심리학 입문서다. 이러한 분야에 관심이 있으면 입문서로 이걸 먼저 읽고, 책에서 소개된 다른 책들을 읽어나가면 좋을 것 같다. 그런데 저자가 너무 쉽게 쓰려는 마음이 앞서나갔는지 구어체가 많아서 오히려 몰입을 방해하는 측면이 있었다. 이런 책을 많이 읽어봤다면 굳이 읽지 않아도 될 것 같다.


소제목에서 보이듯, 내용은 뻔하다(뻔하게 느껴질 만큼 쉽게 풀어 쓰는게 어려운 일이긴 하지만). 원시인때부터 인간의 생존과 번식에 밀접한 행위를 자주 하는게 행복의 지름길이라는 거다. 가령 좋아하는 사람과 뭘 먹는다던지, 좋아하는 사람과 섹스를 한다던지.


평소의 내 생각과 비슷한 점이 많아(제대로 이야기를 하자면, 여러 책및 고민을 통해 구축된 내 생각) 잘 읽혔다. 좀 과장해서 말하면, 인간은 결국 유전자에 따라 사는 기계가 아닐까 하는 것.


책에서의 주요 대목을 소개해보자면 다음과 같다.


-행복은 겍관적인 삶의 조건들에 의해 크게 좌우되지 않는다.

- 행복의 개인차를 결정적으로 좌우하는 것은 그가 물려받은 유전적 특성, 구체적으로는 외향성이라는 성격 특질이다.

-행복은 기쁨의 강도가 아니라 빈도다.

-행복해지려는 노력은 키가 커지려는 노력만큼 덧없다.


책에서는 사회적으로 활발한 사람이 행복할 가능성이 크다고 한다. 그런데 나는 딱히 사람들하고 어울리는 것을 좋아하진 않으며, 회사에선 일부러 점심을 혼자 먹으러 다니기도 한다. 회사에서 사람들이랑 복작대면 피곤해서, 혼자있을 수 있는 시간이 필요하기 때문이다. 그렇지만 혼자 있는 것을 좋아하는 편이라고 해서 특별히 우울증이 있거나 그러진 않는다. 그리고 매일마다 혼자 있고 싶진 않다. 이 부분은 스스로 좀 더 고민이 필요해 보인다.



Posted by 타다키치
,

https://docs.oracle.com/javase/tutorial/java/generics/inheritance.html

Generics, Inheritance, and Subtypes

What type of argument does it accept? By looking at its signature, you can see that it accepts a single argument whose type is Box<Number>. But what does that mean? Are you allowed to pass in Box<Integer> or Box<Double>, as you might expect? The answer is "no", because Box<Integer> and Box<Double> are not subtypes of Box<Number>.

This is a common misunderstanding when it comes to programming with generics, but it is an important concept to learn.

diagram showing that Box<Integer> is not a subtype of Box<Number>
Box<Integer> is not a subtype of Box<Number> even though Integer is a subtype of Number.

Note: Given two concrete types A and B (for example, Number and Integer), MyClass<A> has no relationship to MyClass<B>, regardless of whether or not A and B are related. The common parent of MyClass<A> and MyClass<B> is Object.

For information on how to create a subtype-like relationship between two generic classes when the type parameters are related, see Wildcards and Subtyping.



https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html

Target Types

The Java compiler takes advantage of target typing to infer the type parameters of a generic method invocation. The target type of an expression is the data type that the Java compiler expects depending on where the expression appears. Consider the method Collections.emptyList, which is declared as follows:

static <T> List<T> emptyList();

Consider the following assignment statement:

List<String> listOne = Collections.emptyList();

This statement is expecting an instance of List<String>; this data type is the target type. Because the method emptyList returns a value of type List<T>, the compiler infers that the type argument T must be the value String. This works in both Java SE 7 and 8. Alternatively, you could use a type witness and specify the value of T as follows:

List<String> listOne = Collections.<String>emptyList();

However, this is not necessary in this context. It was necessary in other contexts, though. Consider the following method:

void processStringList(List<String> stringList) {
    // process stringList
}

Suppose you want to invoke the method processStringList with an empty list. In Java SE 7, the following statement does not compile:

processStringList(Collections.emptyList());

The Java SE 7 compiler generates an error message similar to the following:

List<Object> cannot be converted to List<String>

The compiler requires a value for the type argument T so it starts with the value Object. Consequently, the invocation of Collections.emptyList returns a value of type List<Object>, which is incompatible with the method processStringList. Thus, in Java SE 7, you must specify the value of the value of the type argument as follows:

processStringList(Collections.<String>emptyList());

This is no longer necessary in Java SE 8. The notion of what is a target type has been expanded to include method arguments, such as the argument to the method processStringList. In this case, processStringList requires an argument of type List<String>. The method Collections.emptyList returns a value of List<T>, so using the target type of List<String>, the compiler infers that the type argument T has a value of String. Thus, in Java SE 8, the following statement compiles:

processStringList(Collections.emptyList());

See Target Typing in Lambda Expressions for more information.



https://docs.oracle.com/javase/tutorial/java/generics/subtyping.html

Wildcards and Subtyping

Given that Integer is a subtype of Number, what is the relationship between List<Integer> and List<Number>?

diagram showing that the common parent of List<Number> and List<Integer> is the list of unknown type
The common parent is List<?>.

Although Integer is a subtype of NumberList<Integer> is not a subtype of List<Number> and, in fact, these two types are not related. The common parent of List<Number> and List<Integer> is List<?>.

In order to create a relationship between these classes so that the code can access Number's methods through List<Integer>'s elements, use an upper bounded wildcard:

List<? extends Integer> intList = new ArrayList<>();
List<? extends Number>  numList = intList;  // OK. List<? extends Integer> is a subtype of List<? extends Number>

Because Integer is a subtype of Number, and numList is a list of Number objects, a relationship now exists between intList (a list of Integer objects) and numList. The following diagram shows the relationships between several List classes declared with both upper and lower bounded wildcards.

diagram showing that List<Integer> is a subtype of both List<? extends Integer> and List<?super Integer>. List<? extends Integer> is a subtype of List<? extends Number> which is a subtype of List<?>. List<Number> is a subtype of List<? super Number> and List>? extends Number>. List<? super Number> is a subtype of List<? super Integer> which is a subtype of List<?>.
A hierarchy of several generic List class declarations.

The Guidelines for Wildcard Use section has more information about the ramifications of using upper and lower bounded wildcards.



Type Erasure

Type erasure ensures that no new classes are created for parameterized types; consequently, generics incur no runtime overhead.




Erasure of Generic Types

During the type erasure process, the Java compiler erases all type parameters and replaces each with its first bound if the type parameter is bounded, or Object if the type parameter is unbounded.

In the following example, the generic Node class uses a bounded type parameter:

public class Node<T extends Comparable<T>> {

    private T data;
    private Node<T> next;

    public Node(T data, Node<T> next) {
        this.data = data;
        this.next = next;
    }

    public T getData() { return data; }
    // ...
}

The Java compiler replaces the bounded type parameter T with the first bound classComparable:

public class Node {

    private Comparable data;
    private Node next;

    public Node(Comparable data, Node next) {
        this.data = data;
        this.next = next;
    }

    public Comparable getData() { return data; }
    // ...
}

Non-Reifiable Types

Non-Reifiable Types

reifiable type is a type whose type information is fully available at runtime. This includes primitives, non-generic types, raw types, and invocations of unbound wildcards.

Non-reifiable types are types where information has been removed at compile-time by type erasure — invocations of generic types that are not defined as unbounded wildcards. A non-reifiable type does not have all of its information available at runtime. Examples of non-reifiable types are List<String> and List<Number>; the JVM cannot tell the difference between these types at runtime. As shown in Restrictions on Generics, there are certain situations where non-reifiable types cannot be used: in an instanceof expression, for example, or as an element in an array.

Heap Pollution

Heap pollution occurs when a variable of a parameterized type refers to an object that is not of that parameterized type. This situation occurs if the program performed some operation that gives rise to an unchecked warning at compile-time.






Posted by 타다키치
,