Thursday, August 24, 2006

A Year Gone By

..and a short break from the technical posts…

I can hardly believe it’s been a year (today) since my mom passed away.  We have gone through a lot to come to terms with the fact that she is not with us anymore.  Luckily we were (and are) surrounded by loving and supportive family and friends that help us through our hard times.  For that I am truly thankful.

Sometimes I feel like I wish I could cry more about losing her, and other times tears just hit me – mostly when I’m alone, driving and listening to music– when I am reminded of her.  It feels good to cry about it every once in a while.  It reminds me that I am human and that she still holds a large place in my heart.

My fiance, Silvia (who just started a blog herself) posted a touching memoir and scrapbook page on her blog.  Reading her comments makes me remember the good times we all had together, and not so much on the pain in the end.

I posted this link last year as well, but I want to post it again for my new readers to consider making a small donation to the Ovarian Cancer Research Fund.

Now playing: A Perfect Circle - Gravity

I got my Coding Horror Sticker Today

Today I received my free Coding Horror Sticker in the mail from Jeff Atwood. Thanks Jeff!

IMAGE_033

He even hand-wrote the envelope!  350 of them ?!?!

 

Wednesday, August 23, 2006

The Partial function in MochiKit

MochiKit is awesome.  I’ve only begun to scratch the surface of the power in this framework.

During my demo I had a hard time explaining what the partial function does.  I have never been a Python developer, so MochiKit’s influence is foreign to me.  I do appreciate the simplicity of the syntax.

Partial is aptly named.  It is basically a partial function call, wrapped in an object.  Why would you want this, I hear you say?  Consider the following:

// $('ctrlid') is MochiKits alias of document.getElementById('ctrlid')

 

$('txtbox').onchange = filterText('some input'); //wrong!  the function will be called immediately!

 

$('txtbox').onchange = function() //need an inline function wrapper to make the function call

            {               

                filterText('some input');

            }       

$('txtbox').onchange = partial(filterText, 'some input'); //partial separates the function from the argument(s)

 

In this example, the top line is setting the onchange event handler of a textbox to a function call.  But Javascript doesn’t know that you want a function pointer here, it looks like you want to call the method and return something.  So the solution that you can do is write a single function that wraps the function call that you want to make.  This can be done inline like I do above.  Partial comes in and cleans up those 3 lines and pushes them into 1 line. 

Next take a look at this:

 function startsWith(character, target)

 {

    //searches target for character, if found... returns true

 }

 

 var startsWithCapitalB = partial(startsWith, 'B');

 

 alert(startsWithCapitalB('Ben')); //true

 alert(startsWithCapitalB('Henry')); //false

Here you see where partial gets its name.  You can partially apply a function with partial and get a function variable returned!

Partial is incredibly powerful when applied with other functional programming methods like map.

Now playing: Modest Mouse - Black Cadillacs

A Journey with Domain Driven Design (and NHibernate) - Part 5

In Part 5 of our Journey with Domain Driven Design & NHibernate, we introduce the database structure to support our objects. We also configure NHibernate and build a helper class to assist in the usage of NHibernate.

Presentation on Next-Gen Web Techniques

Thanks to all who attended my presentation on Next Generation Web Development Techniques at SARK.  We talked about web layout with CSS (and not tables), Javascript, MochiKit, and AJAX.

It was my first attempt at speaking, and I feel that it went pretty well.  If you attended, I’d love to hear your feedback here.  I did hear from a couple people that a talk on just CSS for layout would be popular.  I’d definitely consider this.

As promised, I have uploaded the complete files from the demos here for you to download.

File Attachment: next gen web techniques - complete.zip (678 KB)

 Links mentioned in the presentation:

Thursday, August 17, 2006

Making DIVs stay next to each other

A colleague came to me with a very simple issue yesterday.  He had a table surrounding the area he was working on, and he wanted to have 2 DIVs side-by-side, one of them containing a table.

Here’s what he had:

<table>
 <tr>
  <td>
  
   <div style="padding: 2px; margin: 2px; border: #ccc; background-color:#eee;">
    here's the first div
   </div>

   <div style="padding: 2px; margin: 2px; border: #ccc; background-color:#eee;">
    ..and here's the 2nd
    <table border=1>
     <tr>
      <td>with a table</td>
     </td>
    </table>
   </div>
  </td>
 </tr>
</table>

...which looks like:

here's the first div
..and here's the 2nd
with a table

 

He tried a number of things that didn’t work.  Here’s the solution:

DIVs are block level elements that stretch to 100% of the width of the parent container.  So to get them to sit next to each other you first need to give them some room to do so.  Set the width so that they will both fit (be sure to account for border + margin as well).

The next thing to do is set the DIVs to float:left;  This will make them push up next to each other until there is no more room, then they will wrap.

Here it is in action:

 <table>
 <tr>
  <td width="300">
   
   <div style="margin:2px; padding:2px; border: solid 1px #bbb; background-color: #eee; float: left; width: 75px;">
    here's the 1st div
   </div>

   <div style="margin:2px; padding:2px; border: solid 1px #bbb; background-color: #eee; float: left; width: 75px;">
    ..and here's the 2nd
    <table border=1>
     <tr><td>with a table</td></tr>
    </table>
   </div>
  </td>
 </tr>
</table>

here's the 1st div
..and here's the 2nd
with a table

 

Understanding how floating works is an important part of effective CSS web design.  I may consider some more of these simple examples if they are of help to my readers.

Newshutch is my friend

For my RSS Feeds I had previously used RssReader.  I used it because I wanted a windows application that would notify me of new posts and not be too obtrusive.  RssReader is pretty nice, but the interface needs quite a bit of polishing.  I also disliked not having a distributed opml or something so that I could access all of my feeds on another computer.

I have since crossed over and succumbd to web-based RSS Feed readers.  I’ve tried Google Reader, Newsgator, Bloglines, and others… but I didn’t like any of them.

My new friend for RSS feeds is Newshutch.  Incredbily simplistic, but functional.  The interface doesn’t get in my way and the nice use of Ajax means that I can leave the window open and it will automatically get my feeds for me.  As I read an entry, I can click 1 button and have that entry fade away and the ones below it to float to the top.  This fits nicely with the way I like to read blog posts, so this one is most-likely here to stay.

Sunday, July 23, 2006

A Journey with Domain Driven Design (and NHibernate) - Part 4

In Part 4 of the series, I dig deeper into the tests to fill out the requirements. We talk briefly about some Domain Driven Design concepts and finish up with enough functionality to move on to the database.
Wednesday, July 19, 2006

A Journey With NHibernate (and DDD) - Part 3

In Part 3 of the series, I jump head first into unit testing our domain model with NHibernate.
Monday, July 10, 2006

A Journey With NHibernate - Part 2

In Part 2 of the series we create our project structure and introduce a first-draft implementation of our model.
Wednesday, July 05, 2006

A Journey with NHibernate - Part 1

In this series of articles we will dive into the world of Domain Driven Design. Along the way we'll focus on concepts of Object Oriented Design, Test Driven Development, Refactoring, and Object-Relational Mapping with NHibernate.
Phoenix Landscaping - Scottsdale Landscaping - Credit Card Consolidation - Unsecured Loans