Wednesday, October 5, 2011

The Mythical Man-Month – Extracts VI

Source: The Mythical Man-Month

Communication in the Large Programming Project

Schedule disaster, functional misfits, and system bugs all arise because the left hand doesn't know what the right hand is doing. As work proceeds, the several teams slowly change the functions, sizes, and speeds of their own programs, and they explicitly or implicitly change their assumptions about the inputs available and the uses to be made of the outputs. How, then, shall teams communicate with one another? In as many ways as possible:
• Informally. Good telephone service and a clear definition of intergroup dependencies will encourage the hundreds of calls upon which common interpretation of written documents depends.
• Meetings. Regular project meetings, with one team after another giving technical briefings, are invaluable. Hundreds of minor misunderstandings get smoked out this way.
• Workbook. A formal project workbook must be started at the beginning. This deserves a section by itself.

The Project Workbook

What. The project workbook is not so much a separate document as it is a structure imposed on the documents that the project will be producing anyway.All the documents of the project need to be part of this structure.This includes objectives, external specifications, interface specifications, technical standards, internal specifications, and administrative memoranda.

Why. Technical prose is almost immortal. The early design of the project workbook ensures that the documentation structure itself is crafted, not haphazard. Moreover, the establishment of a structure molds later writing into segments that fit into that structure.The second reason for the project workbook is control of the distribution of information. The problem is not to restrict information, but to ensure that relevant information gets to all the people who need it.

Organization in the Large Programming Project

If there are n workers on a project, there are (n2-n)/2 interfaces across which there may be communication, and there are potentially almost 2" teams within which coordination must occur. The purpose of organization is to reduce the amount of communication and coordination necessary; hence organization is a radical attack on the communication problems treated above.

The means by which communication is obviated are division of labor and specialization of function. The tree-like structure of organizations reflects the diminishing need for detailed communication when division and specialization of labor are applied.

In fact, a tree organization really arises as a structure of authority and responsibility. The principle that no man can serve two masters dictates that the authority structure be tree-like. But the communication structure is not so restricted, and the tree is a barely passable approximation to the communication structure, which is a network. The inadequacies of the tree approximation give rise to staff groups, task forces, committees, and even the matrix-type organization used in many engineering laboratories.

Let us consider a tree-like programming organization, and examine the essentials which any subtree must have in order to be effective. They are:
1. a mission
2. a producer
3. a technical director or architect
4. a schedule
5. a division of labor
6. interface definitions among the parts

All of this is obvious and conventional except the distinction between the producer and the technical director. Let us first consider the two roles, then their relationship.

What is the role of the producer?

He assembles the team, divides the work, and establishes the schedule. He acquires and keeps on acquiring the necessary resources. This means that a major part of his role is communication outside the team, upwards and sideways. He establishes the pattern of communication and reporting within the team. Finally, he ensures that the schedule is met, shifting resources and organization to respond to changing circumstances.

How about the technical director?

He conceives of the design to be built, identifies its subparts, specifies how it will look from outside, and sketches its internal structure. He provides unity and conceptual integrity to the whole design; thus he serves as a limit on system complexity. As individual technical problems arise, he invents solutions for them or shifts the system design as required. His communications are chiefly within the team. His work is almost completely technical.

Now it is clear that the talents required for these two roles are quite different. Talents come in many different combinations; and the particular combination embodied in the producer and the director must govern the relationship between them. Organizations must be designed around the people available; not people fitted into pure-theory organizations.

Three relationships are possible, and all three are found in successful practice, and they are:

  • The producer and the technical director may be the same man.
  • The producer may be boss, the director his right-hand man.
  • The director may be boss, and the producer his right-hand man.

Tuesday, October 4, 2011

JavaScript II - Expressions and Operators

About Arrays, Objects and Functions

Object Creation Expressions

new Object()
new Point(2,3)
If no arguments are passed to the constructor function in an object creation expression, the empty pair of parentheses can be omitted:
new Object
new Date

Object and Array Initializers

Object and array initializers are expressions whose value is a newly created object or array.

var arrayOfArrays = [[1,2], [3]];
var obj = { x:1, y:’otv’}; // Object with 2 properties

Property Access Expressions

Two syntaxes for property access:

var obj = {x:5,y:2};
obj.x;    // 5 expression.identifier
obj['y']; // 2 expression [ expression ]

Function Definition Expressions

var duplicate = function(x){return x*2;}; // Function definition


Operator Description Input Output
void Return undefined value any undef
*, /, % Multiply, divide, remainder num,num num

Unary operator that attempts to delete the object property or array element specified as its operand

// Deleting object properties
var obj = {x:1,y:2};
obj.x;  //Before deleting property value=1
delete obj.x;
obj.x; //After deleting property value:undefined
// Deleting array elements
var array = [10,20];
array.length;   // 2
array[0];       // 10
delete array[0];// true
array.length;   // 2
array[0];       // undefined

Not all properties can be deleted, however: some built-in core and client-side properties are immune from deletion, and user-defined variables declared with the var statement cannot be deleted. Functions defined with the function statement and declared function parameters cannot be deleted either.

property or array element


Determine type of operand.

var trueTypeOf = typeof true; // “boolean”

The following table specifies the value of the typeof operator for any JavaScript value:

Parameter Return
undefined "undefined"
null "object"
true or false "boolean"
any number or NaN "number"
any string "string"
any function "function"
any nonfunction native object "object"
any host object An implementation-defined string, but not “undefined”, “boolean”, “number”, or “string”.

any str

Test whether property exists.It evaluates to true if the left-side value is the name of a property of the right-side object. For example:

var person = { name:’Bob’, address:’Marylan’}; // Define an object
"name" in person    // true: object has property named "name"
"toString" in person// true: object inherits toString method
var data = [10,20]; // An array with elements 0 and 1
"0" in data         // true: array has an element "0"
5 in data           // false: no element 5
str,obj bool

Test object class. It expects a left-side operand that is an object and a right-side operand that identifies a class of objects. The operator evaluates to true if the left-side object is an instance of the right-side class and evaluates to false otherwise. Take into account that in JavaScript, classes of objects are defined by the constructor function that initializes them. Thus, the right-side operand of instanceof should be a function.Examples:

var currentDate = new Date();  // Create a new object with the Date() constructor
currentDate instanceof Date;   // true currentDate was created with Date()
currentDate instanceof Object; // true all objects are instances of Object
currentDate instanceof Number; // false currentDate is not a Number object
obj,func bool

Test for equality using a more relaxed definition of sameness that allows type conversions.

any,any bool

Test for inequality

any,any bool

Test for strict equality. Known as the strict equality operator (or sometimes the identity operator), and it checks whether its two operands are “identical” using a strict definition of sameness (does not perform type conversion)

any,any bool

Test for strict inequality

any,any bool

Ternary operator. Example:

var name = 10>5?'Ten':'Five'; // ‘Ten’

It expects one argument. If you pass any value other than a string, it simply returns that value. If you pass a string, it attempts to parse the string as JavaScript code, throwing a SyntaxError if it fails. If it successfully parses the string, then it evaluates the code and returns the value of the last expression or statement in the string or undefined if the last expression or statement had no value. If the string throws an exception, the eval() propagates that expression.

eval("x=100") //change local variable
eval("function localFunction() { return x*2; }"); //define local function