Friday 31 January 2020

Thinking about (programers) thinking.


One of the hardest things to do is understand how others think but failure to see and understand the worldview from another persons viewpoint can give rise to unreconcilable conflict. Seeking first to understand how others think can also enhance ones own worldview. This article will delve into four different ways thinking used by programers and other technology specialists in the construction of software solutions. Understanding these different modes will provide insight into "programmers thinking".

Iteration

Step by step from the start to the finish. One item taken at at time in a predictable order. Most often seen in the processing of lists and tables.
Look for phrases like  "for ( i=5; i<20; i++ ) { B[i] += 20 }"

Iteration provides the most basic way of processing items in sequential order. Usually performed one at a time iteration is the most common form of relating the same operation on different items.  Programmers will understand that the above loop have all the iterations executed in parallel but the following loop can not be safely executed in parallel.

 "for ( i=5; i<20; i++ ) { B[i] += B[i-5] }"

Recursion

Best understood as room by room approach. Think of working though a mansion house using these instructions
1a) Enter a room.
1b) Process the current room.
2) Find the doors list for the current room - if list not found then make a list of the doors in this room with the door you came in highlighted and crossed off. Leave door list in room.
3a) Pick an unprocessed door from the room's door list, cross that unprocessed door off and exit via that door.
3b) if the list of doors in this room is finished then exit out the most recent entry door highlighted on the rooms door list.
4) If there are no doors in the room then you are in an oubliette and will have to wait for Hoggle to help you out the Labyrinth.

Recursion is most often seen in the processing of branched trees of information.

Look for procedures that call themselves where inside the definition of treewalk a call is made to treewalk. Look for a structure like "Define Treewalk ( node ) { process_this_node ; Treewalk ( left ) ; Treewalk ( right )  } "

Recursion requires an exit point for closure.

Object Orientation

This way of thinking binds together the processing instructions and information to be processed. Make a data object then ask the object about itself or tell the object to do something to itself. Objects can be grouped into related families that inherit behaviours and attributes. For example: An object Animal is defined with attributes of name, species, habitat, colour.  An object of that class is made "Instantiated" for Cat with attributes Speedy, Manx, domestic home and ginger. Another object is made for Goldfish with Goldie, shubunkin, domestic tank and gold. Within the object definition the logic for how the objects interact is created so that Result of Cat + Goldfish has a meaningful outcome.
Look for references to the object "self.".

Propositional Logic

Describe the problem by dissembling the internal problem into the smallest possible phrases that together describe the whole problem. Propositional logic is a pathway to a solution, a way that multiple problems can be re-presented for solution by a single logic solver.
Look for references to "assert" followed by a definition.  See Solving-classic-sudoku-using-using-smt for a worked example.

Further reading about the different way of thinking and personalities in the IT and cyber world.

** Update May 2020 

Check out this Wired read that really nails the hacker psych and how it turns bad.

No comments: