Week 4

7 minute read

This week we have some git scenarios and some advice on team organization. #SaveDenise

W4.X git, github and IntelliJ IDEA

Over the past years, I have witnessed some git snafus that can be avoided with proper practice. Nevertheless, fixing them is a good exercise in git usage.

The following are scenarios that may or may not have been slightly exaggerated.

Make like a tree and leave [★☆☆]

Adam fires up his IDE and begins work. After a hardcore 18-hour coding marathon he commits all of his 10k LoC commit.

Adam tries to push his code to the team repository and to his chagrin, the commit was rejected. “What do you mean? master a protected branch!?”

  • What is a protected branch? Discuss the limitations and potential benefits of branch protection on github.
  • What can Adam do to fix this?

Layer by layer [★☆☆]

Adam creates a PR on the team repository and awaits 2 other group members’ review and approval before his code gets merged. Beth starts a PR review and comments that a commit that affects 10k LoC is inappropriate and should be broken down into smaller commits.

Unfortunately Adam only knows Java, not git. He clones the team repository’s master branch into another directory and begins the arduous process of copying his code over bit by bit, this time commiting his changes every now and then.

  • How small should a commit actually be?
  • Discuss the merits of having concise commits.
  • Suggest an alternative method to decompose a large commit into smaller commits.
After answering the above: What is the difference between `git reset` modes and think of possible scenarios where each of them would be the most appropriate.

Completeness under incompleteness [★★☆]

Beth and Calvin are working on two dependent features. Beth requires some code from Calvin’s branch but Calvin requires urgent hospitalization after reviewing Adam’s PR.

CUI

  • What can Beth do to arrive at the git commit tree as shown?
  • What could have happened if Calvin is still around?
    • Discuss within your team on some protocol for handling situations like these.

Rose by any other [★★☆]

Adam lives in a penthouse with 7 different computers, one for each day of the week. Somehow, the grading bot is only picking up on his latest commit.

Adam posts the following git log output into his team chat.

d5ac9da 2020-09-14T16:28:33+08:00 Adam      Add tests
ce79e70 2020-09-12T12:28:49+08:00 The Big A Modify AddressBook to donate money everytime it crashes
a20e9cd 2020-09-11T23:28:12+08:00 The Big A Update User Guide
e99c323 2020-09-02T22:11:03+08:00 The Big A Add Gradle task to generate revenue
076c595 2020-08-31T16:28:19+08:00 The Big A Remove appendix of patient

“Hmmm, looks like you provided ‘Adam’ in the pre-module survey and that’s what the bot looks out for”, Calvin replied.

Adam starts to have flashbacks of the time he manually broke down his 10k LoC commit.

  • What can Adam do to fix this issue?

Welcome to the moshpit [???]

Adam, Beth and Calvin are celebrating the submission of their project when Denise pops up in the team chat and said “heyyyy guys i added my name and stuff!”

Wait. Who’s Denise and where has she been all semester? What has she done?

The commit count on the team repository has decreased a significant amount, setting off alarms all across the world. Calvin pulls the code and runs git log:

