Wednesday, 29 August 2007

OutputCache! How did I miss it?

I've accidentally stumbled upon a thing called OutputCache. Weird little thing, I thought, how come I didn't hear about it? It seemed such a wonderful concept: just cache the output of ASP.Net pages and controls for a specific amount of time, specify for what parameters or controls or properties the cache is valid for and if it is shared between different users. Then just output the cached version and don't execute the entire thing all the time.

I tested it and it works. Most useful I find it for user controls. One can put a list of unchanging stuff like a list of cities or provinces or even customers in a user control, cache its output and forget about it.

How to use it:
A) declaratively. Put in the page or control something like this:
<%@ OutputCache Duration=100000 Shared="true" VaryByParam="none" %>
Just read the link above for the details.

B) programmatically. Put in the page or control code something like this:
CachePolicy.Cached = true;
CachePolicy.Duration = new TimeSpan(1, 0, 0, 0, 0);
CachePolicy.VaryByParams.IgnoreParams = true;

Update: it has come to my attention that this returns an error with the message "The CachePolicy cannot be used, since the control is not being cached." which is returned when the CachePolicy was not instantiated with a BasePartialCachingControl as a parameter. The solution, it seems, it is to also decorate the user control with the PartialCaching attribute.

ex: [PartialCaching(20)] - set the caching to 20 seconds.

C) One can even validate the cache programmatically after whatever of A or B methods were used like this:
Response.Cache.AddValidationCallback(new HttpCacheValidateHandler(MyCacheValidatorMethod),null );

That's it!

Debugging ASP.NET by Jonathan Goodyear, Brian Peek and Brad Fox

This book is written by a guy that made a small company dedicated to programming with free tools. Thus, it tries to show how to debug ASP.Net assuming that you come from an ASP background and that you don't have Visual Studio .Net. So I don't think I have to tell you how much useless information there is in there. It even covers programmatic code tracing.

That doesn't mean it is a bad book, just useless for me. If you expect some wonderful debugging frameworks or code structure that would allow you to easily debug your applications, then this book is not for you. Not to mention that at the time it was written, Visual Studio 2005 was not out yet.

Bottom line: just a hands on approach and some Google when you meet problems will solve any problems that are solved by this book.

The Abbey by Dan Dobos


Dan Dobos is a Romanian writer and so I find it difficult to bad mouth his work. He also had bad luck with this one, as I'd just found one of the better writers of sci-fi and read a few of his books before trying to (re)read The Abbey.

Bottom line, The Abbey tries to be a Romanian Dune, with some Christian theology thrown about, a planet controlling the resources of the entire human dominion, people with heightened intelligence, instincts, subtle two way dialogs and verbal manipulations, etc. It fails. The characters are inconsistent, obvious, their best attempts at charade are ludicrous, their motivations are inedible, the whole human galactic evolution completely unbelievable. The writing style is also very shallow, made only of dialogue and inner thoughts, with little detail of what is actually going on.

Although I admire the attempt, the basic ideas and the fact that he got published in a country where people rarely buy books and if they do they don't buy Romanian authors, this series is a failure. Better luck next time.

Fallen Dragon by Peter F. Hamilton


Enough said, I started reading anything this guy wrote. I've found Fallen Dragon, a single book this time, but filled with ideas that obviously grew into the Commonwealth Saga. With this earlier novel I did find Hamilton's Achilles heal, the one thing that bothered me in his books more than the slight over detailing of everything: the characters have no freedom.

Let me expand on that. When you write something, you have the characters in your head, fighting and shouting to let them free to do what they want. If you do that before they are fully matured, they break havoc with your writing, even considering you have the skill. However, when you force them to do your bidding like slaves, you also damage your story, because they lose credibility and consistency.

In this book more than others, the characters were forced to do something that they should never have done. A soldier looses his squad to a bunch of idealistic galactic eco terrorists, but eventually joins their ranks. That is just not possible. I was wriggling in bed, waiting for the moment the hero would remove his mask and kill that brain damaged bitch. He did no such thing, just letting his mates die for no reason. Thinking back, the same happened with Judas Unchained, when all characters willingly marched against an alien that was clearly lacking any resources and just trying to escape in a wild wild west kind of quest "let's all personally go and kill the bad guy".

