Intro to Style Guides (Activity)
The Need for Style Guides
In this activity students will learn about why we need a style guide for team-based projects and compare style guides for a various projects. Based on this experience, students will develop a style guide for their team.
Knowledge of basic regular expressions is helpful to understand the checkstyle documentation.
|After successfully completing this activity, the learner should be able to:
Working by themselves on small projects convinces students that coding style his little relevance. As they begin work on HFOSS projects, they need to begin to build an appreciation for the place of a standardized coding style.
This topic is an opportunity for active debate about coding style, but is also a lesson in the need for accepting standards - even if they are not your preference.
The following activities should be completed by the student before coming to class:
- (30 minutes) This article talks about the need for a coding standard
- (30 minutes) Read about the Google Style Guide
- (optional 15 minutes) Read this article about style versus standards
- (90 minutes) Checkstyle (http://checkstyle.sourceforge.net/) is one of a number of static analysis tools that provides a measure of the health of a codebase.
- Read the ~150 items checked, and determine if each should be included or excluded from the standards for your group project. For each item included, state appropriate parameters.
Ideas for in-class activities:
- Some checkstyle items are controversial, providing an opportunity for lively debate. See items in the following categories
- Have students work in their groups to compare their assessment of the checkstyle items. Each group should develop a single style for their work.
(optional) Install checkstyle for your favorite IDE:
(optional) Add checkstyle to your build (ant, maven, etc.)
- ant: http://checkstyle.sourceforge.net/anttask.html
- maven: https://maven.apache.org/plugins/maven-checkstyle-plugin/
- gradle: https://docs.gradle.org/current/userguide/checkstyle_plugin.html
Ideas for assignments:
- A list of questions to answer as the student is reading the articles / watching the video
- A journal assignment (informal writing) where students respond to the arguments in the article / video
- Use the Google and/or Sun checkstyle files to see how well student's existing code meets the style
- Google style file: http://checkstyle.sourceforge.net/google_style.html
- Sun style file: http://checkstyle.sourceforge.net/sun_style.html
Area & Unit(s)
SE - Software Engineering
SE/Software Process, SE/Tools and Environments,
medium (because of the time required)
2.5 hours preparing plus one class session
Internet access, Java IDE
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
Suggestions for the Open Source Project:
Suggestions for an open source community member who is working in conjunction with the instructor.