July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  
Chris Donnan

Create Your Badge

Chris Donnan : Programming – Brooklyn Style

software, trading, family, fun

Crazy, Insane, Huge Spider Web

In or yard, we have the hugest spider web I have ever seen – by far. Now perhaps I have not spent enough time in the wilds of the wold, but this web starts AT THE PHONE LINE up some… 15 feet at least up. It runs across the stairs up to the outside – this stairway is likely 3-4 feet across. The ‘core’ of the web must be around 3-4 feet across, and the extensions run way up to the phone lines. Anyhow – here is a semi-good shot of the spider web.

It made for an interesting camera exercise. It is really the 1st time I was able to USE the manual focus WELL to achieve a purpose. I was able to lower the F down a bit to get the background blurred out a bit. I was able to use a prime lens (although I DID get some good shots with my Sigma zoom) and creep up to see it out a window. Cameras are cool – but I am SUCH an amateur, trying to use my prosumer Canon XTi. I also noticed that the image stabilizer for my Sigma zoom lens has been OFF… Lessons…

-Chris-


Responses are currently closed, but you can trackback from your own site.



The simplest possible DI container (part 4)

In this segment, we will discuss pushing in singletons that you have already created and adding a simple generic hook point.

Here is our starting test. We want to create something outside the container, then add it as a singleton.

This is trivial, we simple give it a delegate that returns that instance when it is called.

Here our lambda is just going to return that instance. (PS – this is a C# lambda expression, google it.).

But wait, what is wrong here… was it so trivial? Well, how about disposal? Do we want to dispose this thing when our container is disposed? I do not think so… So we can create a policy that does not dispose.

Here is a test:

Let us split our SingletonCreationPolicy into 2 parts – 1 that is the same in both cases – the creation bit, and 2 – the disposal bit we can ‘add on’ in only the case we want it in. This results in:

In our Kontainer class:

 the basic singleton creation policy is broken out (back to):

And finally, the Disposable version of the policy for ‘container managed’ singletons:

OK, so that code allows us to push singletons into the Kontainer and allows them to be disposed correctly. (Note the use of protected auto-properties. Less code - I like it).

Hook points

Many 3rd party vendors have used events as hook points for some time. I think grid control products like DevExpress’s XtraGrid have gone far and wide using events as the primary ‘hook points’ to their APIs.

In order to give similar behavior to SpringFramework’s IObjectPostProcessor, we can add an event for a similar effect. Let us start with a test:

We want to hook onto the point when a user is ‘getting’ an object. and ‘do something’ before they actually get it. In this case, we are getting drastic; we are completely replacing what the container has internally. Most usages would be more benign most likely.

We change our Get method, add a GettingObject event and allow callee’s to each have a go at the returning object. So our Kontainer class changes like:

This will happily allow callers to modify the created object and return to the ultimate caller of Get the result. It id the event listener’s perogative to elect to process the created object based either on the object itself or on the label.

So; there you have a nice way to push instances of objects into the container and a cheap hook point to ‘do stuff’ when the user calls to Get.

More soon;

Chris


Responses are currently closed, but you can trackback from your own site.



Being a Good Daddy

I love being a dad. I have always been a self proclaimed ‘child monger’; making faces at kids on the subway and such. Kids generally like me and I like them. Kids generally smile at me, respond to me – and mostly they give me an excuse to act like a 3 year old myself.

Having just spent a few weeks with my kids; Gabe (who turned 6 yesterday) and Micah (3.5) and I have been thinking about them a lot. I aspire to be a good daddy. Gabe has told me on a few occasions that I am a ‘good daddy’ so I wanted to write up a quick retrospective of a few weeks with the kids – where am I doing well as a dad, where do I need to work, what do they respond to, etc.

My goals as a dad

  • To make my boys know they are loved and valued
  • To make my boys respect themselves and others
  • To prepare my boys to be flexible to lives that change
  • To instill in my boys the passion for whatever they find in their lives to care about
  • To instill a love of learning in my boys
  • To help prepare them to have healthy, meaningful, rewarding relationships with others
  • To help them love and respect each other as brothers, people, and friends

My mechanisms for achieving these goals

  • Listen to them, be attentive
  • Give them boundaries and let them know where they are
  • Talk to them at their level
  • Put them in good schools
  • Cooperate with my wife, align our expectations, talk about the kids
  • Spend time with them one-on-one and with the whole family
  • Use an even tone when speaking to them
  • Think about parenting
  • Read about parenting

Where can I improve?

After a few weeks of being with the kids all day, every day – here is what I think I can improve on:

  • Micah is still ‘the baby’ a bit. I need to align myself with Gabe as much as Micah when there are arguments, battles, etc. Little boys fight – it is important to make them both know they are respected and have a voice when they get in a tussle.
  • Patience. There is no end to the amount of patience that you need to have as a parent. My wife is more patient than I. I have patience, I could use more.
  • Evenness of speech. I simply need to keep an even tone when speaking to the boys, when they are in a fight, when they are being nutty, when they are doing anything – I need to have an even tone. This is a ’subclass of’ patience I think.

Divisiveness/ Togetherness

Whenever you have greater than 1 child, it is important to drive them together. My wife Shannon and I work hard at driving our sons together and are very cognizant of ‘not driving wedges’ between our sons. It is very easy to be divisive or cause dynamics that make kids resent one another. “Why is HE getting all the attention?”, “Why am I always getting in trouble?”, etc. This is one of those areas that I think Shannon and I are doing well, but only because we are ALWAYS really thinking of how to avoid driving wedges between our boys, and focusing on how to coerce them into brotherly love.

Boundaries

I thought that the idea of boundaries and their importance needed a quick comment. I think that the concept of boundaries is one of the most central and critical concepts in parenting. Kids thrive on strucuture and expectations. Kids need to know where the ‘edges’ of their lives are. It is SO important (IMHO) to let kids know where their bounds are in their lives. How do you do this? Well, mostly by telling kids where the boundaries are, offering a penalty for violating (and the hard bit) following through with the penalty WHENEVER the violate the boundary. CONSISTENCY is KING with kids.

I read in some book about parenting once; (psuedo-quote) “Kids do not hear what you say, they hear the actions”. So if you say something like “if you color on the wall; then you will go to bed early”, then the child colors on the wall and they DO NOT go to bed early, then the kids learn they DO NOT REALLY HAVE A BOUNDARY.

A general concept in my life that I try to adhere to is; having a STRICT match between my word and my actions. Child rearing is one area of life where the benefits of this mantra are clear. It is clear that this is an important concept to live by in other relationships, work, etc – but in parenting – it is just in your face. When you violate your word, you kids learn that their boundary is NOT where you SAID, but where you acted. They learn you are malleable, and they try to push you and cajole you to sort out where that actual boundary is.

Anyhow – there is my humble 2 cents on being a good daddy. I am not saying I AM a good daddy, just that I want to be :) I will ALWAYS be improving in this, and I will ALWAYS need to improve here.

