我的独一无二 发表于 2016-11-30 02:17:14
By Dan Stark | @danstarkdevops
您需要 登录 才可以下载或查看，没有帐号？立即注册
At Zonoff, we have a general Slack channel “#nerds” where anyone can ask quick engineering questions. Often, the answers yield highly technical discussion. People can get very into it.
Codebattles: Competitive Coding in the Workplace
A couple months ago, I posted a relatively straightforward question about the best way to parse a blob of JSON. Before I knew it, people were writing test scripts proving that their solution was the fastest when executed 100 times. I felt like there was some magic there we could tap into. After talking it over with a few coworkers, Codebattles was born.
A quick introduction: I’m a DevOps engineer with a Master’s in counseling psychology. I don’t have a traditional engineering background, and neither do some of my co-workers. I’m jealous that I never got to participate in hackathons or coding competitions in school. Although I’ve seen them attempted in previous jobs, they typically failed to meet my expectations. I can think of a number of reasons why they fail most places and why they succeed at Zonoff:
1. Picking your battles
- Identifying a topic of wide interest can be difficult . The engineers we hire share a desire to learn and are willing to tackle just about anything.
- Lack of planning/organization . I was pretty sure I could figure this out with help from the participants.
- Waning interest . Gamification might keep people engaged.
- People feel that their voices/ideas aren’t heard . We encourage empathy and foster communication.
Codebattles are lightweight engineering competitions held monthly at Zonoff. They’re entirely self-organized. Anyone can recommend a topic, and participants collectively decide the ground rules and scoring for that battle. A good topic is short, definitively scoped, and bridges a variety of specialties. We’ve covered everything from parsing JSON to writing a small game. Some specialties don’t lend themselves to challenges as easily, but, in general, we pick topics that many developers are familiar with and excited about. It’s a lot easier to create interest for a codebattle when someone is motivated and willing to help define the topic. Part of the challenge is making sure it’s an idea open to the wide majority of the engineering team. Not everyone participates every month, and that’s natural; it doesn’t discourage the rest of us. Every idea presented gets talked out with multiple battlers to see if it’s scoped and accessible.
2. The Git down
Since we use git for version controlling our product source code, it seemed natural to use it to organize the submissions for Codebattles. Before the battle, the moderator creates a folder in the main codebattles repository for the upcoming challenge. The challenge is described in a README and placed in the folder alongside related supporting files. As this is happening, each participant clones the repository and creates their own named local branch as follows:
git clone https://<private-git>/codebattles
git checkout -b dstark
The challenges kick off when the moderator announces a push to the battles directory on the master branch. The battlers then merge it to their local working set.
git merge master dstark
When battlers arrive at their solution, they simply push to their remote.
git commit -am ‘codebattles 1 submission’
git push -u origin dstark
Battle one extended my parsing json exercise. Here is the directory structure for the first challenge after the moderator pushed the first challenge to master:
codebattles [master] % tree
│ ├── README.md
│ ├── raw_data.json
│ └── results.txt
The instructions are in README.md:
Battle One: Data parsing
You may use any language, tool, resource, etc.
Let’s say we have a hub check in multiple times during the day and we want to evaluate CPU utilization. All of the data in this example is from one hub. You’ll notice output regarding CPU load average in raw_data.json. Sort checkins descending by 1 minute CPU load average and ID so we can look it up easily.
A data set from [ElasticSearch](https://link-to-dataset) (This data is in: *raw_data.json*)
Save to a file ‘results.json’ desc list of “LoadAvg (1 minute), _id” sort by LoadAvg.
## Example result of ‘results.txt’
0.15, 12345678912345678912345678912345678912345678912345678907.0 “`
Please share your solution – if you have any code leave it in this directory so others can see how you derived your answer
3. Quit playing games with my code
Like many side projects, it’s easy to start with burning fury only to fizzle out weeks later. To combat this, we incorporate a reward system where battlers can score points across multiple battles. As this is a friendly competition, the points aren’t the point of the challenge. We’re all competitive people; it’s natural for us to be measuring our skills against each other. But we didn’t want this to be a chest-thumping, king-of-the-jungle competition. We wanted it to be fun, so we built in gamification. A point system that runs across multiple challenges encourages people to build their skills in other areas and see whom they can learn from over time. At the end of the season, the engineer with the most points takes home the coveted Golden Keyboard trophy.
4. “Just hear me out, what if we all build a compiler”
When we first began Codebattles, a funny thing happened. We had a huge influx of ideas, from engineers, managers, marketing, and more. I believe my role as organizer is twofold:
Having someone expand on their idea builds excitement and makes them feel ownership, and I support them to see it through if they’re passionate. Ideas are most powerful when they can be driven from dev to production, and I treat Codebattles the same way.
- Make sure everyone feels heard , that I’m not dismissive of their ideas (I genuinely am not); and
- Ask open-ended questions about their idea. How would it be judged? How would a UI developer react to this challenge? What would be the benefit to the engineering team if we choose this?
Codebattles: Competitive Coding in the Workplace
One of the reasons I came to work at Zonoff a year ago was the diverse engineering backgrounds of the people here. Codebattles are a way to leverage the entrepreneurial spirit we all share and learn from our peers. And while I know I’d lose writing C++ code, I’ll happily throw down against anyone in sed/grep/awk one-liners!
上一篇：SiFive open sources RISC-V chips
下一篇：Downloading files from web using Python