coding the activity

Table of Contents

What do coder do when they code:

1. Design   ATTACH

designing the process, often scripting how they would be manually performed.

For example, when coding a robot controller that follows wall with PID controller, designing would be to spread out the strategy for parallel wall, for going outside and inside corners, and how PID controller’s output affect robot’s movement.

_20240105_023035screenshot.png

Figure 1: going inside corner

1.1. Depth of design work

How detailed should designs be? How much of the function should be completed before opening a .java file?

3 predicates could come in handy:

primitive
design until whatever is left is primitive to you to write in the language
formula
if you have broken down a piece of the function to a formula, you are pretty much done for design
start to end
go through the design and see if they connect the start and the end

2. Implementation

Translate design into executables.

Writing the code, configure service, setting up server, setting up environment, to make things that run on themselves

2.1. Depth of implementation

Depth of implementation should be super flat.

The decision coder make in implementation could be:

tool
use dictionary, list, or vector to store a collection.
naming variable
’dedicated-session-session-time-counter, sessionTimeCounter, sessiontimecounter
macro/helper function
to spot similarity in code and make them macros and helper functions
which syntax
cond, condp or if; while loop or for loop.
some small counting
lookupTable[i] be distance, lookupTable[i+1] be value

The decision coder should not make in implementation at least include:

make design desicions
with feedback loop: directly controll value or controll derivative of value

3. Link

Backlinks

(Processing is bad)

Implementation of any kind is destructive: you are making behaviours of code that do not exist before, you are creating entities that could break the whole program.

Example be you are programming in C, and at one time, when dealing with a sorting problem, you paused to decide on whether to use recursion or loop to do that sorting(which indicated that design is not complete enough), and forgot that you created an object that needs to be cleaned. Afterwards you’d find the program being wierdly slow and sometimes give you value you don’t understand why they would appear. That’s because you messed up something you would never expect yourself to mess up.

Moreover, practical code are flooded with ad-hoc solutions like “-1 means left, 1 means right”, “this variable should be tuned; value normally resides in [0,4]”, “if the for loop is never broken, i would be len(a)+1” or “timeCounter would be added and go up to timeCounterTarget”. Complete standalone documentation and inline documentation could alleviate cognitive load of remembering them, but some of them you still needs to keep track on, like to close resource after done, reset global variables when a behaviour is over and such.

Author: Linfeng He

Created: 2024-04-03 Wed 23:22