# Martijn van der Woud Member since Mar 26, 2009

## Recent Blog Comments By Martijn van der Woud

• #### Create A Running Average Without Storing Individual Values

Posted on Jul 9, 2009 at 4:44 PM

@Jody, @Roland I think you both made your points clear. Now would be a good time to stop your catfight. I am getting bored... Martijn... read more »

• #### Create A Running Average Without Storing Individual Values

Posted on Jul 3, 2009 at 3:06 PM

@Dave Totally agree that tricks like this one by Ben and the one you just mentioned are incredibly handy sometimes. Do you know of any reference page where they collect things like these?... read more »

• #### Create A Running Average Without Storing Individual Values

Posted on Jul 3, 2009 at 2:54 PM

Mmmm... looks like I missed a part in my above comment. if a) M = Sum / N; then d) Sum = M * N; and e) N = Sum / M As I mentioned when you add a number X to the collection, then b) Sum = Sum + X; and c) N = N + 1 By inserting d) into b) you get f) Sum = (M * N) + X If you insert f) and c) int... read more »

• #### Create A Running Average Without Storing Individual Values

Posted on Jul 3, 2009 at 2:41 PM

You can easily prove this by applying some calculus that even I can understand: ;) Given a) M = Sum / N; If you add the value X to the collection, then b) Sum = Sum + X; c) N = N + 1 now fill in b) and c) into a) : M = (Sum + X) / (N + 1) But it is of course always good to check these things... read more »

• #### OOP Philosophy: Invalid State vs. Invalid Method Call

Posted on Mar 26, 2009 at 5:15 AM

As interesting as discussions like this one are, in my opinion it would be best to sum up different feasible solutions to the problem, instead of trying to find the silver bullet. So what exactly is the problem here? I understand it as follows: "how do we handle the possibility that the (combinati... read more »