-Chris-


Responses are currently closed, but you can trackback from your own site.



The simplest possible DI container (part 3)

In this segment, we will make our stuff dispose nicely.

1st – let us look @ our creation policies in a bit more detail:

Here is the simplest possible one – a prototype creation policy. It will simply call the user’s func each time it is called, passing in the calling container for possible child dependency resolution :

The singleton creation policy is a bit more:

This policy uses the user supplied func to create a value 1x, then returns the value for all subsequent calls.

Now – why is this relevant? Well in order to dispose properly, we need to make our container disposable and implement that so – in normal form – here is a test and a little class to help test:


All we want to do is to dispose our container and ensure that any disposable items are disposed – for creation policies that want it as such.

So – we will add a dispose method to our container:

Our container has a field that is a dictionary of string to Definition. The list of values is a list of definition. If our definition has a disposable creation policy, we dispose it. This is using LINQ to select the values in an orderly fasion and a functional-esque call to dispose each in the ToList().ForEach(lambda) call.

We updated our singleton creation policy to look like this:

So – now our singleton creation policy will dispose singletons when the container disposes. If a caller supplies any disposable custom creation policy – it will also dispose as per their mechanism.

Now – I need to make sure that I throw exceptions ‘at the door’ when users provide bad data, or use the container incorrectly. After that, I need to make a pass at thread safety for the container…


Responses are currently closed, but you can trackback from your own site.