Writing Code for Other People Tom Mullen The barriers and techniques of human intelligence are starting to be uncovered by psychologists. There are remarkable parallels between the cognitive model and principles established by software designers. It is as if the jigsaw puzzle that software designers have been working on has been turned over to reveal another picture on the back, the very same picture that psychologists have been building...
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Elements of Cognitive Psychology
Chunking and Memory A chunk is “a collection of memory elements having strong associations with one another but weak associations with elements within other chunks” Structured Design Principle: “maximise cohesion and reduce coupling”
Chunking and Memory STM Capacity Limit CRC Model Refactoring STM Time Limit Indirection cost
LTM Structure Discrimination Nets
Cognitive Model
Summary Conjecture: Current software languages and design principles guide a programmer to produce code that is a direct textual representation of the memory network of the solution within the brain (subject to the constraints of short term memory).
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Analogies
Meeting Room Analogy
Gentner Classification
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Analogy Template
Analogy Patterns in Software
Analogy Patterns in Software Attribute Only [Map] Map exchangeCountry = new HashMap(); exchangeCountry.put("CBOT","US"); exchangeCountry.put("LIFFE","England"); Na Aa Nv Av
Analogy Patterns in Software Statement Shape p rivate boolean isValid() { if (expirationDate == null || !( expirationDate.getTime() > 0 ) ) return false; if (contractNumber == null || !(contractNumber.longValue() > 0) ) return false;
Analogical Translations
Analogy Patterns in Software Method Name (Prefix) public void visitExpression(Node a){}; public void visitBlock(Node a){}; public void visitFile(Node a){};
Analogy Patterns in Software Application Level Running Instances are Literal Similarities of one another. Configuration details the attributes IOC mechanisms allow operations
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Parlay? In Pirates of the Caribbean what was Captain Barbossa's response to Elizabeth Swan's demand that the Pirate Code required him to put her ashore safely?
4 minus Analogies Rule The core fundamental metric of software de-sign is that software should be chunked in elements of four (or fewer) after allowing for any number of varieties of analogies.
The Pirate Code “… more what you’d call ‘guidelines’ than actual rules” – Capt. Barbossa, Pirates of the Caribbean: The Curse of the Black Pearl
Overview Cognitive Psychology (Chunking and Memory) Analogies Psychologists Definition Code Structures Fundamental Metric Using the Cognitive Model
Can be taught using life experiences Is the foundation of software design principles Design principles still need to be learned! Use to discover new principles?
Conclusion Cognitive Psychology: Detailed the strong mapping between the cognitive model and design principles. Chunking Analogies: The two primary disciplines in good software design are: recognising & coding analogies chunking. Used these results to discover the “4 minus analogies” rule. Questions?