Learning #Java is a never-ending story for me: I just learned about " double-brace initialization", which creates an anonymous class derived from the specified class (the outer braces), and provides an initialiser block within that class (the inner braces). e.g. 👇
For example, this code:
List<Integer> l = new ArrayList<>();
l.add(1);
l.add(2);
May look like:
new ArrayList<Integer>() {{
add(1);
add(2);
}};
Or it may look like constructor with named parameters:
public class User {
String name;
String surname;
String email;
}
User user = new User() {{
name = "John";
surname = "Doe";
}};
Note that an effect of using this double brace initialisation is that you're creating anonymous inner classes. The created class has an implicit `this` pointer to the surrounding outer class.
Whilst not usually a problem, it can cause grief in some circumstances, e.g. when serialising or garbage collecting, and it's worth being aware of this.
Institutions will try to preserve the problem to which they are the solution.
-- Clay Shirky
👇
The Shirky Principle suggests that complex solutions - a company, an industry, or a technology - can become so focused on the problem that they are solving, that they can inadvertently perpetuate the problem itself.
This may be deliberate (a company striving to find new nuances to a problem which justify continued development of a solution), or inadvertent (being unable or unwilling to accept or build a solution which solves the problem completely or obviates it).
I wouldn't say I like @Transactional spring tests and don't recommend using them. I prefer cleaning/populating db with @Sql annotation. To do this I usually create 2 files:
📍resources/clear.sql
📍resources/insert_data.sql
👇
The Pareto Principle suggests that in some cases, the majority of results come from a minority of inputs: 👇
📍80% of a certain piece of software can be written in 20% of the total allocated time (conversely, the hardest 20% of the code takes 80% of the time)
📍20% of the effort produces 80% of the result
📍20% of the work creates 80% of the revenue
📍20% of the bugs cause 80% of the crashes
📍20% of the features cause 80% of the usage
A management concept developed by Scott Adams (creator of the Dilbert comic strip), the Dilbert Principle is inspired by The Peter Principle.
Under the Dilbert Principle, employees who were never competent are promoted to management in order to limit the damage they can do. Adams first explained the principle in a 1995 Wall Street Journal article, and expanded upon it in his 1996 business book, The Dilbert Principle.
Today I decided to check the performance of different ways of converting an int variable to a String object in Java. 🧵👇
I searched on Stackoverflow:
📍Integer.toString(i)
📍"" +i
📍String.valueOf(i)
📍new StringBuilder().append(i).toString() - a bit strange way, but it was one of the suggestions😄
I have implemented 4 benchmarks using the JMH framework (see pictures).
The more talented and effective IT engineers are the ones most likely to leave - to evaporate ... [those who tend to] remain behind [are] the 'residue' — the least talented and effective IT engineers. 🤓
--Bruce F. Webster
The "Dead Sea Effect" suggests that in any organisation, the skills/talent/efficacy of engineers is often inversely proportional to their time in the company.
Typically, highly skilled engineers find it easy to gain employment elsewhere and are the first to do so.
Engineers who have obsolete or weak skills will tend to remain with the company, as finding employment elsewhere is difficult.