Sharing my thoughts on software development

Friday, March 5, 2010

You don't need a publisher

I was talking to my imaginative friend Joe the other day, trying to figure out why there still hasn't been a good website to read novels. We were talking about why book publishers should release books online in this era of Internet, and it struck me, why was publishers needed in the first place?

Back in the days, book publishing was a huge task and no small entities (a.k.a. authors) can do it for themselves, and in order to reach a wider audience without devoting their life to marketing which many may not be good at, book publishers were necessary.In fact things haven't changed much since! Book publishing is still a tremendous effort, you have to get editors to review the book, get advertisers to market the book, get designers to do book design, get printing companies to print the book, then go through a chain of distribution to get the books to readers.

And the result of that? Authors don't make that much. According to this post from a New York Times best selling author, she made a staggering $24,517.36 on a book that sold for 61,663 copies, about 40 cents for every book that's sold for $7.99 at retail. That's very little, but considering the amount of work the publisher has to do, it is only fair. Or is it?

In a business partnership, each partner has to contribute value to the business and take his/her share of profit based on the contribution, it is not always easily measurable, but mostly fair or the partnership won't work. Let's take a look what publisher brings to the table, that warrant a 95% cut [1].

Editor Review
Editors are quite helpful as they check for spelling, grammar and logical errors,they also give some good advices to improve the book or edit it directly.

Marketing
While authors can do a lot of the marketing themselves (and are increasingly required to), paid marketing campaign and advertisement still have their values. After all, who don't want to sell a few more books?

Printing and Distribution
These are normally done by separate companies. Printing and distribution is a lot of work, and book shelves are costly.

Publishers are indeed bringing a lot to the table in traditional publishing practice to warrant their share of profit. But things has changed! Advance in computer technology and the Internet has made a lot of things obsolete, including publishers, and here is why:

Editor Review
 Spell checkers will weed out most of the typos and simple errors. Some helpful readers or a fellow author could definitely be able to help to do the proofreading to find any logical errors. In fact the readers will feel delighted to have a sneak peek into your newest book, it's a privilege! And even if errors manage to loom into your book, you can always go back and fix it, a luxury you don't have with paper backs.

And what beats reader feedback on how to improve your book? After all, the definition of a good book is that people like it enough that they will buy it.

Marketing
 Authors already do a lot of marketing these days, and with the help of Internet, self-promotion has not been easier! If you really think you need some professional marketing, no one can stop you from hiring a marketing company, and you get to decide whether that's worth it.

Printing and Distribution
 Need to say no more, distributing books online cost a fraction of traditional printing and distribution model. And there is always print-on-demand option for readers who prefer paperback.

Notes:
[1] To publishers' defense, they do not take 95% of the sales, money goes to all parties involved in the process of publishing a book. But to an author, it doesn't make a difference where the money went.

Sunday, February 28, 2010

Google AI Challenge

I have recently competed in Google AI Challenge, it was a lot of fun and I have learned quite a few things. Here is a quick explanation of the strategy I employ.

First it checks to see if two bots are seperated.
If two bots are connected, it will use Minimax/Alpha Beta Pruning to determine the best move it should take. The evaluation functions is as follows:
  1, if I win: +1000; opponent wins: -1000
  2, if disconnected, and I have more open spots: +800; opponent has more open spots: -800; same: 0; Open spots is determined by flood fill.
  3, if still connected,
    find articulation points and divide map into zones
    find the largest zones
    use breadth first algorithm to divide the zones into spots I can reach first and spots enemy can reach first
    return final score as spots I can reach first - spots enemy can reach first
The whole Alpha Beta Pruning process is wrapped using a Iterative Deepening loop.

When two bots are seperated, simply use a breadth first algorithm to determine how many open spots are left after each move using flood fill. Then choose the move that leaves the most spots open, in case two moves are equally good, hug the wall.

It is written in C#, and can be found here: http://github.com/analyst74/Tron-Bot

Update:  here is a great write up about the challenge and many related links http://www.benzedrine.cx/tron/

Thursday, January 21, 2010

on Google vs China

Now the immediate heat of discussion on Google's new approach to China has settled a little (until new news come out from either party).

A lot of interesting analysis and speculations have emerged from the blogsphere and news medias, from bashing China's (if you don't know yet) human rights problem to questioning Google's real motives. You can find them all here (courtesy to Google!).

One thing everyone agrees, is that this is a significant event, but how significant? Will it change the world?

Fast forward forty years.

It's year 2050, we have just achieved 80% CO2 reduction goal set out forty years ago thanks to innovations in energy sector. On the news:

(Yahoo News) A syndicate of Internet companies lead by prominent companies like Google, Microsoft and eBay, have threatened to blacklist Australia if a new tax is implemented. The tax will be applied to companies who do not voluntarily comply with its censoring rules, and cover costs associated with censoring on the ISP level. Rumors say proponents of the tax are rapidly losing support from voters for fears that those threats become real.

