![]() |
Tags
|
|
May 23rd, 2007
I came across a 10-year old presentation on Java - less interestering, I flicked quickly over the pages, but this slide made me stop:
Object-Oriented Benefits
• Better software design
– different way of thinking about software
– software can more closely models real world problem being
addressed
– domain experts can more easily participate in initial software design
• Easier to maintain
– problems are easier to isolate
– changes are more localized
• Easier to extend
– easy to make extensions to existing functionality
• Less code to write
– more likely to reuse code from other applications
– more likely to find commercial code (class libraries) that can be
used for portions of an application
I think this is a good writeup of the alleged advantages and capabilities of OO from the time where OO was not yet 100% mainstream. Did this live up in reality? I doubt that. The tend towards (or back to) more functional languages seems to be an indication. The more I hit the limits in Java the more I find myself imitating functional programming techniques in Java code - rarely pretty code you get by doing that. Irony or just the prove that be all keep learning: The author from the presentation cited above is now touring whith some JRuby slides
Posted in
Java |
No Comments »
May 7th, 2007
A while ago I visited this already. Now I think that it is not that bad, at least as I know now how to fix it. A valid remark is of course, why not doing it right in first place, but actually this is why I changed my mind.
In fact, even if you start out with a proper domain model, you might end up later with an anemic one. Or an over-complicated that creates other issues. Another reason is of course that you have a legacy application that is just reimplemented using pseudo OO (”I have get and set instead of public attributes, thus I did OO”)
So the fix. I have to admit that I forgot it. I started writing this post some months ago and abandoned it, then openend it up again as my mind changed, etc.
Read the rest of this entry »
Posted in
Architecture, Java |
1 Comment »
September 6th, 2006
I am reading Groovy in Action at the moment (via MEAP), today Chapter 4 and 5 arrived (So far a good read, but it offers not much more you’d expect from a good apidoc).
I flipped through chapter 4, as it is much know stuff, but this thing here was so strange that it caught my attention:
For the common case of having keys of type String, one can leave away the string markers (single or double quotes) in a map declaration.
assert [’a':1] == [a:1]
Nice, it comes comes as a side-effect from the pattern syntax, I guess. But it continues like this:
This notations can also get in the way when e.g. the content of a local variable is used as a key. Suppose, you have local variable x with content ‘a’. Since [x:1] is equal to [’x':1], how can we make it being equal to [’a':1]? The trick is that we can force Groovy to recognize a symbol as an expression by putting it inside parentheses.
def x = ‘a’
assert [’x':1] == [x:1]
assert [’a':1] == [(x):1]
Does this really simplify anything? Two things to consider
- Pattern work naturally(?) on strings, so it is nice that they don’t have to wrapped as in Java-regexp, in maps I rarely use strings as keys.
- The syntax of “()”: In patterns this is the group operator - here it is an eval. This I find confusing.
Posted in
Java |
1 Comment »
September 3rd, 2006
There are millions of programmers and trillons of lines of code out there that use Java, but as Java is an All-purpose language, most of the code produced is procedural redump of what people did when they used C or Fortran.
I came up with a short-list of sanity checks that I use to benchmark my designs.
- No public method shall return null, this applies also to protected methods of non-final classes
- Never pass this as an argument
- Getters and Setters are evil
- A public method shall be declared by an interface (sometimes an abstract class is sufficient and more convenient)
- No switch / if-else if on class invariants (this includes instanceof)
- A class shall be either (conceptually)final or abstract
- No method declares a foreign exception (I am OK with some checked exceptions from the java* packages)
- An object that can be passed back to the API shall be immutable or a Builder
- Prefer delegation over inheritance (this makes 6. reasonable)
- The class skeleton shall fit on a single page, as do all methods (including the private methods that are used by a single method only)
- The number of ctors shall be much smaller than the number of instance methods
- All statics are in enums
This is no style-guide (most of them are a waste of time with as little impact as knowledge is required to contribute), this is what I distilled out of code that pleases me and that really works and has been proven to be maintainable and easy to integrate.
To be continued / comments and suggestions are welcome.
Actually I know of style-guide that focussed on more than indentation and the placement of whitespace: JSF air vehicle C++ coding standards
Update: I started some explainatory notes on each topic (1-6,10,11 for the moment) under Design Rules
Posted in
Architecture, Java |
7 Comments »
May 20th, 2006

I started playing with Google Web Toolkit beta- actually I didn’t really start. Because I had to uninstall IE7 (which I don’t use at all), but hey I’d been curious.
The screenshot above is a ‘warning’ from the uninstall. I think they inserted it to deter people from stopping using it (interesting though how this compares to trailware).
But at the end the best one:

It is always more confusing to offer a negated phrase (”Are you not sure if you don’t want not all files lost on harddrive not being formatted [Y/N]”), instead of defaulting a reasonable choice.
The alert reader might have spotted that I use a french edition of XP (with the Vista L&F) - but everything comes in english?!
BTW: I think IE7 sucks. It is IE6 with tabbed-browsing, a terrible layout of controls and all known bugs. Worst of all: The anti-aliasing. Looks like s**t - if you happen to use Office 2003 you know this reading-layout - just like this, just a tad worse.
They should steal the anti-aliasing from Mustang, that works and looks really good.
PS: I now believe Microsoft invented the browser: It just took them longer than Netscape to come out with it:-) If the big battleship Microsoft is in hurry, some things might go over board
Posted in
Web, Java |
1 Comment »
April 9th, 2006
The C++ folks complain about a feature Java is lacking, the “constness”.
For the younger readers: The keyword const can be added to a method to make it promise not to modify the status of the object, as the same keyword for a variable means that you are only allowed to call const-methods on it.
Thus a const-type is a supertype of the type. Some types in Java are actually const: Number and String are immutable that is even stronger (they never change at all, while a const-object restricts only the reference holder to modify its state).
The Problem with Java is simple to explain: Imagine you had MutableString extends String. When implementing an interface do(String) just implementing do(MutableString) is not sufficient because there are MutableStrings that are not mutable - being plain Strings. When you design the interface of your class carefully, you can have constness: Create a const-interface and extend it by an interface defining all other methods. This is cumbersome and really hard to maintain. The implementation of a getter - see below - can call some non-const method; slicing the class creates problems down the road because of Java’s restriction to single inheritance.
My point here is that I argue that the concept of constness is of any good use in OOD at all.
Let aside the documentary benefit of a const method ( you should be concious about what a method does when you plan to use it), the const is used mainly for return-values of functions and one could view the need of const methods just a by-product of this modifier since otherwise the object at hand would be 100% useless (there are some subtleties with operator overloading, but this doesn’t apply to Java and the C++ syntax is questionable there anyway).
Read the rest of this entry »
Posted in
Architecture, Java |
No Comments »
March 27th, 2006
Just read over Kimchy’s Blog that pointed to an article by Martin Fowler which dates back to the end of 2003…
Oh my god this was definitely ahead of my time. As I started my current project I had been well aware of it (I am not sure anymore - I think I even read it shortly after it had been originally published). In fact we moved a system having an anemic domain model to a more object-oriented system (very sucessful by the way - perhaps the thing I am most proud of in my whole career).
Well I had been aware of it. Or I had been occupied by to many things at the “outer rim” to notice: Now we have “Assistants”, “BusinessProcesses” and “Calculator” that stripped out functionality from the business (or domain) objects. They now became more an more a bogus layer between the procedural code and the database*.
*Please note:
…which typically results in a whole layer of O/R mapping. This is worthwhile iff you use the powerful OO techniques to organize complex logic
“Iff” means “if and only if” - so you should employ OO-techniques to do the mapping and not only for the sake of having a mapping layer. In a non-trivial application you will have the need for it so plan for, do not take it too lightly
… the last sentence is perhaps the obligatory detail where I disagree with Martin:-)
Posted in
Architecture, Java |
No Comments »
February 18th, 2006
Once upon a time the was a search engine called Google. It had been a friendly search-machine and everyone liked it - not everyone of course , there was this nasty Giant of Redmond that was feared by everyone but also disliked by everyone.
End of the fairy-tale.
Google wants to make more money and “the next big thing” is localized services - if one believes the web to-point-”Ohh!” evangelist - formerly knows as the guys who didn’t get a word a Starbuck’s right and used them as brand names instead - who needs vowels, especially the ‘e’ is largely overrated (See G. Perec La disparition /A Void).
No google.de etc. are fully localized (to target you with more adspam). Also they provide more top-listed sites (It depends which google you talk about)… If I had the choice, they can do so, but what really bothers me is that it ignores whenI search with english or french terms: I still get only german pages… unless NO pages exists in german on the topic. Even if there is a single hit in german all other 200.000.000 hits are ignored…
Don’t say that I have to change my language preferences - they don’t have any effect on that: If you search you have to know now the language domain you want to investigate. My girl-friend is completly fucked: She mainly works translating french texts and when I say french I mean texts in french from France. Sadly Google now prefers Canada (Blame Canada!)…
Well perhaps they’ll improve on that, but actually it is a loss. All google sites looked the same because they were merely portals to the world’s information. The “global village” was too “.” O tied to Google to keep it connected. Now we go back to some regions (and some white(?) spots).
I have nothing against translations and reasonably ranked content, but I don’t like to revise all the weeks if I can still trust my dictionary. The rules must be transparent. The google-quirk can be circumvented (when using english) by querying google.com, but IBM and (guess who?) Microsoft made it worse: They use your IP-address to redirected you to localized content. This is very useful when you are in France and french is your third language (or 5th, 6th if computer languages count). At Microsoft it is just a bit annoying, but there is always the link to the translation (and the (english) original) on the same page and when you navigated a local site you won’t be dispatched without any notice while browsing it (I don’t except nobody to translate any bit of information immediately). IBM nows better: The transferred their mainframe-attitude to the 21st century. You can change your preferences, but you have to navigate away from the current page and you’ll never find the desired content…
Posted in
Web |
No Comments »
September 4th, 2005
A year ago I made a translation of a Wired article “Google vs. Evil”. This article is now four years old, but yesterday I read Jason Bell’s blog and found there a story that reminded me of the older article on Google.
I am not an idiot, I noticed the irony, so read on!
Point is why articles like this start to pop up since Google’s IPO. Before Google going public it had the charm of Linux. Nevertheless, the Wired article questions Google’s submissive attitude towards govermental pressure where nowdays we have to question Google’s pressure on goverments.
The latest Google project Google Print (perhaps not really the latest, but the one that made some waves) causes copyright-holders and libraries to raise concerns on the possible exploit of their property by Google that does not hold any right on them. Google offered copyright holders an opt-out to appease their concerns.
Well in fact if you opt-out this equals destroying your content - Google will not do it explicitly as annonced in the article, but your product will be virtually invisible as Google is the search-engine Superpower. This “either you’ll comply to our conditions or you’ll be eradicated” fits perfectly how the military Superpower acts nowdays.
Google is largely unaffected by govermental regulations unlike Microsoft that sells its products and thus has to comply with some laws. As Microsoft started/relaunched (in a desparate attempt to stop Google becoming the web’s hegemon) its search service everybody had the same concerns that now materialize in Google’s strategy.
I don’t want Microsoft to save me from that but I think something has to be done to limit the abuse of market share to prevent it becoming market power. Our culture that became so much richer by the web (and Google!) will quickly degenerate to MacInfomation when indexing of information will become indexing of products. Let’s face it: Google’s shareholders payed a ridiculous price and money can come only from selling things and as long Google does not sell anything directly the money has to come from content-providers.
In worst case you’ll have the top 1000 hits for “healthy nutrition” referencing the composition of a BigMac because McDo can outgun all other providers of “quality” content. A search Superpower, receptive to money and sufficiently “flexible” in its moral will give big companies a venue to extend their media control to the web.
Perhaps Google is not evil. I hope so. But their must be something like a true choice.
Posted in
Web |
No Comments »
|