and has 0 comments
The name says it all: "The Everything Creative Writing Book: All you need to know to write novels, plays, short stories, screenplays, poems, articles, or blogs", maybe too much. In this book, Wendy Burt-Thomas takes a holistic approach to writing, discussing everything from how to write poetry and children's books, blogs and technical specs to how to find an agent, self publish and so on. It covers writing techniques and editing advice, writer block solutions and how to deal with rejection (or success for that matter) and many more. In that regard, the book is awesome, it shows everything you might want to know a little about in order to decide what you actually choose to do, but like that Nicholas Butler quote An expert is one who knows more and more about less and less until he knows absolutely everything about nothing, the book is probably not very useful to someone who has already started working on things.

That said, the book is compact, to the point and can help a lot at the very beginning of the writer's journey. It can be used as a reference, so that whenever a particular subject or concern appears, you just flip to that chapter and see what Wendy recommends. Is it good advice? I have no idea. I've certainly read books that go more in depth about topics that interested me more, like how to write a novel or how to set up a scene, but a panoramic view of the business is not bad either. The material also felt a little dated for something released in 2010, especially in the technical sections.

You choose if you find it useful or not.

Intro


An adapter is a software pattern that exposes functionality through an interface different from the original one. Let's say you have an oven, with the function Bake(int temperature, TimeSpan time) and you expose a MakePizza() interface. It still bakes at a specific temperature for an amount of time, but you use it differently. Sometimes we have similar libraries with a common goal, but different scope, that one is tempted to hide under a common adapter. You might want to just cook things, not bake or fry.

So here is a post about good practices of designing a library project (complete with the use of software patterns, ugh!).



Examples


An example in .NET would be the WebRequest.Create method. It receives an URI as a parameter and, based on its type, returns a different implementation that will handle the resource in the way declared by the WebRequest. For HTTP, it will used an HttpWebRequest, for FTP an FtpWebRequest, for file access a FileWebRequest and so on. They are all implementations of the abstract class WebRequest which would be our adapter. The Create method itself is an example of the factory method pattern.

But there are issues with this. Let's assume that we have different libraries/projects that handle a specific resource scope. They may be so different as to be managed by different organizations. A team works on files, another on HTTP and the FTP one is an open source third party library. Your team works on the WebRequest class and has to consider the implications of having a Create factory method. Is there a switch there? "if URI starts with http or https, return new HttpWebRequest"? In that case, your WebRequest library will need to depend on the library that contains HttpWebRequest! And it's just not possible, since it would be a circular reference. Had your project control over all implementations, it would still be a bad idea to let a base class know about a derived class. If you move the factory into a factory class it still means your adapter library has to depend on every implementation of the common interface. As Joe Armstrong would say You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.

So how did Microsoft solve it? Well, they did move the implementation of the factory in another creator class that would implement IWebRequestCreate. Then they used configuration to associate a prefix with an implementation of WebRequest. Guess you didn't know that, did you? You can register your own implementations via code or configuration! It's such an obscure feature that if you Google WebRequestModulesSection you mostly get links to source code.

Another very successful example of an adapter library is jQuery. Yes, the one they now say you don't need anymore, it took industry only 12 years to catch up after all. Anyway, at the time there were very different implementations of what people thought a web browser should be. The way the DOM was represented, the Javascript objects and methods, the way they actually worked compared to the way they should have worked, everything was different. So developers were often either favoring a browser over others or were forced to write code for each possible version. Something like "if Internet Explorer, do A, if Netscape, do B". The problem with this is that if you tried to use a browser that was neither Internet Explorer or Netscape, it would either break or show you one of those annoying "browser not supported" messages.

Enter jQuery, which abstracted access over all these different interfaces with a common (and very nicely designed) one. Not only did it have a fluent interface that allowed you to do multiple things with a single target (stuff like $('#myElement').show().css({opacity:0.7}).text('My text');), but it was extensible, allowing third parties to add modules that would allow even more functionality ($('#myElement').doSomethingCool();). Sound familiar? Extensibility seems to be an important common feature of well designed adapters.