Back to Fallen Dragon, it is an interesting story, with some moral teachings as well as a delicate temporal paradox, but it's not comparable with Hamilton's latest books.

The Dreaming Void by Peter F. Hamilton

After finishing the Commonwealth Saga, by the same author, I started reading the next series: The Void Trilogy. As in the aforementioned saga, the story does not end in any way at the end of the first book, you have to read all three books to reach the end, which effectively makes this another huge monolithic story, not a series or saga.

Set in an even more technological advanced future, but in the same Commonwealth universe, it depicts the interactions between a powerful pseudo-religious void worshipers, ANA (a quantum artificial intelligence where people download when the are tired of living and the next evolutionary phase of the SI) and its competing factions, the different alien races and the void, which is a dark impregnable sphere in the middle of the galaxy that only some psychic humans seem to penetrate.

The style is the same, the writing as almost flawless as before. I do think that P.F. Hamilton is one of the greatest sci-fi writers I've read, up there with Tolkien and Herbert.

Stupeur et tremblements by Amélie Nothomb


I have seen the movie on TV a while ago, but didn't catch the start, so I never knew what the name was. Finally, someone in a Romanian book club found the translated print here and reminded me of it and told me that it was based on a book. I've decided to read it in its native language, a bit scared that I would understand nothing of it, but the French is pretty easy to understand. Maybe because the author is Belgian :)

The story of Fear and Trembling is about a Belgian girl, born in Japan (just like the author), employed in a big Japanese corporation as a translator. Due to her inability to understand the local customs and the irrational feelings of her employers, she is demoted time after time until she ends up replacing toilet paper in the water closets.

The book itself is not meant as a comedy. The main character sees everything with a stoic detachment, analysing both her feelings and the feelings of others, trying to make sense of a world that she can't seem to fit in. It made me understand more than ever the illusory nature of reality. Both her and the Japanese were occupying the same space and time, were observing the same events, but their realities were completely different. That clash of incongruous realities is the core of this small novel.

A bit too French for my taste, not in the language, but in the endless repetitions of metaphoric interpretations of the same event, that overwording of inner thoughts that makes French writing sound pompous. However, I did enjoy the book, I recommend it to anyone wanting a light and distracting reading.

Fruit of the Mall

I wanted it to sound like Fruit of the Loom, for the connoisseurs in gaming :), but failed miserably. This blog post is about the exotic (and shamelessly expensive) fruits one can found in market stores.

The first one is the Lychee fruit. It is small, has a rough skin that has to be removed and a big seed inside. It leaves little else, but the flesh is very tasty, with a taste like that of a grape, but less sour and stingy. No wonder it is called the Chinese grape. I recommend it, at least try it once.

The Mangosteen. Now that's a fruit. Big as a small apple, it has a similar hard skin to remove and a similar taste as the Lychee, with the added advantage that it has more flesh. I would venture to say that this is the most tasty fruit I'd ever tried, even if a little too sweet. There is a funny story here, too. When I was a child I used to keep newspaper bits of the "did you know?" column (back in the days when newspapers has a science and information section). One of them said that the Mango is the king of the fruits, the very best in taste, but hard to transport because it rots easily. I was disappointed when I first tasted mango. It wasn't even tasty. But apparently, the author of the article made a confusion between the Mango and the Mangosteen. 20 years later, the article is vindicated ;)

The Carambola. A yellow star shaped fruit that can be bitten into, has the taste of a Quince fruit and a bit of its texture, but a bit finer. I would prefer it to quince, even if I don't particularly enjoy apple/pear tasting fruits.

The Kiwano, or horned melon. This is an odd fruit. It can be cut in quarters and eaten like a melon, has a greenish yellow color and taste like a combination of cucumber and banana. It is an interesting experience :)

I have tried another fruit, one that looks like a plum shaped (but smaller) orange. And it is :) It is like an orange pill. If it weren't for the price, I would use it to make arranciata. The name is kumquat and it can be hybridised with lime to fruit limequats. There are a lot of citrus fruits in the world, not only the orange, lemon and grapefruit!

For other exotic (for me) fruits, check out Part 2.