Archive for May, 2005

Book Sharing P2P Network

I was browsing this list of books that Joel Spolsky recommends for any programmer.  Its a pretty extensive list, covering different areas of software development.  As I read the summary for the books I found myself wanting to go to amazon and buy them all, they sound really interesting and useful.  Now, buying a dozen books is going to cost quite a bit of money, which I’m not going to spend.  Its also difficult to find these books at the library, at least the times that I’ve looked, so I can’t go borrow them from my library.  But I bet if I were to post a title of the book on my blog, I could find many people who own that particular book.

I think it would be sweet if we could have some sort of P2P network for sharing books with each other.  Virtually any book that I would want to read is owned by some other blogger.  We could maintain lists of what books we own, and if someone wanted to borrow a book, they could just search for a blogger with it, request it from them, read it, and send it back.

There are a few hurdles that I see here:

  • Cost, sending these books isn’t free, so the person requesting the book would have to PayPal the person some shipping money.  This problem is amplified by the potential international shipping costs, if Geoff wants to borrow one of my books, its going to cost a pretty penny. :-)
  • Trust, you need to have a trustworthy network of people so that nobody gets screwed and doesn’t get their book back. To this end I think you could have a rating system like eBay has so that users are rewarded for positive transactions, and abusers are marked as such.
  • Reference, a lot of times you read a book, and then you keep it around for reference material later on. Obviously if we’re reading the books, and then sending them back, we can’t hold on to them for reference.
  • Time, there would need to be a set of guidelines for how long someone can have the book for, I wouldn’t want to lend my books out for a year at a time.
  • Laziness, when someone requests your book, you would have to package it up and go to the post office, or arrange for the book to be picked up, kind of a big favor for someone you potentially don’t know.

I think the only major obstacle is the first one, cost.  I think that if you start with a small group, say the codebetter.com bloggers, we wouldn’t have an issue with trust or time, as I don’t think there is a dishonest or disrespectful one among us.  If there was some way to streamline the shipping of the books, and make it reasonably priced, I think this would work out really well, especially for a site like ours where we encourage education and professional development (don’t we?).  This would be just another way to build relationships and a community.

Head First Design Pattern Question

Still working my way through “Head First Design Patterns”, slowly but surely :-) I have a question for others who have read the book.  In chapter 4, the factory pattern, they use a pizza shop as the example throughout the chapter to show how different pizza shops can have different pizza factories, i.e. Chicago style, New York style, etc.  They then go on to describe how you can use the factory pattern to model the pizzas themselves.

My question is whether or not they could have used the decorator pattern from chapter 3 to model the pizza objects instead of the factory pattern.  The example from the decorator pattern is the coffee shop, with mochas, lattes, blah, blah. It seems natural to use the decorator pattern to model each of the toppings, so you start with a plain cheese pizza, and then decorate it with pepperoni, sausage, peppers, etc.  I realize that they used the factory pattern in order to facilitate the book, but does anyone agree with me that the decorator pattern could have, and maybe should have, been used in a real world scenario?

Thoughts on custom development shops

I’ve been thinking about custom development shops and the difference between them and regular old software companies that make a specific product and then sell that product to the masses.  The custom development shops are living “paycheck to paycheck”, so to speak. When they finish the current project(s) they go out and try to find the next one, and depending on the situation, they need the next job in order to pay overhead, salaries, etc., whereas a company that makes a single product can sell the initial release of the product, and then if revenues from the sales are consistent, they have a variety of options.  They can put more work into the current product, add more features, fix bugs, etc., or they can come up with a new idea for an application, and begin work on that.  By having consistent sales from their initial release they can work at their own pace (to an extent).

Based on these assumptions, it seems that running a custom development shop would be much less desirable than a software company.  There are, however, downsides to the latter.  In order to have the time to develop that first application, you need some seed money, while the custom shop could crank out some web apps fairly quickly to begin sustaining themselves.  Another possible angle is that maybe people who work at custom shops like the fact that they are consistently working on new projects, rather than a small set of projects over a long period of time, but this is purely an individual opinion either way.

The situation seems analogous to some basic economic principles.  If you go to a financial planner, they will tell you to invest some money (obviously).  The inherent benefit to investing money is that the money can grow without any interaction from you, making the income “passive.”  By developing a single product to sell to many people, you can potentially have some of this “passive” income.  Sure, you need to do work after the release by releasing upgrades that fix bugs, but at some point you can add features and resell the product as an upgrade.  This is especially true if you charge your customers in a subscription style, so they have yearly fees to pay, rather than a large upfront fee, because now you have a recurring source of income that only grows as your customer base grows.

