a MIDlet for personal timeboxing
I wrote a small, very very simple MIDlet for time boxing since more than one person mentioned in last weeks that it would be nice to use such an application.
It’s a MIDP 2.0 app and it should work on any phone, on my N95 works fine. Depending on the number of downloads and feedbacks maybe I’ll improve it. (UI is poor, no customization possible for instance…)
What If Apple Has Sold Fewer Than 1 Million iPhones?
I’m a bit sad about this news, reported here,
What If Apple Has Sold Fewer Than 1 Million iPhones
AT&T (T) announced today that it had only activated 146,000 Apple (AAPL) iPhones the first day that they were on sale. And, investment bank CIBC said that sales of the handset have slowed considerably in the last 10 days. CIBC said that AT&T Wireless stores had plenty of supply and little traffic.
The research call explains that customers are disappointed with Apple’s connection speed. It goes on to speculate that Apple and AT&T may be rushing to get out a 3G device by Christmas.
If the information is accurate, it means that the quarter that will be reported about 90 days from now could be a significant disappointment, and that eyes will be on Apple’s earnings report this week for info on how the device has sold in July.
Douglas A. McIntyre
Especially cos my friend and former team lead, Ed Schepis, is not gonna reach his objectives on his fantastic website, OneMillionIphones
Inheritance is not OO, template methods are evil
My first coach Bruno always said that Inheritance doesn’t imply Object Oriented and he’s absolutely right. An abstract class necessarily implies inheritance and I really don’t like abstract classes! I rather prefer to use dependency injection, inheritance between classes just leads to the highest level of coupling that you can introduce.
Right after the university I was abusing of it, then day by day fortunately I started to use interfaces rather than that. It’s strange, looks like that at the university they really love that kind of stuff, I was doing some code reviews in the last weeks for new graduates applying to TW, you know what: a good number of them were (ab)using of abstract classes with no sense, instead of using Interfaces.
A common usage of abstract class is for template methods pattern, Martin wrote an article about this already. I really hate any framework that forces you to call a super implementation. What about the design of Junit 3! What about Struts Actions!!! What’s doing the super class? Why do I have to call super (base) something? It just smells.
Here there’s a good article by Alex Miller on how to remove template methods and why template methods are evil, I just can’t add nothing more.
But what to do then, when you need to call something before or after? Aspects maybe, Interceptors, Annotations (Java), Attributes(C#).
TestNG has some really interesting annotations like the BeforeClass:
package example1; import org.testng.annotations.*; public class SimpleTest { @BeforeClass public void setUp() { } @Test(groups = { "fast" }) public void aFastTest() { System.out.println("Fast test"); } @Test(groups = { "slow" }) public void aSlowTest() { System.out.println("Slow test"); } }
Aspectwerkz is AOP with annotations, so, here an example:
package testAOP;import org.codehaus.aspectwerkz.joinpoint.JoinPoint; public class MyAspectWithAnnotations { /** * @Before execution(* testAOP.HelloWorld.greet(..)) */ public void beforeGreeting(JoinPoint joinPoint) { System.out.println("before greeting..."); } /** * @After execution(* testAOP.HelloWorld.greet(..)) */ public void afterGreeting(JoinPoint joinPoint) { System.out.println("after greeting..."); } }
Spring is also another well known framework that plays with this stuff, in the reference guide they say:
So much for the pros and cons of each style then: which is best? If you are not using Java5 (or above) then
clearly the XML-style is the best because it is the only option available to you. If you are using Java5+, then
you really will have to come to your own decision as to which style suits you best. In the experience of the
Spring team, we advocate the use of the @AspectJ style whenever there are aspects that do more than simple
“configuration” of enterprise services. If you are writing, have written, or have access to an aspect that is not
part of the business contract of a particular class (such as a tracing aspect), then the XML-style is better.
I’m not sure about this, xml writing is voluntarily not supported by this blog syntax highlighter, so I’m not pasting any example
So, finally, the tip is, do not extend, implement.
Pragmatic tips on wordpress
I’ve generated the fortune files from the old good pragmatic tips, in order to use them you need the fortune wordpress widget. And this is the main reason also for the restyling of the layout of my blog… I guess the 4th… My previous theme wasn’t widget compatible… That generated a widget obsession, so I have a flickr and a last.fm widget here on the right now…