Sledgeworx has completed our first Getting into Software interview with Craig Freeman. We discuss how Craig got into software, his career and the pros and cons of being a software engineer.
Sledgeworx has completed our first Getting into Software interview with Craig Freeman. We discuss how Craig got into software, his career and the pros and cons of being a software engineer.
I have been reading ‘Software Estimation’ by Steve McConnell which is about estimating software projects. I got interested in the subject a few months ago, because my interns were asking questions about how to estimate stories in Agile ceremonies. The company I work at does not have any estimating theory. Its a shoot from the hip, ‘wild ass guess’ environment. I didn’t really have a good answer for the interns.
A couple surprises are that research has shown software engineers typically underestimate tasks to the tune of about 30% of the actual time and that the range of estimation accuracy is around 1.2-16x.
Sledgeworx is happy to announce the release of the Code Review Handbook. The Code Review Handbook contains everything I know about Pull request reviews and reviewing code.
I do most of my work in the Go ecosystem and rely heavily on the go fmt
tool to maintain style consistency across the team. But the javascript language does not have a formatter built in so we have been relying on jslint to enforce consistent styles. I found a auto-formatter for javascript prettier, which could make frontend formatting much easier you can find it at https://prettier.io. Prettier supports JSX which is key for us since we work on a single page application with a react.js frontend. I have added prettier to my crypto-exchange application https://github.com/Sevii/pepper-exchange to evaluate how well it works.
I dislike using linters to address code formatting and style questions because they basically nag developers into formatting things correctly. Code formatting is low value work, I would much rather have a machine do it in 250ms than have a developer spend 60 seconds addressing linter issues.
Prettier should let us eliminate formatting nagware, and limit our use of jslint to semantic and correctness issues.
You can use prettier as follows.
yarn add prettier --dev --exact # or globally yarn global add prettier
prettier --write "src/**/*.js" # This command will format any .js files in your src folder.
A common problem when reviewing pull requests is large diffs of formatting changes. You end up with pages of formatting changes that people waste time looking at when in reality it was just a 3 line PR. Go has a tool called fmt which can format any Go code into the standard Go format. What happens in my project is that some of the team has their IDE configured to automatically run go fmt
when they save a file, while the rest do not. So our codebase is in an inconsistently formatted state. What I am attempting to do is to setup a git-hook that will run go fmt before any commits.
The .git/hooks directory contains samples of git hooks that can be triggered on various git actions like pre-commit, post-commit, post-receive, etc. The files need to be executable, with no extension and named after the appropriate hook. This digital ocean link has a table of the available hooks if you scroll down a bit https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks#basic-idea-with-git-hooks.
The hooks are just executable files and it may be possible to run compiled binaries as well as shell scripts. Here is my working go fmt pre-commit hook. I edited the example script in .git/hooks/pre-commit.sample
to run go fmt
and renamed it to pre-commit
.
#!/bin/sh # # A hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # This hook runs 'go fmt ./...' on the project # To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # If you want to allow non-ASCII filenames set this variable to true. allownonascii=$(git config --bool hooks.allownonascii) # Redirect output to stderr. exec 1>&2 echo "Running go fmt" go fmt -x ./...
Here are some further references.
An Example Git-Enforced Policy
Pre-Commit NPM based git-hook installer https://github.com/observing/pre-commit
Githooks
https://githooks.com