Speaking of jQuery, one very used feature was jQuery.browser, which told you what browser you were using. It had a very sophisticated and complex code to get around the quirks of every browser out there. Now you had the ability to do something like if ($.browser.msie) say('OMG! You like Microsoft, you must suck!'); Guess what, the browser extension was deprecated in jQuery 1.9 and not because it was not inclusive. Well, that's the actual reason, but from a technical point of view, not political correctness. You see, now you have all this brand new interface that works great on all browsers and yet still your browser can't access a page correctly. It's either an untested version of a particular browser, or a different type of browser, or the conditions for letting the user in were too restrictive.

The solution was to rely on feature detection, not product versions. For example you use another Javascript library called Modernizr and write code like if (Modernizr.localstorage) { /* supported */ } else { /* not-supported */ }. There are so many possible features to detect that Modernizr lets you pick and choose the ones you need and then constructs the library that handles each instead of bundling it all in one huge package. They are themselves extensible. You might ask what all this has to do with libraries in .NET. I am getting there.

The last example: Entity Framework. This is a hugely popular framework for database access from Microsoft. It would abstract the type of the database behind a very nice (also fluent) interface in .NET code. But how does it do that? I mean, what if I need SQL Server? What if I want MongoDB or PostgreSQL?

The way is having different "providers" to translate .NET code Expressions into whatever the storage needs. The individual providers are added as dependencies to your project, without the need for Entity Framework to know about them. Then they are configured for use in code, because they implement some common interfaces, and they are ready for use.

Principles for adapters


So now we have some idea about what is good in an adapter:
  • Ease of use
  • Common interface
  • Extensibility
  • No direct dependency between the interface and what is adapted
  • An interface per feature

Now that I wrote it down, it sounds kind of weird: the interface should not depend on what it adapts. It is correct, though. In the case of Entity Framework, for example, the provider for MySql is an adapter between the use interface of MySql and the .NET interfaces declared by Entity Framework; interfaces are just declarations of what something should do, not implementation.

Picture time!


The factory and the common interface are one library that will use that library in your project. Each individual adapter depends on it, as well, but your project doesn't need to know about it until needed.

Now, it's your choice if you register the adapters dynamically (so, let's say you load the .dll and extract the objects that implement a specific interface and they know themselves to what they apply, like FtpWebRequest for ftp: strings) or you add dependencies to individual adapters to your project and then manually register them yourself and strong typed. The important thing is that you don't reference the factory library and automatically be forced to get all the possible implementations added to your project.

It seems I've covered all points except the last one. That is pretty important, so read on!

Imagine that the things you want to adapt are not really that similar. You want to force them into a common shape, but there will be bits that are specific to one domain only and you might want them. Now here is an example of how NOT to do things:
var target = new TargetFactory().Get(connectionString);
if
(target is SomeSpecificTarget specificTarget) {
specificTarget.Authenticate(username, password);
}
target.DoTargetStuff();
In this case I use the adapter for Target, but then bring in the knowledge of a specific target called SomeSpecificTarget and use a method that I just know is there. This is bad for several reasons:
  1. For someone to understand this code they must know what SomeSpecificTarget does, invalidating the concept of an adapter
  2. I need to know that for that specific connection string a certain type will always be returned, which might not be the case if the factory changes
  3. I need to know how SomeSpecificTarget works internally, which might also change in the future
  4. I must add a dependency to SomeSpecificTarget to my project, which is at least inconsistent as I didn't add dependencies to all possible Target implementations
  5. If different types of Target will be available, I will have to write code for all possibilities
  6. If new types of Target become available, I will have to change the code for each new addition to what is essentially third party code

And now I will show you two different versions that I think are good. The first is simple enough:
var target = new TargetFactory().Get(connectionString);
if
(target is IAuthenticationTarget authTarget) {
authTarget.Authenticate(username, password);
}
target.DoTargetStuff();
No major change other than I am checking if the target implements IAuthenticationTarget (which would best be an interface in the common interface project). Now every target that requires (or will ever require) authentication will receive the credentials without the need to change your code.