be5a77f3 2020-11-08T23:18:00+08:00 denisedadawg stuffs :))
b3c73c74 2020-08-01T23:04:50+08:00 AB-3 Team    Add integration with CodeCov
86f65cc7 2020-07-29T00:45:28+08:00 AB-3 Team    Add tutorial about adding a new command
4eafb67e 2020-07-28T15:23:07+08:00 AB-3 Team    docs/DevOps.md: Document repo-wide checks
81e0ef29 2020-07-23T01:17:54+08:00 AB-3 Team    Set <title> in documentation pages (#45)

Oh no no.

All the tests are failing, the Java code does not even compile.

A quick look into some of the Java files quickly reveals what when wrong. Some of the existing code has been commented away and replaced with Denise’s code.

//Excerpt from ConcreteAddressBookParserFactoryBeanResolverStrategyManager.java
/**
<<<<<<< HEAD
public Command parseCoolCommand(String userInput) throws ParseException {
        final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
        if (!matcher.matches()) {
            UiContextManagerDelegateDecorator.showSuperCoolHelpBox()
        }

        final String commandWord = matcher.group("commandWord");
        final String arguments = matcher.group("arguments");
        switch (commandWord) {

        case AddCommand.COMMAND_WORD:
            return new AddCommandParser().parse(arguments);
=======
public Command parseCommand(String userInput) throws ParseException {
        final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
        if (!matcher.matches()) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
        }

        final String commandWord = matcher.group("commandWord");
        final String arguments = matcher.group("arguments");
        switch (commandWord) {

        case AddCommand.COMMAND_WORD:
            return new AddCommandParser().parse(arguments);
>>>>>>> be5a77f39c87cba7395f6a30e162e4647aa8a45a
**/
public Command parseCommand(String userInput) throws ParseException {
        final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
        if (!matcher.matches()) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
        }

        final String commandWord = matcher.group("commandWord");
        final String arguments = matcher.group("arguments");
        switch (commandWord) {

        case AddCommand.COMMAND_WORD:
            return new AddCommandParser().parse(arguments);

The final submission date is 40 minutes away?!

  • What do you think has happened here?
After answering the above: When asked what happened, Denise replied with a nonchalant: "i follow some StackOverflow(r)(tm)(c) things because the push keep fail lol. i delete the .git thing also cannot. i turn off the protection cannot then i go copy paste something until it worked. dont angry plsss i trying my best :))))"

The deserving [☆☆☆]

Adam delegates the tasks. Beth will write the angry email to the professor while Calvin restores the repository to a pre-Denise state. Adam proceeds to work on his best impression of Liam Nelson’s monologue in Taken.

  • Restore the repository and save their grades.
  • Adam has a very particular set of skills, skills he has acquired over a very long semester.
  • If you revert the repository now, that’ll be the end of it. Adam will not look for you, Adam will not pursue you.

And the damned [★★★★★]

Calvin’s heart melts after reading Denise’s mea culpa of “dont angry plsss i trying my best :))))” and initiates a forceful takeover of Denise’s computer. Denise’s IntelliJ is still open!

  • Devise an action plan to rescue as much of Denise’s work as possible in 40 minutes.
    • What do you start looking for?
    • What parts of Denise work do you focus on to maximize her grade?

Habits of highly successful teams

Did you manage to save Denise?

Students have asked me what’s the best way make the most out of their projects. I have noticed that teams that do well usually exhibit certain qualities.

Self-introductions are important

Get to know your teammates really well. Play to your teams’ strengths and weaknesses. There’s something that you can learn from your teammates and vice-versa.

Set expectations for the module! Grades aside, what do you really want to make of this module?

Establish an avenue of contact

Have a team chat and make an effort to be responsive. There is no meaning in having a team chat that is empty/dominated by a few people.

Use the team chat as your go-to when you run into any issues. If you see an issue, jump in and help out! Five heads are better than one.

Code can’t compile? Team chat.

Tutor too mean? Team chat.

Not sure what design pattern to use? Team chat.

You get the drift. A team that commiserates together, learns together.

Announce intentions

Before starting work, announce to the team the feature that you’re working on. If you are waiting on people to finish their work before they can finish yours (aka a blocker), you need to let those responsible know.

Take the helm (occasionally)

Don’t be afraid to take charge and delegate tasks. There is no need for a team leader but everyone in the team should feel comfortable stepping in when a situation goes south.

Habits and practices

Meetings

Figure out a meeting date and stick to it. Having a meeting every week ensures that work gets done every semester.

  1. Check on the progress of the past week.
    • Who has done what?
    • If tasks are incomplete, why?
      • Reevaluate the difficulty of the task at hand.
      • Commit to finishing the task this week.
  2. Resolve outstanding issues.
    • Insufficient manpower on tasks?
    • Lack of knowledge to proceed?
  3. Figure what out what needs to be done for this week.

Proper git hygiene

The broken windows theory applies in spades. Everyone needs to commit to having proper git habits all the way.

Having concise and well-documented commits allows the entire team to navigate the codebase efficiently. Remember that people read code more than they write!

Proper github hygiene

Lock your master branch to prevent an accidental Denise. It has happened before, it can happen again.

There are options that can prevent a single person from forcing a PR through. Use it to ensure that extra eyes pass over each commit. If you’re not free to review the commit, don’t give the greenlight for the sake of pushing the commit through.

Remember, a stitch in time saves nine.