(Apple Daily) In a bold move to tackle lumping economy and increasing domestic unrest, Japanese government has announced a plan to lift regulations related to the Internet, citing "The Internet has sovereignty of its own and cannot be governed in traditional means". The plan includes establishing a governing entity called UN (United Netizens) and handing over all regulatory duties to this entity. UN council body will consist representatives from prominent Internet companies and user groups. Japan urges other countries to follow the "great leap forward in net-neutrality". Economic analysts say such move could attracts over 5 trillion foreign investment to flow to Japan, especially from countries with complex or repressive Internet laws like US and China.

How does this future sound?

Maybe, just maybe, one day the Internet could be free.

Sunday, December 6, 2009

Two management styles

There are two brilliant managers called Jack and Gordon.

They both work for the same company -- it's one of the nation's biggest corporation and has huge influence in the market. Having a job in the company is considered a privilege, let alone a managerial position. One has to be cream of the most brilliant crop to get there.

Jack is a very smart man, and he has gained substantial experience in this field to make him a distinguished expert in the company. This is not to say he lacks social skills though. In fact people admit that he posses both technical expertise and some political talent. He is a star leading a team of experts solving some of the company's most difficult problems. His talent is both widely appreciated by the senior management and admired by fellow employees, even those who are not in his team.

Gordon is also a very smart man, although not quite as sharp as Jack is. He is considered by most people to be a people's manager as compared to Jack, who is both a remarkable manager AND technical leader. Gordon's team is also one of the most successful teams in the company, the product they created has received outstanding reception and is bringing the company a steady stream of income measured in the millions. The success of Gordon, as people say, is widely contributed to the great idea (which did not come up by himself) and a superb team he got stuck with. His team is indeed superb, many of them have proved themselves to be A players and there is one young guy who is considered to be a wizard even among his team of A players, a star employee he is. Anyone who is lucky enough to stuck with a good idea and a superb team like Gordon's would have succeeded, probably more wildly than Gordon have.

Fast forward fifteen years.

Jack has gotten old and has stepped away from the company's core team since he lost his sharpness a while ago. The company still treats him well though, and he is enjoying his life with a much less stressful job. He misses the glory days, but nobody can fight time, his time has passed.

Gordon has lost the best members of his original team, three of them including the star employee were promoted "past" him, others eventually left and got promotion in other companies. But the team somehow managed to survive, he always seem to be lucky to recruit a few remarkable employees who kept the team and Gordon himself afloat, until about five years ago when he was promoted to senior management. "It is all due to his political talent", some people say.

But the company's chief architect disagrees:"He (Gordon) is the best manager I've ever met and the time working for him was the best of my career. He did not only understand both the business and technical sides, shielded us from senior management pressure, but also cared for us personally. He fought tooth and nails with HR to give us bigger raises and single handedly convinced senior management to promote me to the architect team. Without him, I wouldn't have been where I am now. I am so glad that I am reporting to him again."

The chief architect was not the only one Gordon promoted -- almost a dozen of the company's current managers used to work in Gordon's team and have since been recognized and promoted. They were equally thankful for the chance to work for Gordon. On the other hand, nobody seems to remember Jack except a few old timers, and Jack has never been "lucky" enough to recruit such talented people like Gordon has. Those "B players" who worked for him have either stayed where they were or have since left the company.

"Luck" is really important, as people say.

Monday, November 9, 2009

Does Inheritance breaks Encapsulation?

Because inheritance exposes a subclass to details of its parent's implementation, it's often said that 'inheritance breaks encapsulation' (Gang of Four 1995:19)
No I did not read the GoF book, I'm quoting them because I believe quoting important people makes my point more correct.

So we know that inheritance breaks encapsulation because it exposes a subclass to details of its parent's implementation. But what is the harm of exposing parent's implementation to subclasses? Why does it matter?

Imagine this situation: you are coding a very core class for a system, and decided to make a field protected so it's convenient for subclasses to access it. After all, it is a core member field that all subclasses need to use and declaring it as protected seemed like reasonable thing to do. Everything worked fine and smoothly in the beginning. Then 5 years passed, assuming the system is actually making money for your company, it has grown substantially through a steady stream of feature requests. And many subclasses were created inheriting the core class you wrote. Now imagine you have to change that protected field, and *bam*, you're stuck! Because there are many subclasses sprang across many assemblies, and nobody has a headcount of them all! So you either end up not changing it, or do the change and fix as many subclasses as possible, then prey you don't miss any.

Does this sound familiar? Yes, this is the exact scenario when someone accidentally declared a field public for convenience when it should have been properly encapsulated, I hope it's not you, oops! (I'll be honest, I did this before!)

I believe this is the context when those influential people declared that inheritance breaks encapsulation. But a class does not have to expose its implementation to subclasses, take Hashtable for example: it is carefully designed to hide all implementation details from not just the rest of the world, but also its subclasses. So if there is a change to the default hashing method, how data is stored internally or any of the implementation details, all the subclasses created by developers across the world will not be broken! I believe a more proper statement would be:
Overusing protected members breaks encapsulation.
And the remedy to that? Don't overuse the protected keyword. :)