The other solution is more complex, but it allows for greater flexibility:
var serviceProvider = new TargetFactory()
.GetServiceProvider(connectionString);
var target = serviceProvider.Get<ITargetProvider>()
.Get();
serviceProvider.Get<ICredentialsManager>()
?.AddCredentials(target, new Credentials(username, password));
target.DoTargetStuff();
So here I am not getting a target, but a service provider (which is another software pattern, BTW), based on the same connection string. This provider will give me implementations of a target provider and a credentials manager. Now I don't even need to have a credentials manager available: if it doesn't exist, this will do nothing. If I do have one, it will decide by itself what it needs to do with the credentials with a target. Does it need to authenticate now or later? You don't care. You just add the credentials and let the provider decide what needs to be done.

This last approach is related to the concept of inversion of control. Your code declares intent while the framework decides what to do. I don't need to know of the existence of specific implementations of Target or indeed of how credentials are being used.

Here is the final version, using extension methods in a method chaining fashion, similar to jQuery and Entity Framework, in order to reinforce that Ease of use principle:
// your code
var target = new TargetFactory()
.Get(connectionString)
.WithCredentials(username,password);
 
 
// in a static extensions class
 
public static Target WithCredentials(this Target target, string username, string password)
{
target.Get<ICredentialsProvider>()
?.AddCredentials(target, new Credentials(username, password));
return target;
}
 
public static T Get<T>(this Target target)
{
return target.GetServiceProvider()
.Get<T>();
}
This assumes that a Target has a method called GetServiceProvider which will return the provider for any interface required so that the whole code is centered on the Target type, not IServiceProvider, but that's just one possible solution.

Conclusion


As long as the principles above are respected, your library should be easy to use and easy to extend without the need to change existing code or consider individual implementations. The projects using it will only use the minimum amount of code required to do the job and themselves be dependent only on interface declarations. As well as those are respected, the code will work without change. It's really meta: if you respect the interface described in this blog then all interfaces will be respected in the code all the way down! Only some developer locked in a cellar somewhere will need to know how things are actually getting done.

and has 0 comments
I started reading The Things They Carried as a recommendation for writing style and it is, indeed, a very deep personal work. Tim O'Brien writes about the Vietnam war in most if not all of his work, but this novella is a collection of short stories all brought together under the mantle of a sort of a confession. It's a mosaic, each piece beautiful, but together creating the artistic vision of the true war.

I liked the subtlety, most of all. The characters are not overly complex, but they are portrayed in a very personal manner, with details that are important for the overall meaning of the book. I loved how O'Brien described soldiers going to war (instead of running away to Canada, as he almost did) because they were too embarrassed not to. Died in the war because they were afraid to die of shame. Too cowardly to run.

At just 150 pages, the book shows not how the training went, or how the shooting was, it presents everything from the viewpoint of the people there. How it takes over every feeling you have, how it changes you into this creature that is completely different from the man (or woman) who left. It's not about maneuvers or tactical prowess or strategies of survival. They are all meaningless. The important part is to keep a semblance of sanity.

The titled refers to the trinkets people carry to remind them of who they are. And they carry much more: hopes, wounds, fears, diseases, the ever growing arsenal of pointless weapons and ammunition and so on. A bit depressing, but a damn good read.

and has 0 comments
The Martian was a total surprise as it took the world by storm and became beloved by all science, tech and fast talking pun lovers in the world. Artemis, on the other hand, will not be. Andy Weir writes another book about a supersmart tech savvy character with a great sense of humor, this time solving technical problems on the Moon. Is it as good as The Martian? I don't know, because now I have a template and knew what to expect. Without the element of surprise, it's difficult to compare the two books. Yet I finished reading the novel in a day. That's gotta count for something.

Stylistically it is first person, filled with dialogue and action. It's incredibly easy to read. This time, the main character is a young woman and the location is a city on the Moon. Andy Weir is nothing if not optimistic, so in his book we do get there. I thought the action was following the pattern of danger-action-solution too closely, so much in fact that at one time I saw the entire story as a big adventure game. I will bet you lots of slugs that Weir loved Sierra games as much as the next geek (that being me).

