| Homepage | Content | Slides | Video |
Warning
This lesson is under construction. Learn from it at your own risk. If you have any feedback, please fill out our General Feedback Survey.
Code analysis tools are some of the most important tools in a developer’s arsenal when it comes to finding and fixing bugs. Code analysis tools come in two flavors:
Debuggers are interactive dynamic analysis tools that are used to inspect your code as it runs.
C/C++ Tools
GDB
Valgrind
Python Tools
PDB
NodeJS Tools
node debug
Node Inspector
Linters inspect your code and flags suspicious usage. This can be to enforce a style guide or to flag code which will probably not compile or break the program when it is running.
src/times.js: line 407, col 20, Expected '{' and instead saw 'return'.
src/times.js: line 415, col 49, Missing semicolon.
src/times.js: line 407, col 58, 'error' is not defined.
Name Stmts Miss Cover Missing
-------------------------------------------------------
my_program.py 20 4 80% 33-35, 39
my_other_module.py 56 6 89% 17-23
-------------------------------------------------------
TOTAL 76 10 87%
IDEs are programs used to help developers get their job done by integrating many essential tools into one ecosystem.
The Linux kernel style guidelines are actually fun to read:
“First off, I’d suggest printing out a copy of the GNU coding standards, and NOT read it. Burn them, it’s a great symbolic gesture.”
NASA’s Jet Propulsion Laboratory style guidelines are very short and are concerned with automated tooling to do code analysis:
“All loops shall have a statically determinable upper-bound on the maximum number of loop iterations.”
Dependency isolation is the process of – wait for it – isolating the dependencies of a project. This is a surprisingly hard problem and many consider it largely unsolved.
Setup and enter the virtual environment.
$ virtualenv <virtualenv name>
New python executable in /path/to/<venv name>/bin/python
Installing setuptools, pip, wheel...
done.
$ source <venv name>/bin/activate
Install a package. This installs it in the current working directory and so does not ask for root permissions.
(<venv name>) $ pip install flask
[...]
To list all packages in the venv:
(<venv name>) $ pip freeze
click==6.7
Flask==1.0.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
Werkzeug==0.14.1
Deactivate (leave) the venv.
(<venv name>) $ deactivate
$
A Carbon Copy of the Production Environment(s)
Development servers are used to test that your code works in a real environment, with a real server, and real data. You shouldn’t throw your code up on a production website to see if it works, so a development server is as close to the real thing as you can get.