Books

God is not Great debate

Reverend Al Sharpton, former presidential candidate (among many other things) and Christopher Hitchens, author of “God is not Great” had a very interesting discussion a couple of nights ago. A partial (though fairly accurate) transcript is available here, with the full audio recording available here. Its 1.5 hours long, and with such an interesting topic, it is really hard to concentrate on other tasks at hand.

Regardless of which side of the debate you stand on, there is something to think about.

Books
Thought

Comments (0)

Permalink

Books!

Books to the ceiling,/ Books to the sky,/ My pile of books is a mile high./ How I love them! How I need them!/ I’ll have a long beard by the time I read them.
- Arnold Lobel

Sunday was my 30th birthday. So, I went out and got me some birthday presents:

I picked up Domain-Driven Design: Tackling Complexity in the Heart of Software
by Eric Evans. Blaine had lent me his copy, and has been telling me for the longest time that I needed to pick this one up. So I did. I got about 25% of the way thru the first time before giving it back to Blaine, so I am looking forward to finishing it.

I also picked up Refactoring to Patterns (The Addison-Wesley Signature Series) by Joshua Kerievsky. This one has been on my wishlist for a long time. I have skimmed the first few chapters and it looks great.

The non-tech book I am currently reading is The Way of Zen by Alan Watts. I have had this book for quite some time now. Before this time, every time I tried to read it I would get bogged down in the sometime terse language. This time I got through that and now am throuroughly enjoying it, although it still can be difficult at times with the Chinese and Indian names for things.

Books
Design
General
Software Development
Thought

Comments (3)

Permalink

Changing Mindset: From Procedural to Object Oriented

Yesterday I had the chance to write some code to determine if I needed to schedule an action for later processing, or do the action immediately. I am working on a system that has a fairly well laid out component architecture, with a fairly good Business model. However, it is almost all “Controllers and Data Structures” at this point. Given my previous experiences with how people would write this type of code, it would invariably end up like this:

  1. public void someComponentMethod(Long rootModelID) {
  2.   RootModelObject root = DAOFactory.getRootModelDAO().getRootModel(rootModelID);
  3.  
  4.   // many lines of code later …
  5.  
  6.   if ( root.getExtraData() != null &&
  7.         root.getExtraData().getSchedule() != null ) {
  8.         Schedule s = root.getExtraData().getSchedule();
  9.         if ( s.getScheduleDate().after(new Date()) ||
  10.              s.getCronExpression() != null ) {
  11.                 root.setStatus(SCHEDULED);
  12.                 DAOFactory.getRootModelDAO().save(root);
  13.                // schedule for later code
  14.         }
  15.   } else {
  16.         // deliver immediately code
  17.   }
  18.   // many lines of code later …
  19. }

There are a number of issues in the above code:

  1. The interface to this method is abhorrent. I will discuss this in another post.
  2. The component knows WAY too much about the specifics for processing.
  3. Hand in hand with the above, it knows way too much about the Business Model.

This is a classic case of “Asking, not Telling”, the antithesis to the awesome article Tell, Don’t Ask, by Dave Thomas and Andy Hunt. GO NOW and read it if you haven’t.

Here is the code I ‘ve written so far:

  1. public void someComponentMethod(RootModelObject root) {
  2.         // small amount of other code
  3.  
  4.         if ( root.shouldBeScheduled() ) {
  5.                 root.setStatus(SCHEDULED);
  6.                 DAOFactory.getRootModelDAO().save(root);
  7.                 scheduleComponent.schedule(root);
  8.         }
  9.         else {
  10.                 root.setStatus(PROCESSING);
  11.                 DAOFactory.getRootModelDAO().save(root);
  12.                 nextComponent.process(root);
  13.         }
  14. }