Bottom line is that I liked the book, I gobbled it up and enjoyed it to the end. I didn't like Jazz Bashara as much as Mark Watney and, while the technological descriptions kept me interested, I still think that space mechanics and Martian farming trump EVA shenanigans and vacuum welding any time. It was still damn entertaining, though.

and has 0 comments
All in all I liked Oryx and Crake. Margaret Atwood is writing in a very technical manner, at least it felt like that to me, with scenes and characters constructed in a certain way. That is both instructional and a bit off putting, because once you become aware of it, it distracts from the plot. The plot itself is simple enough: the world has ended and there is this half crazed old man who is reminiscing over what happened. At first it is all unnervingly vague, with things being kept from the reader as the feelings and mental issues of the main (and single) character of the book are being declared. Then, when vagueness cannot be sustained anymore, it is all told as a linear story of what happened, with clear explanations of everything. No mystery left.

To me, it felt like Atwood wanted to warn about the way we treat our world and she just exaggerated some things while letting others be whatever she wanted them to be. From a scientific and sociological standpoint some of the things described are spot on, others are complete bogus. I would go into details, but I don't want to spoil the story. One example is the marketing brands that she cooked up and that are all (and I mean all) phonetically spelled descriptions or sometimes puns. All companies, all product names, all new animal names are like that and it gets really tiresome after a while. Also people are able to do wonderful (or horrible) new things in some areas and not advance at all in others. The timeline is a little screwed up, too.

My favorite quote, the one that made me think the most, was: "All it takes," said Crake, "is the elimination of one generation. One generation of anything. Beetles, trees, microbes, scientists, speakers of French, whatever. Break the link in time between one generation and the next, and it's game over forever" . He is referring to technology after a post apocalyptic event. There are few people that understand any instructions left by makers of advanced technology and the ones that can are ill equipped for survival.

The book does feel like it was written as standalone, with the possibility of being continued, which is a good thing: no ending cliffhangers and too much setting up the next books. The title is weirdly misleading, though, as both Oryx and Crake appear very little in the memories of the main character. Why was the book named so? It makes little sense. I am not sure if I will be reading the next books in the MaddAddam trilogy.

Bottom line: good, although a tad bland writing. A single character reminiscing is all that happens in the book. Grand ideas that most of the time make sense, but sometimes fall flat. Scientifically things don't go as she described.

and has 0 comments
This guy can write! I mean, Peter Brannen is writing about paleontology and climate change and the words just sing to you, make you see worlds that we actually know very little about and feel for ammonoids like there would be the cutest kittens, looking at you with big eyes and begging not to get extinct. As someone who wants to write himself someday, I really hate this guy. He is that good.

That being said, The Ends of the World is a book about the major extinctions in Earth's history, their causes and how they relate to our present lives. It's a captivating read, evoking lost worlds and very carefully analyzing how they disappeared and why. There is humor, drama, interesting interviews with fascinating people. Dinosaurs? Puh-lease. This takes you back to the good old days of the Ediacaran and slowly brings you around our time and even speculates on what could come after us, the hubris filled species that, geologically speaking, was barely born yesterday - or a few seconds ago, depending on how you measure it - and has the chance to outshine all the other species that came, ruled and went.

There is no way I can do it justice other than to say that I loved the book. In itself it's a summary of life on Earth so summarizing it myself would be pointless. I highly recommend it.

Here is the author, presenting his book at Google Talks:

and has 1 comment
What's Expected of Us and Others is a collection of stories by Ted Chiang including
  • Exhalation
  • Dacey's Patent Automatic Nanny
  • The Truth of Fact, the Truth of Feeling
  • The Lifecycle of Software Objects
  • What's Expected of Us
  • The Merchant and the Alchemist's Gate
  • The Great Silence

All the stories are speculative fiction, their subjects related to the meaning of life and evolution in relation to technology. His writing style is direct, unsophisticated, often based on first person perspective and dialogue. It's the ideas that he is exploring where he spends most of his efforts. All in all a nice collection of sci-fi, but not something extraordinary in nature.