A relevant example I can think of is fellow codebetter.com member Eric Wise.  He is currently working on his own software product EasyAssets.Net.  Suppose when Eric releases EasyAssets it takes off like wildfire; if he wants, he can sit back and let the customers line up without much more work on his end.  He could choose to add features to his product or make something completely different; the key element is that because he has a revenue source, he has plenty of options.  Compare this to someone who makes custom web apps.  They do a project, get paid, then they look for the next job.  They do the next job, get paid, then they look for the next job.  If they’re good, they will find a way to reuse some of the work they have done previously to decrease the amount of time spent on each product, but they still need to find the next job.

I currently work at a place that does a lot of custom development work, but we are trying to get some actual products off the ground, I think my situation is what causing me to contemplate these things.  After proofreading this post, I realize that a lot of this is probably obvious, I just happened to be thinking about this quite a bit lately and wanted to put the thoughts into words, please comment where you feel I’m off base, or if you agree with a point I’ve made, thanks for reading.

Vertical scroll bars in Firefox

If you use Firefox, a difference that you might run across is that when
IE displays a page that does not need a vertical scroll bar, the bar
still appears, its simply disabled, whereas in Firefox the bar is just
gone.  This can mess up your site design if you have a fixed width
site because the pages without the scroll bar will shift to the right
slightly, which can be really annoying.  You can use the following
css style to force Firefox to show the scroll bar, however it won’t be
disabled like in IE, it just doesn’t scroll.

HTML {   overflow: -moz-scrollbars-vertical;}

Command prompt shortcut

Frequently while developing I need to use the command prompt.
Compiling, batch files, copying files, build scripts, etc. and its
always a pain to open the command prompt and then navigate to the
directory that you want to work in.  To make my life a little
easier, I tweaked the registry a little, and added a command prompt
item to the folder context menu, so when I select the “Command Prompt”
item, it opens cmd.exe and moves into the current folder.


DISCLAIMER: Be very careful when modifying your registry and always
make a backup before changing anything. I give no warranties :)

Here is what you add to the registry in order to get this:
1. Go to HKCR\Directory\shell
2. Right click on ’shell’ and select ‘New Key’
3. Change the name of the new key to “Command Prompt”
4. Right click on the new key and select ‘New Key’
5. Change the name of this new key to “command”.
6. Select this new key and right click on its default value:

7. Select “Modify” and in the input box enter this text: cmd.exe /k “cd %1%” (include the quotes)
8. Thats it! You should be able to right click on your folders and get a command prompt.

Dynamically calculate record count

When I was developing a custom datagrid control, I ran into the problem
of paging.  Frequently you need to show the results in sets of 25,
50, 100, etc. because there can be thousands of records making it
impossible to show them all at once.  So with our custom datagrid,
the user could supply a sql statement that would drive the datasource
of the grid.  In order to get the paging correct, I needed to know
the total number of records, so that I could calculate the number of
pages that were available, so at first we had the user calculate the
total themserlves, and supply that to the datagrid, which worked fine,
but I wanted it to be easier to use.  So I thought about it for a
little bit, and realized that with a little manipulation of the
supplied sql statement, you could get the total record count for any
query.  Heres a snippet of the code that I used to accomplish this:

string s = sql.ToLower();
int index = s.IndexOf(” from “);
string end = s.Substring(index);
string countSql = “select count(*) ” + end;

What this does is strip the “SELECT Column1, Column2, ….” from a sql
statement and replaces it with  “SELECT COUNT(*)”, leaving the
user’s WHERE clause intact, so that the resulting sql statement has the
same logic, its just selecting a count of records, instead of the
columns the user wanted.  Its worked pretty slick since then, I
can now give my datagrid a sql statement and the paging works
automatically, it makes our life a lot easier.

Firefox annoyance

Something that I dislike about firefox, is that each window does not
start its own process.  If you have 3 internet explorer windows
open, you can look in the task manager and see 3 “iexplore.exe”
processes running, but with firefox, there is only the 1 process
running.  This sucks when you hang your browser and you go to end
the process, you’d think that your other windows are safe, but once you
end that process, all your windows are gone.  Its just a little
annoying, especially coming from using internet explorer where that
situation would have worked out perfectly.