tools (7) programming (6) rails (5) cluj (4) productivity (4) misc (3) startups (3) emberjs (2) internet (2) software (2) hack (1) meetup (1) os x (1) science (1)

Tuesday, July 3, 2012

Three things I learned on a Tuesday

MVC is dead, it's time to MOVE on.
  • Models encapsulate everything that your application knows.
  • Operations encapsulate everything that your application does.
  • Views mediate between your application and the user.
  • Events are used to join all these components together safely.

What is a closure?
I'll give an example (in Scheme):

(define (make-counter)
  (let ((count 0))
    (lambda ()
      (set! count (+ count 1))

(define x (make-counter))

(x) returns 1
(x) returns 2

What this function, make-counter, does is it returns a function, which we've called x, that will count up by one each time its called. Since we're not providing any parameters to x it must somehow remember the count. It knows where to find it based on what's called lexical scoping - it must look to the spot where it's defined to find the value. This "hidden" value is what is called a closure.

Measuring added value of code refactoring
So an idea I recently came to my mind is to use the size of test code as an approximation for the added value. Then, an equation for the bonus point can be like below:
score = k1 * number_of_new_test_cases - k2 * net_amount_of_code_added

What did you learn this Tuesday?

No comments:

Post a Comment