and has 0 comments
As far as I can see, Ted Chiang's Tower of Babylon is the first thing he published. It's a short story (that you can find online for free) about two workers climbing the tower of Babylon to dig through the Vault of Heaven.

In this story the tower is not struck down and the people have been working on the tower for centuries. It's a fun read, although not particularly funny or captivating. It does show Chiang's penchant for speculative fiction, though. I liked it, but not enough for four stars and three seems too little. Read it. It's short and I don't want to write more about it than it is itself in length :)

and has 0 comments
A Conjuring of Light ends the Shades of Magic trilogy, although apparently a new trilogy set in the same universe is on its way. All the major threads are closed, although some of them felt a little forced and some of the drama was clearly artificial. But at least it all ends, which is one of the major reasons I read this book, only to see how Victoria Schwab's characters will end up.

I felt that this was the more ambitious volume of the three in the series, with all three Antari having to interact, with foreign dignitaries stuck in the royal palace while it was under siege from a demented magical creature who believed itself a god, with ties with families and past revealed, with new places and new magic. However, the book was quite inconsistent. For example, there is a plan to use a spell to seal the god in a body. When it is inside one, they forget about it and fight him with knives and fire and what not. There is a spell that could restore Kell's memory. He wonders if he should use it, then we forget about it. As for Grey London (ours) and Black London (the one where the creature originated), they are completely ignored.

The personalities of the characters also change a lot, with everyone acting brave and selfless (sometimes to stupidity) as if forgetting we are talking about a ruthless street thief, a killer turned sociopath by years of torture and so on. To me it seemed as if the author wanted a tough story, but she couldn't help turning it into a classic hero quest with a happy ending.

Bottom line: I had fun reading the series, but I won't continue with the next trilogy. It's not bad, but it's not above average either.

There is this channel I am subscribed to, with various people discussing or demonstrating software development concepts, with various degrees of success. I want to tell you about this series called CSS3 in 30 Days which is very well organized and presented by a clearly talking and articulate developer, Brad Hussey. He's nice, he's Canadian.

And before you go all "I am a software programmer, not a web designer", try watching it for a bit. Personally I am sure I would have solved a lot of what he demos using Javascript. Changing your perspective is a good thing. Note it is about CSS3, which had quite a few improvements over the classical CSS you may know already.

Here is the first "day" of the tutorial:

Paranoia Agent (or Delusion Agent, maybe) is an anime by famous anime director Satoshi Kon, unfortunately killed by cancer in 2010. His work is always more than it seems, focusing on the inner worlds of people and how they all perceive things differently.

The anime is only 13 episodes and starts with a simple case of violent assault on the street and then becomes stranger and stranger until it is not clear which is real and which is in someone's head. It critiques the repressive Japanese society and human nature in general, it goes from police procedural to slapstick comedy, from horror to psychological drama. The ending is, as they say, a mystery that doesn't stay solved for long. I quite liked the anime and I recommend it highly. It is rarer and rarer to find Japanese anime which is not derivative or simply idiotic.

and has 0 comments

It involves Russia! The story of how Boris Pasternak's Doctor Zhivago got popularized and received the Nobel prize for literature is fascinating and one of the reasons why my wife and I decided to read it as part of our own private book club. She loved the book, although she admitted she didn't understand a lot. I couldn't finish it because I didn't understand it at all!

Let me get this straight, this is not a bad book, the fault lies solely with me. That being said, I've read half of it before I decided to watch the TV adaptation from 2002 and realized I had no idea who anyone was. I had read half of a book, enjoying the way Pasternak describes individual lives, but I didn't remember one character or scene. And the explanation is simple: this is like Crash, on steroids, had sex with Gone With The Wind and had this bastard child around the first World War in Russia. People have three different names, plus nicknames, that the author just splays around without explanation. Events are described through short chapters that sometimes connect via a character seeing the same things from a different perspective or saying something about a character, using a different name than the one we read about it previously. And all these people keep bumping into each other again and again. Sometimes there is no rhythm in how things are written, sometimes it sounds like poetry. There is huge attention to some details and complete ignoring of others. And so on. It is not an easy book; it requires your full attention.

