Code Convention and version control help us to success in Botball

Similar documents
CSE 142/143 Unofficial Style Guide

Introduction to Programming Style

EECS 280 C++ Coding Standards

KEEP CALM KERN AND. Some of the do s and don ts of Typography by Fran Pimblett

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Working with JavaScript

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

Learning to Program with Haiku

CS 251 Intermediate Programming Coding Standards

CSE 11 Style Guidelines

CS 351 Design of Large Programs Coding Standards

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine

Scheme of work Cambridge International AS & A Level Computing (9691)

Perl Basics. Structure, Style, and Documentation

Activity Guide - Will it Crash?

Programming in ROBOTC ROBOTC Rules

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

Coding Style Handout #15 February 1, CS106A Winter

Variables and Functions. ROBOTC Software

User Interface Programming OOP/Java Primer. Step 3 - documentation

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

Documentation Requirements Computer Science 2334 Spring 2016

C++ Programming Style Guide

CS106A, Stanford Handout #30. Coding Style

Language Proposal: Mandala

11 Coding Standards CERTIFICATION OBJECTIVES. Use Sun Java Coding Standards

Chapter 2: Programming Concepts

You Can t Move Forward Unless You Can Roll Back. By: Michael Black

Eclipse Plugin Tool for Learning Programming Style of Java

Overview. Introduction to Embedded Systems. What is an embedded system? What are some of their characteristics? What is the required skill set?

Database Programming with PL/SQL

The Power of Unit Testing and it s impact on your business. Ashish Kumar Vice President, Engineering

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

Java Programming Style Guide


6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

Coding Standard for ECE3090 August 24, 2005

Construction: High quality code for programming in the large

PROGRAMMING STYLE. Fundamentals of Computer Science I

CS112 Lecture: Working with Numbers

HTML/CSS Lesson Plans

SNS COLLEGE OF ENGINEERING,

Software Design and Analysis for Engineers

CS112 Lecture: Extending Classes and Defining Methods

Learning to Program with Haiku

Social Share for Magento 2. User Guide

Shut the Box. By the time you are done with this activity, you and your team should be able to:

Example: Fibonacci Numbers

Objectives. Coding Standards. Why coding standards? Elements of Java Style. Understand motivation for coding standards

Data Structures Lecture 2 : Part 1: Programming Methodologies Part 2: Memory Management

Coding Standards for C

CIT 590 Homework 5 HTML Resumes

CS 177 Recitation. Week 1 Intro to Java

Coding Standards for C

Public Meeting Agenda Formatting Best Practices

Introduction to C. CS2023 Winter 2004

Guidelines for Coding of SAS Programs Thomas J. Winn, Jr. Texas State Auditor s Office

The compiler is spewing error messages.

FAQ: Advanced Functions

Software Implementation (Writing Quality Code)

Chapter 2 Author Notes

Page 1. Logistics. Introduction to Embedded Systems. Last Time. ES Software Design. Labs start Wed CS/ECE 6780/5780. Al Davis

This assignment requires that you complete the following tasks (in no particular order).

Kebot: Robot Simulator

Readers are wary of out of date content, so it's important to actively manage the information you publish.

Programming in the Real World. Dr. Baldassano Yu s Elite Education

Object Visibility: Making the Necessary Connections

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

CS112 Lecture: Defining Instantiable Classes

We re working full time this summer alongside 3 UCOSP (project course) students (2 from Waterloo: Mark Rada & Su Zhang, 1 from UofT: Angelo Maralit)

CSCI 2101 Java Style Guide

G. Tardiani RoboCup Rescue. EV3 Workshop Part 1 Introduction to RobotC

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

CSCI 305 Concepts of Programming Languages. Programming Lab 1

Documentation and examples of sectioner.py 1.0 boxerer.py 1.0 and miarticle.cls

UNIT II Requirements Analysis and Specification & Software Design

CS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June

Microservices Smaller is Better? Eberhard Wolff Freelance consultant & trainer

102. Introduction to Java Programming

MATLAB provides several built-in statements that allow for conditional behavior if/elseif/else switch menu

Unit 1: Guess and Check: A Decoding Strategy

Happy Birthday, Ajax4jsf! A Progress Report

Guidelines & Instructions for Manuscript Preparation

CMSC 201 Fall 2018 Python Coding Standards

REPORT MICROSOFT PATTERNS AND PRACTICES

Course Coding Standards

Control Structures in Java if-else and switch

SML Style Guide. Last Revised: 31st August 2011

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar

FPLLL. Contributing. Martin R. Albrecht 2017/07/06

Annotation Annotation or block comments Provide high-level description and documentation of section of code More detail than simple comments

Programming Style. Quick Look. Features of an Effective Style. Naming Conventions

Software Design. Levels in Design Process. Design Methodologies. Levels..

Creating SQL Tables and using Data Types

Programming Preset Heights in ROBOTC for VEX Robotics By George Gillard

Coding conventions and C++-style

Commits and Commit Messages

Shorthand for values: variables

Programmer s Style Guide

Transcription:

Code Convention and version control help us to success in Botball Zebu Lan USTB Robot Society Team 1 Code Convention and version control help us to success in Botball 1 Introduction Clean and well-structured code boosts the collaboration of a team. As we all know, team work is the most common and effective way to achieve an objective. In the Botball project, the robot programming work is commonly a team work. Writing clean and well-structured code and posing proper and essential comments help prevent the potential bugs that might occur in the program and testing stage. Well-structured code helps other people to quickly understand the code as well, which also help to debug. Although messy codes do not absolutely equal to more bugs and long debugging time, clean and well-structured code provided a good foundation for subsequent program optimization. Based on clean and well-structured code, the maintenance cost can be reduced dramatically. Robot design is a process where robot mechanisms and structures would be adjusted or even rebuilt frequently. In this process, the computer program has to follow the changes as well. If the code is not under a clean and well-structured situation, the changing, code refactoring and corresponding test work will become a nightmare for everyone. 2 Code convention our team follows A set of clear and simple code conventions can help a team to reduce most of the misunderstanding when team members are working together, and help to increase the maintainability and reliability of the code which is essential to the success in Botball. We simply list 5 rules need to be followed, which can prevent most of the common errors from happening. 2.1 Naming Naming is critical to a program. A reasonable naming convention can help us to save the time which is spent on understanding the logic of the program. It can also effectively help us to make changes to the code. For example, the small top-hat sensors were used in our robot to track the black lines. In our program, the variable which is the left sensor is named LeftSensorValue and right sensor is named RightSensorValue. Code blocks with good naming and bad naming are shown in Fig 2-1 and Fig 2-2. Although the code block in Fig 2-2 looks longer than the corresponding one in Fig 2-1, but it reduces most of the magic values which makes the code more understandable.

Fig 2-1 Code without good naming Fig 2-2 Code with good naming In this way, people can clearly understand the meaning of the function and the debug process becomes relatively easier. Moreover, when there is any change of the hardware happening, i.e. the motor port is changed, programmers don t need to go through the whole program to change the port value, but only need to change a constant value, which helps to increase the maintainability of the code. 2.2 Indent In order to improve the readability of the code, we have an indent convention in our team. Please refer to Fig 2-3 as an example. It is quite clear that the code in this program has a good indent style. Code in main function and while loop indent to different level, marked with a pair of curly braces. In this way, people can easily understand under which code block a statement is, which helps our team member to read the code especially when there is nesting loops in our code.

Fig 2-3 Code with good indent style 2.3 Case In our program we have a lot of different symbols, i.e. local variables, global variable, functions, constant values. To easily distinguish them from each other, we designed the following case convention in our team. Please refer to Table 2-1 for the detail. Item Case Local variable First word in lowercase, other words first letter capitalized Global variable First letter capitalized Function Lowercase words connected by underlines Constant value Capitalized words connected by underlines Table 2-1 Case convention Below are some examples from our code: Local variable: counter Constant value: LEFT_MOTOR_PORT Function: drive_turn() By strictly follow the above rules, our programs are easier to read.

2.4 Function When you find there are some pieces of code appear more than one time in your code, it indicates that you may need to encapsulate those code into a function. Using functions can make the code more reusable and easy to maintain. When we use functions, we separate the declaration and the implementation of the function into two parts. The declarations of functions are placed before the main() function, while the implementations are put behind the main function. Fig 2-4 is an example of our function. Fig 2-4 Example of user function This program is used to make the car go as a square route, where the function drive forward was used only one time, however it may be used many times in other tasks. For this problem, using encapsulation can solve it perfectly. The design method is to subdivide the system functions into simple functional module, so that function statements generally are no more than fifty lines. From this program we can draw a conclusion that we should use modularization to encapsulate the function module as general functions where declarations are put in the file header and the implementation codes are put behind the main function, if it will be called more than two times. 2.5 Comments Comments are useful when sharing work with teammate, and it also remind the programmer himself how code is originally designed to work. We normally put a short sentence at the beginning of a program to indicate the function of this program.

And comments are placed at main statements, i.e. loop statements, conditional statements. Fig 2-5 is an example of the comments we add to our code. 2.6 Version Control Fig 2-5 Example code of comments Although version control which refers to more sophisticated technologies and methodologies is normally not a code convention issue, we have our own simple but effective version control method in our team, which helped us to well manage our code during several months Botball season. As the program in a Botball team is relatively simply, and the team is a small team compared with most software companies. We found it is not necessary to use CVS, SVN or Git to manage our code. Instead, we follow a naming convention of the C program files, to make the version management work easy to apply. Our programs are named as the following style: Function_Author_Date_Version.c. For example, we meet up on 16 th May and wrote a program to control the robot to walk up the slope and sweep the balls, we had 3 major updates and several minor updates during the day. The file name will be Walk_Sweep_Zebu_5_16_V3.1.c. In this manner we achieved well management of our code.

3 Conclusion Follow several simple rules and write clear and consistent code is essential to Botball teams. It can help our team to really work in an engineer s way, which is the most meaningful experience we got during the whole process. No matter what programming language we use and how sophisticated our future task will be, following a proper designed code convention will largely facilitate team work and make the code maintainable and reliable.