Teaching basic lab skills
for research computing

Engineering-Focused Bootcamp

Summary: In advance of a bootcamp to be held for a Midwestern university's mechanical engineering department this fall, I've started reworking the traditional Software Carpentry (SWC) curriculum, and will be creating new teaching materials to accompany the workshop. Content changes are being made to accommodate the instructional needs of engineering students at the sponsoring university, while remaining consistent with the basic tenets and goals of the SWC movement. Comments and suggestions from the community on this matter are welcomed and encouraged, particularly in the area of PowerShell scripting (at which I'm currently a novice.) I'm also looking for instructors that might be willing to help teach such a bootcamp in the Detroit area this fall.

Introduction: A former research colleague of mine recently asked if a Software Carpentry workshop could be crafted to meet the needs of engineering students at the university where he currently teaches. After exchanging several emails, we agreed his students would benefit from having MATLAB replace Python during the programming portions of the workshop. Additionally, since the university's computers run the Windows operating system, it was decided that Microsoft's PowerShell language would supplant the traditional session on Bash shell scripting. Version control would remain unchanged, continuing to use Git. With these constraints in mind, I wrote up a brief synopsis of a tentative workshop itinerary and ran it past Greg Wilson to see if it would meet the criteria for being called a "Software Carpentry" workshop. He has given his tentative approval, but suggested I run my proposed workshop content past the community-at-large for further comment and advice. This blog post is intended to convey my reasoning behind the suggested modifications, as well as to lay out the new workshop materials.

Audience: Workshop attendees will be a mix of graduate and undergraduate mechanical engineering students. My colleague reports that they lack substantive programming experience, and display difficulty with relatively simple programming tasks such as declaring and typing variables. Although the traditional SWC curriculum covers these notions, it is felt these engineering students (especially those going into sub-disciplines such as Mechatronics that rely heavily on integrating software and hardware design), would benefit from seeing the manner in which programming abstractions are physically created. Thus, while most SWC attendees (primarily scientists) model physical systems on top of software abstractions, the proposed "engineering-focused" version of SWC would attempt to show how physical systems (electronic devices, mostly) permit the creation of these software conceptualizations. For example, while a pointer provides a useful mapping mechanism for programmers, there exists an electronic circuit that maintains the voltages and currents needed to implement the mapping. The Boolean logic that girds modern programming languages has to be somehow realized, and this is currently achieved by exploiting the electrical characteristics of semiconductor materials. While we cannot cover electronic design in any serious depth during a two-day bootcamp, it is my hope that we can provide students with a useful mental model that helps them understand how complex logic is constructed from a network of simple electronic devices. Starting with an enhanced understanding of computing mechanisms, I am further hopeful that the students will be better able to construct code that is aligned with the tools (both hardware and software) they have available to them.

Since the students use MATLAB for the majority of their day-to-day programming assignments, it makes sense that we use MATLAB rather than Python when teaching programming concepts. A MATLAB-based SWC bootcamp was taught at Manchester University earlier this year, and seems to have been well-received. Programming techniques critical for good MATLAB performance, such as memory allocation and loop vectorization, will be emphasized in the code examples. MATLAB will also be used to cover debugging and testing concepts. Scripting concepts will be taught to this audience using Microsoft's PowerShell language, as it is built into the operating system (OS) for Windows 7 and beyond. Since all the students are working the Windows OS, this precludes the need to install a Linux-like shell (such as Cygwin) to teach Bash shell scripting.

Concerns: My most fundamental worry is that I am trying to cover too much material in the time available. There is some possibility that this workshop could be spread out over three days, instead of the customary two-day format. Any suggestions or advice in this regard will be welcomed. I am also a newcomer to the world of PowerShell, so I'm very open to collaborating with someone who has PowerShell experience in generating teaching materials. All coursework generated for this bootcamp will be made freely available to the SWC community. Thanks!

Proposed Agenda:

Day 1

8:30 - 9:30 am: Programming as Engineering Skill. Discuss engineering aspects of programming. "Instead of software design becoming more like 'real' engineering, we're about to see the latter become more like the former." (see this blog post from 2009.)

  • Engineers as Programmers: Why engineering and programming are becoming irreversibly intertwined.
    • Programmable interfaces (APIs)
    • Software is "eating the world" (Marc Andressssen in a 2011 WSJ essay.)
    • Design through computer simulation and analysis
    • Programming skills as critical as calculus?
  • Engineering the Computer: How engineering advances make programming possible. (Much of this material will come from a Mechatronics course that I've taught the past several years.)
    • Electrical conductivity
    • Semiconductor materials
    • Diode as electronic "valve"
    • Transistor as electronic "switch"
    • Logic gate as electronic "function"
    • Flip-flop as electronic "bit storage"
    • Data register as beginning of "memory"
    • Analog voltage levels become digital "bits"
    • Memory and logic combined into CPU
  • Physical Constraints on Abstract Programs: How engineering decisions influence software design and usage. (Similar to physical constraints that engineers face when designing a bridge, or trying to accelerate a chemical reaction.)
    • Limited memory (reuse requires memory managment)
    • Limited processing power (sequential rather than parallel execution, clock speed)
    • Pointers into memory stack
    • Variable memory allocation (dynamic vs. static)
    • Microcode
    • Assembly language programming
    • Higher-level compiled languages
  • Anatomy of a Variable: Implications of declaring a program variable.
    • Purpose of a variable (beneficial to people, machine doesn't care!)
    • Variable contents are just ones and zeros
    • Where does a variable value start and end?
    • What "type" is a variable?
  • Anatomy of a Program: How software is prepared for execution, and how data is stored. (Not going into depth here, but rather trying to explain why these activities are important in software programming.)
    • Purpose of a program (again, for people!)
    • Defining a function
    • Conditional statements
    • Writing a program
    • Compiling a program
    • Running a program
  • Exchanging Information: How software shares data among internal components, and with the world.
    • Reading data from external sources
    • Storing a run time variable (volatile)
    • Storing results (non-volatile)

9:30 - 10:30 am: Hardware Example. Provide students "hands-on" experience of using software to accomplish an "engineering" task, by lighting LEDs via Arduino boards.

  • Arduino Programming: Have students use an Arudino "sketch" (mostly pre-written) to blinks lights
    • Distinguish between steps of programming, compiling, executing, and debugging
    • Illustrate compilation directives
    • Highlight program "flow"
    • Write to serial port to provide status information
    • Emphasize need for revision control
    • Have students pull program from GitHub

10:30 - 10:45 am: Break

10:45 - 12:00 noon: Introduction to MATLAB.

  • Why MATLAB?: Advantages and disadvantages of programming in MATLAB.
    • Optimized for linear algebra
    • Pros: Well-supported toolboxes; strong following in controls community; standard interface; well-tested
    • Cons: Expensive; not widely used in all science fields
  • MATLAB as IDE: Maneuvering about the MATLAB environment.
    • Program $PATH
    • Command window
    • Workspace window
    • Command history
    • MATLAB as a dynamic language
    • View existing data (.dat files)
  • MATLAB Numbers and Arrays: Examining the basic data types used within MATLAB
    • Numbers vs. Arrays
    • Array orientation is important!
    • numel, size, and reshape functions
    • Avoid array looping (use vectorization instead)
    • Memory preallocation
    • Special arrays: eye, ones, zeros
    • Element-wise array operations
    • Array indexing (1-based)
    • Array slicing
  • MATLAB Data Types: Examining the programming structures available within MATLAB
    • Numeric (intXX, single, double)
    • Complex number
    • Array (vector, matrix)
    • String as Array
    • Structure Array (struct)
    • Cell Array (cell)
    • Tables and categorical arrays (recently added by MathWorks to avoid toolbox dependencies)
    • Coercion (cast, typecast, char, int2str, str2num)
    • Type Verification (isinteger, isfloat, isnumeric, isreal)
  • MATLAB Operators and Functions: Logical and mathematical operators.
    • Logical comparisons (==, <, >)
    • Mathematical operators (+, -, *, \string^)
    • Built-In functions (mean, max, min)
    • Commenting code in MATLAB

12:00 - 1:00 pm: Lunch.

1:00 - 2:30 pm: MATLAB Programming. Give students a chance to write simple programs.

  • Flow Control: Directing the operation of a MATLAB program.
    • If/then/else loop
    • For loop
    • While loop
    • Switch/case
  • User-Defined Functions: Structure of a MATLAB function.
    • Function header (define function name, inputs, and outputs)
    • Accessing input values (nargin)
    • Accommodating a variable number of inputs
    • Manipulating and analyzing data
    • Returning output values (no return statement needed)
  • Automating Your Work: Writing MATLAB code.
    • Importing data (graphical interface and command line)
    • Sending messages to command window (disp and display)
    • Writing functions (encapsulation and independence)
    • Writing programs
    • Saving programs
    • Executing programs
  • MATLAB Objects: Making sense of the move to object-oriented programming within MATLAB.
    • Object programming
    • MATLAB classes
    • Dot notation
    • Object instantiation
    • Displaying object methods and attributes (methods, etc.)
  • Using External Libraries: Making use of pre-written and tested code.
    • MATLAB toolboxes
    • Simulink
    • Compiling code for Arduino

2:30 - 2:45 pm: Break

2:45 - 4:30 pm: Scripting. Introduce students to various forms of scripting, and PowerShell in particular.

  • Shell Scripting: Expose students to scripting applications.
    • What is a shell?
    • MATLAB shell
    • Bash shell
    • PowerShell
    • Other shells
  • Introducing PowerShell: Exploring the PowerShell console, and how it can be customized
    • Brief history of PowerShell
    • Modifying window size and title
    • Setting colors, fonts, and text size
    • Quick edit mode
  • PowerShell Basics: Getting started with PowerShell Scripting
    • Cmdlets
    • Parameters
    • Command Types
    • Command Information
    • Variables
  • Data Handling within PowerShell: Managing the flow of data from within PowerShell scripts
    • Generating output
    • File manipulation
    • Integrating with WMI and .NET (very brief!)
  • Applying PowerShell: Example of using PowerShell to automate data entry and analysis
    • Example problem
    • Data entry
    • Data analysis
    • Launching PowerShell from within MATLAB (!powershell)
    • Launching MATLAB from PowerShell

Day 2

8:30 - 10:30 am: Version Control. Introduce students to version control

  • Version Control: Why it is a good idea, and various means of implementation.
    • Benefits of version control
    • Means of implementing version control
    • Opportunities for collaboration
    • Why we teach Git
  • Git: How Git is structured, and how it works in a Windows environment. (Again, a greater emphasis on the physical implementation of a Git repo than is provided in the standard SWC curriculum.)
    • Brief history of Git
    • Structure of a Git repository
    • Initializing a Git repo
    • Adding files to be committed
    • Committing files to repo
    • Comparing committed files
    • Exploring repo history
    • Git tools in a Windows environment

10:30 - 10:45 am: Break

10:45 - 12:00 noon: Introduction to GitHub. How to collaborate using the GitHub interface.

  • GitHub: Using the GitHub interface.
    • Relationship between Git and GitHub
    • Establishing a remote repository
    • Cloning an existing repo
    • Merging repos and resolving conflicts
    • Standard GitHub practices and terminology
    • Using GitHub to share electrical schematics and 3D models

12:00 - 1:00 pm: Lunch

1:00 - 2:30 pm: MATLAB Visualization. Expose students to various means for charting and plotting data within MATLAB.

  • Standard Plots: Built-in plotting functions.
    • Data formats (csv, txt, xls, etc.)
    • Line Charts (plot)
    • Programmatic vs. interactive analysis (finding peaks, frequency, etc.)
    • Barcharts, histograms, and color maps
  • Plot Appearance: Modifying plots.
    • Linetypes and data markers
    • Overlaying plots
    • Data range
    • Chart text and legends

2:30 - 2:45 pm: Break

2:45 - 4:15 pm: Debugging and Testing. Introduce students to testing and debugging.

  • Program Status: Using print commands to show program status and query program variables.
    • Printing values to screen
    • Mixing strings and numerical values
    • Formatting numerical values
    • Waiting for user input
  • Debugging: Expose students to debugging methods within MATLAB.
    • Timing function duration (tic and toc)
    • Profiling program execution (profile on, profile off)
    • Entering and exiting the MATLAB debugger
    • Stepping through a program
    • Setting breakpoints
    • Good debugging practices
  • Unit Testing: Expose students to the concept of unit testing.
    • Purpose of unit testing
    • History of unit testing
    • Test-driven development
  • Unit Testing in MATLAB: Explain how unit testing is implemented within MATLAB.
    • Cloning a unit test class within MATLAB
    • Defining class to carry out unit tests
    • Writing test functions
    • Asserting returned values (hard failure using assertEqual, assertSize, etc.)
    • Verifying returned values (soft failure using verifyEqual, verifySize, etc.)
    • Executing tests using the run method
    • Setting up and tearing down test fixtures
    • Selecting which tests to run
    • Merging unit tests into test suites

4:15 - 4:30 pm: Concluding Remarks. Summarize important points from workshop and gather participant feedback.

BOOTCAMPS · ENGINEERING · MATLAB · POWERSHELL

Dialogue & Discussion

You can review our commenting policy here.