miércoles, 19 de enero de 2011

MySQL slow queries

sudo mysqld_safe --timezone=+0:00 --long_query_time=1 --log-slow-queries=/tmp/slow.log --log-queries-not-using-indexes

Sort by Rows_examined:

grep Query_time /tmp/slow.log |sort -n -k9
# Query_time: 0.007019 Lock_time: 0.000098 Rows_sent: 0 Rows_examined: 65
# Query_time: 0.001595 Lock_time: 0.000042 Rows_sent: 0 Rows_examined: 66
# Query_time: 0.002316 Lock_time: 0.000101 Rows_sent: 0 Rows_examined: 72
# Query_time: 0.003357 Lock_time: 0.000380 Rows_sent: 0 Rows_examined: 83
# Query_time: 0.003342 Lock_time: 0.000403 Rows_sent: 0 Rows_examined: 116
# Query_time: 0.004729 Lock_time: 0.000319 Rows_sent: 0 Rows_examined: 116
# Query_time: 0.002406 Lock_time: 0.000043 Rows_sent: 0 Rows_examined: 205

jueves, 13 de enero de 2011

Unit Tests' value in TDD

Hierarchy of tests:
  • Acceptance: Does the whole system work?
  • Integration: Does our code work against code we can't change?
  • Unit: Do our objects do the right thing, are they convenient to work with?

Unit Tests' value in TDD:
  • Write loosely coupled components
  • Detect errors while the context is fresh in our mind
  • Add an executable description of what the code does (documentation)
  • Focus: discouraging unnecessary features
  • Rythm: tests tell what to do next
  • Trust: tests give a reason to trust you
ref:
- Extreme Programming Explained
- Growing Object-Oriented Software, Guided by Tests

miércoles, 1 de septiembre de 2010

Brooks's law

adding manpower to a late software project makes it later

How to vanish terror of deadlines and expectations

It's not my job to “manage” someone else's expectations. It's their job to manage their own expectations. It's my job to do my best and to communicate clearly.

Kent Beck
Extreme Programming Explained

viernes, 6 de agosto de 2010

JavaScript Class using JSON prototype


/// <summary>
/// Class that represents a customer of our store.
/// The constructor receives the name of the customer
/// </summary>
/// <param name="firstName"> First name of the customer.
/// <param name="lastName"> Last name of the customer.
function Customer(firstName, lastName)
{
// Properties
this.FirstName = firstName;
this.LastName = lastName;
}

Customer.prototype = {

/// <summary>
/// Returns the first name of the customer
/// </summary>
GetFirstName: function()
{
return this.FirstName;
},

/// <summary>
/// Returns the last name of the customer
/// </summary>
GetLastName: function()
{
return this.LastName;
},
...
}


Usage:


var aCustomer = new Customer("Pablo","Bustos");
alert("Hello " + aCustomer.GetFirstName());

Good programmers

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Refactoring: Improving the Design of Existing Code by Martin Fowler

jueves, 8 de julio de 2010