Monday, March 30, 2015

Favor static member classes over non static

A nested class is a class defined within another class. A nested class should exist only to serve its enclosing class. If a nested class would be useful in some other context, then it should be a top-level class. There are four kinds of nested classes: static member classes, nonstatic member classes, anonymous classes, and local classes. All but the first kind are known as inner classes. This item tells you when to use which kind of nested class and why.


A static member class is the simplest kind of nested class. It is best thought of as an ordinary class that happens to be declared inside another class and has access to all of the enclosing class’s members, even those declared private. A static member class is a static member of its enclosing class and obeys the same accessibility rules as other static members. If it is declared private, it is accessible only within the enclosing class, and so forth. 


If you declare a member class that does not require access to an enclosing instance, always put the static modifier in its declaration, making it a static rather than a nonstatic member class. If you omit this modifier, each instance will have an extraneous reference to its enclosing instance. Storing this reference costs time and space, and can result in the enclosing instance being retained when it would otherwise be eligible for garbage collection. And should you ever need to allocate an instance without an enclosing instance, you’ll be unable to do so, as nonstatic member class instances are required to have an enclosing instance. 

Saturday, March 28, 2015

Open4Education: Introdução ao JSF 2


Segurança física e psicológica

Não se pode viver sem segurança; a primeira, a mais básica exigência animal, é que haja segurança física. Precisa-se ter uma casa, comida e roupas. Entretanto, a maneira psicológica como utilizamos tal necessidade de segurança, gera caos dentro e fora de nós. A psique, que é a mesma estrutura do pensamento, também quer estar segura interiormente, em todos os seus relacionamentos. Então começa o problema. É preciso haver segurança física para todos, não só para uns poucos. No entanto, essa segurança física para todos é negada, quando se busca segurança psicológica por meio de nações, por meio de religiões, por meio da família. - Krishnamurti, The Flight of the Eagle, p57