I've been working quite a lot in Java. Although this is part of the university course, we actually have some QAs we need to satisfy, and so the quality of the code matters. Most modern languages are Turing Complete, so it is rarely about what you can do, but rather how you can do it. Every now and again (more often than not actually), I came across painfully annoying Java constructs which make the code that much harder to read and write. Like today, I tried to instantiate new date. In C# and probably any other language:
1 |
new Date(theYear, theMonth, theDay); |
Since Java 7, this kind of construct is depreciated. Instead, one should use:
1 2 3 4 5 |
Calendar myCal = Calendar.getInstance(); myCal.set(Calendar.YEAR, theYear); myCal.set(Calendar.MONTH, theMonth); myCal.set(Calendar.DAY_OF_MONTH, theDay); Date theDate = myCal.getTime(); |