There are few things here that are better: First, I pass in the object I want to work on… this is SO much better than having to go get the Object from some back-end store by ID. I will definitely be talking about this more in the near future. Second, I broke out the beautiful comments from the code above into separate methods, on the components that they represent. This can only make things easier in that code, which most assuredly would have otherwise been in the if block as the comments suggest. And finally the piece that got me started on this post, I moved all of the logic revolving around the Schedule behind the walls of the RootModelObject. But, I did not stop there. Since from the perspective of the RootModelObject, it is not it’s responsibility to determine if it should be scheduled, I created a shouldBeScheduled method on the ExtraData object, which then called a shouldBeScheduled() method on the Schedule object:

  1. class RootModelObject {
  2.   …
  3.   public boolean shouldBeScheduled() {
  4.         return getExtraData().shouldBeScheduled();
  5.   }
  6. }
  7.  
  8. class ExtraData {
  9.   …
  10.   public boolean shouldBeScheduled() {
  11.         return getSchedule().shouldBeScheduled();
  12.   }
  13. }
  14.  
  15. class Schedule {
  16.   …
  17.   public boolean shouldBeScheduled() {
  18.         return ( getScheduleDate().after(new Date()) ||
  19.                    getCronExpression() != null );
  20.   }
  21. }

This “string of pearls” makes it much easier to keep the code where it needs to be, while providing convenience to the component developer.

So, the code is better, but part of me says that the code really should look like this:

  1. public void someHigherLevelComponentMethod(RootModelObject root) {
  2.   …
  3.   root.schedule();
  4. }

Since technically, when you say “process immediately” you are effectively saying “schedule for processing now”. What do you think?

Books
General
Java
Software Development
Thought

Comments (2)

Permalink

Amazon aStore front

So, I’ve been playing around with advertisements on this blog since the beginning, mainly so I could understand what it is all about. Over the last two years I think I’ve made about $20 total. A couple of months ago I put an Amazon advertisement on my sidebar, which did not really do much as it was in a horrible location. The links to specific books seem to work well, as people have bought some books through them.

So, I am always kinda looking around to see what is out there in the internet advertising realm. Recently, Amazon started what it is calling aStore, a way for normal people (as well as people like me) to create a store using Amazon’s product catalog. It’s an interesting idea, so I thought a little while on what I would like to see in a Amazon store, and came up with Coders Haven.

The idea behind Coder’s Haven is simple: out of all the computer programming books out there on Amazon, take the best ones and put them all together on a single page. The best ones in this case are the best books that either I have personally read, or a colleague has read and not been able to shut about it. I think when you look at the set you will see why. The other idea is to change the list out every month or two. So right now the books are decidely agnostic on the whole technology stack. They are more meta type books, and for good reason: I want only the best of the best right now, and these are the best.

aStore is currently in Beta, and it shows. The administration aspects of the store are a little difficult, such as only being able to hand pick the front page items, and then only being able to pick 9 items. I really wanted to hand pick the entire store, but they only allow keyword filtering on the subsequent category pages.

So, go take a look… if nothing else it would be interesting to hear other people’s thoughts on this.

Books
General
Software Development

Comments (1)

Permalink

PST’s

Tonight I finished The Idea Book, by the guys at interesting.org. The book is not readily available in the US, but the great folks over at inBubbleWrap.com and 800cr kindly put together a fundable project to get an order of the book shipped to the US from Sweden, and I got in on the deal. By the way, if you are interested in the book, there is a sample of the book (around 35 pages if I remember correctly available here).

150 pages about ideas.
150 pages for your own ideas.
An idea book.

The first thing you notice when opening the book is that the content is interleaved with a number of plain white pages. These are for your ideas. So that you can jot as you read. I was tempted, but instead chose to have a sheet of paper handy for the note taking, in case people want to borrow it.

There is so much great stuff in the book that I could go on and on. Instead I will leave you with one tidbit of advice: Don’t be a PST (Person who has Stopped Thinking). These are the people who continue to do things the same way, all the time,because that is the way it always has been.

Always be willing to question the norm, and look for another way of doing things. I know that I at times (more often then I would like to admit) have been a PST. It is an insideous trap, because while you are stuck in PST mode, chances are good that you do not even know you are stuck! Be willing to accept new ideas. Question everything. Think Different. (your pithy two word statement goes here)

Books
General
Self
Software Development
Thought

Comments (0)

Permalink