3 February 2017
In this lecture, I am going to run through what you are expected to do during the implementation phase of the project. Here are the steps:
The implementation phase of your project is not just about writing code that runs correctly. It is also about communicating with other developers using source code, comments, commit messages, API documentation etc. Getting the code to compile and run correctly is just a small part of the process. Take time to communicate properly.
Your reputation as a software engineer depends on the quality of your code. Think of your github account as your resume.
This is a good time to review your CS2103’s Handouts/Slides on Good Code, Bad Code.
Some properties of good code includes:
Check out Page 1-2 of the Clean Code Cheat Sheet for the dos and don’ts for writing clean code.
Advices:
You can learn to write good, clean, code by:
A linting tool performs static analysis on your code to check for style inconsistency, ensure good and professional coding habits, and identify potential bugs. Think of it as a computer-assisted code review.
Your favorite language should have a linting tool. For instance,
Most of these tools allow configuration of rules – what do you want to, or do not want to, detect.
Your team should also adopt a consistent coding style. You can find existing tools that indent/format your code. To ensure consistent coding style, use a beaufitier, which can automatically reindent and reformat your code following a given configuration (e.g., use spaces or tab, how much to indent, etc.)
The following might be useful:
js-beautify
jalopy
is for Javaphp-cs-fixer
fixes coding style for PHP, while php-formatter
formats the code.Android Studio comes with built-in indenter, but I find them less configurable than CLI tools in general.
Don’t underestimate the importance of indentation (see Apple’s goto fail bug)
You should:
git app -p
or use a GUI)*.class
) nor external libraries (e.g., node_modules
) into your repository.Your team should establish a git repo convention. Normally, you would want to have a master
branch that contains only approved (has been code-reviewed) and stable code. Development should occur on feature branches, which is merged into the master
after issuing a pull request and had that request reviewed.
Atlassian has a nice article on such feature branch workflow.
master
branch.Why is code review important?
Best practices of code review by SmartBear
Integrate your code with the rest and test as soon as you push. This allows:
Commit often, push often (to the main branch)
Vagrant is a really cool and simple way of creating a virtual development environment. It allows a developer to easily setup and teardown an environment when switching between different projects, ensures different developers on the same team work on the same environment (even if they run different OSes), and simulate deployment environment locally.
You can choose from a large catalogue of boxes, which are basically pre-configured virtual development environments.