Archive for the ‘refactoring’ Category
Thinking Monkey would like to …

…point out the importance of critical thinking
The Problem
Everyone thinks; it is our nature to do so. But much of our thinking, left to itself, is biased, distorted, partial, uninformed or down-right prejudiced. Yet the quality of our life and that of what we produce, make, or build depends precisely on the quality of our thought. Shoddy thinking is costly, both in money and in quality of life. Excellence in thought, however, must be systematically cultivated.
A Definition
Critical thinking is that mode of thinking – about any subject, content, or problem – in which the thinker improves the quality of his or her thinking by skillfully taking charge of the structures inherent in thinking and imposing intellectual standards upon them.
The Result
A well cultivated critical thinker:
- raises vital questions and problems, formulating them clearly and precisely;
- gathers and assesses relevant information, using abstract ideas to interpret it effectively comes to well-reasoned conclusions and solutions, testing them against relevant criteria and standards;
- thinks openmindedly within alternative systems of thought, recognizing and assessing, as need be, their assumptions, implications, and practical consequences; and
- communicates effectively with others in figuring out solutions to complex problems.
Critical thinking is, in short, self-directed, self-disciplined, self-monitored, and self-corrective thinking. It presupposes assent to rigorous standards of excellence and mindful command of their use.
It entails effective communication and problem solving abilities and a commitment to overcome our native egocentrism and sociocentrism.
(source: http://www.criticalthinking.org)

lambdaj proves Java programs can be concise and even more elegant – in a functional kind of way
Is the Java programming language too verbose? lambdaj clearly proves the answer is NO.
Java programs usually are, because Java APIs (starting with the SDK) have built a poor reputation for the language.
This powerful library might help us change that in the future.

In a nutshell, lambdaj allows you to manipulate collections in a pseudo-functional and statically typed way.
This means you can reduce your stereotypical and superfluous ways of looping in Java to equivalent one-liners that are:
- much easier to understand (thus allowing you to focus on the actual problem not on details)
- type safe, being written in Java benefits from static typing (and all the good things that derive from here – clear semantics, compiler checks, tool support in refactoring)
- concise, less error prone, giving you more power per line of code
Below I pasted some usage examples from their site.
I did not add any explanations, because I’m sure you’ll understand what’s going on straight away:
List<Person> personsInFamily = asList(new Person("Domenico"),
new Person("Mario"), new Person("Irma"));
forEach(personsInFamily).setLastName("Fusco");
List<Person> sortedByAgePersons = sort(personsInFamily, on(Person.class).getAge());
List<Integer> biggerThan3 = filter(greaterThan(3), asList(1, 2, 3, 4, 5));
List<Integer> ages = extract(personsInFamily, on(Person.class).getAge());
Map<String, Person> personsByName = index(personsInFamily,
on(Person.class).getFirstName());
Person me = new Person("Mario", "Fusco", 35);
Person luca = new Person("Luca", "Marrocco", 29);
Person biagio = new Person("Biagio", "Beatrice", 39);
Person celestino = new Person("Celestino", "Bellone", 29);
List<Person> meAndMyFriends = asList(me, luca, biagio, celestino);
Group<Person> group = group(meAndMyFriends, by(on(Person.class).getAge()));
List<Person> oldFriends = filter(having(on(Person.class).getAge(), greaterThan(30)),
meAndMyFriends);
I really look forward to use this powerful tool!