Defining Programming Standards   
for Professional Programmers 
  

         

Home

Contents

1: Standards

2: Psychological Factors

3: General Principles

4: Commenting

5: Naming

6: Code Layout

7: File Layout

8: Language Usage

9: Data Usage

10: Programming Usage

11: Implementing Standards

A: Example Standard

B: References

C: Glossary

Syque

About

Share this page:

Google
C Style
syque.com
Web

 

 

Books and
more at:

USA:

In association with amazon.com

UK:

In Association with Amazon.co.uk

Canada:

In Association with amazon.ca

 

 

CHAPTER 2 : Psychological Factors

PART 1 : BASICS

CHAPTER 2 : Psychological Factors

2.1 Pattern Recognition
2.2 Filtering
2.3 Habit
2.4 Redundancy
2.5 Cues and Context
2.6 Recognizing Basic features
2.7 Short Term, Working and Long Term memory
2.8 Chunking
2.9 The Rule of Seven
2.10 Context Switching
2.11 Modifying the image
2.12 Memorizing sounds
2.13 Eye focus
2.14 Eye movement
2.15 Looking ahead
2.16 Looking back
2.17 The subconscious is always right
2.18 Natural ambition
2.19 Summary

<--Prev page | Next page -->

 

2.10 Context Switching

When you are talking about something, and get interrupted (and parentheses in a sentence like this is just such an example) then what you were thinking about before the interruption goes onto a 'mind stack'. Successive interruptions cause the previous context to be pushed onto the stack, and popped off again only when the interruption is completed.

The stack is held in relatively volatile memory. So what happens is that whilst the interruption is taking place, the mind needs to go back and refresh the stack, reviewing and thinking about the items stored there. The result of this is that the more data there is on the stack, either from several interruptions or from a context containing much data, the less time is available to process the current data, and the easier it is to make mistakes.

Whenever an extra level of detail is used in a C program, such as a compound statement or a function call which must be 'followed', the reader has to push the current context onto his stack, whilst processing the new block (although, like real life, the saved context can still interact with the current action). Thus deep levels of nesting add to the complexity of the program and reduce its readability. Note that this also happens at a micro-level with parentheses in expressions, nested structures, etc.

A similar, but often hidden, effect happens when the reader comes across something, possibly a complex algorithm or an element of style, which is unfamiliar to him. Again, he will push the current context onto the stack whilst he ponders the meaning of the unfamiliar item.

Consider the section numbering in a book: a section numbered 3.8.7.5.9.11.2 would indicate a very complex book, yet it is only seven nested sections. Could we not push each context onto each of the seven slots in short term memory? In fact, complexity increases in a non-linear fashion with each new context, and three section levels (e.g 3.8.7) is a more common limit, with deeper nesting being the exception, rather than the rule.

 

<--Prev page | Next page -->

 

 

  © Syque 1995-2010

Massive Content -- Maximum Speed