It is obvious that Pasternak loved people and he described their experiences and toils during times of great upheaval, but for him those paled compared with the love stories and the feelings of the characters involved. I can understand how he was confused on why people thought his book was against the Soviet system, where it was clearly about people. I am sure this book is great, it is just not for me. If you want to try it, I suggest you read the summary in Wikipedia so you understand what is going on and you do not read it in bits of 15 minutes in the subway.

and has 0 comments
I started watching Killing Eve, the BBC TV series starring Sandra Oh and Jodie Comer, and I quite liked it. So I've decided to read the books it is based on, Codename Villanelle being the first one. The result is a mixed bag. I clearly prefer the TV show, but the book is not bad either. They are, I have to say, quite different.

While both focus on a police woman trying to find a highly skilled female professional sociopath assassin, the show adds a little dark humor, which is both nice and off putting, while the book is going for the full "secret world of spies and weapon technobabble" route, which is also half and half. I think Luke Jennings wanted to write a simple spy story, inspired by the likes of John le Carré, while the show screenwriters have more ambitious goals. Most of the little episodes there are based on stuff in the book, but wholly reinterpreted, the characters changed or added, their fates changed.

But enough about TV. The book is easy to read, but a bit one sided: kill after kill and the chase of the department that has to uncover not only the identity of the killer, but also who are the high placed people who help hide her tracks, without most of the emotional exposition that makes a character relatable. Funny enough, there is more emotional content related to the killer than the cop. Makes you wonder which one of them is the psycho sometimes.

In conclusion, I will not read the rest of the books, but I will continue to watch the TV show. I feel like reading the first book opened my eyes on what the characters were supposed to be and thus Codename Villanelle acted like a nice companion book for an interesting series that I enjoy watching.

and has 0 comments
I liked Binti, even it is a short story. It is my first contact with the Nigerian-American author Nnedi Okorafor and I loved how African ideas blended with science fiction concepts in Binti. I will probably read the others in the trilogy, sooner or later.

The story is about a girl that leaves her tribe and planet to go to a university she was just admitted to. Just when getting there, an alien race of Medusae kills everybody except her. You will have to read why that happens and how she becomes the ambassador of the aliens, because the story is short enough to get spoiled by a detailed review. The writing is not without flaws and the character is dangerously close to the one in Who Fears Death, but I felt that it made a lot more sense in the context of an interstellar Federation as in Binti.

Read it. It was fun.

and has 0 comments
Who Fears Death is an interesting book mainly because of the Nigerian background of Nnedi Okorafor, the author, and the subject vaguely inspired by the atrocities in Sudan. The fantasy plot revolves around a girl resulted from intertribal rape who has to deal with the injustices of her world using her magical powers. Imagine a Harry Potter book in a German extermination camp scenario where he is a Jewish girl and you get close. In fact, this and other books on the subject of tribal hatred in Africa should make any white supremacist feel good about themselves, because there is no worse racism than between violent religious uneducated tribes that pretty much look the same.

Yet the book's interesting factor kind of stops there. The African culture references throughout the story keeps it entertaining, but the plot is a classic hero arc with pretty much all of the flaws inherent to the genre. Hero is young and powerless, discovers powers, is guided by mentors that keep from her just about everything there is to know and use up until she needs it, evil villain to whom she has a direct connection and opposition, friends that are there just to support the hero, things that happen for no other reason than they needed to further the story in a particular direction, she has amazing powers but uses them sparingly and often is stopped from using them for moral reasons by her friends and so on. In fact, it gets a lot worse, considering the hero is an African girl who could get killed at any moment by an angry mob just for the color of her skin, moving around in a society where even her boyfriend thinks it's OK to keep things for himself or treat her patronizingly just because of her gender, not to mention the old male mentors.

So while the book is interesting and well written, it does have a major flaw in the way it was structured as a story. Perhaps the docile Black woman who occasionally gets upset and then regrets it resonates better with African audiences, but for a Westerner it might get a little frustrating. It is a book worth reading, mainly because of the culture shock one experiences while reading it, but it could have been better.