Sara

I have been coding mainly front-end in React and Redux. And there is so much more than stupid javascript as we see in school. Since the project has had more than one bug due to rendering in the wrong order, I have been looking for video's and tutorials. This one is very visual and easy to understand.

Sara

Context :

With my team I am developing a feature that can calculate weekly, monthly, yearly reports. After pulling the develop-branch on my computer, multiple tests went haywire. Tests for weekly reports had been added and those failed on my computer because of week numbers. After checking with all colleagues (Mac-users) and the Jenkins jobs that run all tests after commit (running on Unix) it seemed my Windows was the only one with failing tests.

So lets look at one of the failing tests :

        assertThat(row16.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2017-52");
        assertThat(row16.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);
        assertThat(row17.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2017-53");
        assertThat(row17.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(1.0);
        assertThat(row18.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2018-1");
        assertThat(row18.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(6.0);
        assertThat(row19.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2018-2");
        assertThat(row19.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);

Result :

        org.junit.ComparisonFailure: 
        Expected :"2017-53"
        Actual   :"2018-1"

What was happening :

Different countries have different time/date standards :

  • The calendar that is used.
  • The order in which the year, month and day are represented.
  • How weeks are identified (see seven-day week)
  • Whether written months are identified by name, by number (1–12), or by Roman numeral (I-XII).
  • Whether the 24-hour clock, 12-hour clock or 6-hour clock is used.
  • The punctuation used to separate elements in all-numeric dates and times.
  • Which days are considered the weekend.

My machine was using the settings from Great Britain, and my colleagues were using different settings. Meaning our week starts on different days(Sunday / Monday) and our year had a different amount of weeks due to this. My year only had 52 weeks. Their years consisted of an additional incomplete week with the last/first days of the year.

Iso standards : Wikipedia can give you a very dry explanation of how it all works, but just trying a few 31/12/YYYY on an ISO conform time converter can show you how it works.

If the week contains 4 or more days in year X, the week is in year X.Image description

Image description

How we fixed it :

Since we work for an international company we will have to implement a standard, and communicate this to all that use our API. We chose to use the settings from Great Britain, meaning that 2017 only has 52 weeks. Weeks should have 7 days, and should start on a Monday. Fully in line with the ISO standards.

To set the locale settings on the local servers and maven we used this :

         -Duser.language=en -Duser.country=GB

The tests were adapted to test if ISO standards and GB locale is used :

        assertThat(row2.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2017-38");
        assertThat(row2.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);
        assertThat(row16.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2017-52");
        assertThat(row16.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);
        assertThat(row17.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2018-1");
        assertThat(row17.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);
        assertThat(row18.getCell(CONSOLIDATE_DATA_WEEK_COLUMN).getStringCellValue()).isEqualTo("2018-2");
        assertThat(row18.getCell(CONSOLIDATE_DATA_WEEK_COLUMN + 1).getNumericCellValue()).isEqualTo(7.0);

Tip of the day :

Because you are the only one having the bug, it's not a given that the issue is on your machine.

Because you are a minority, it does not mean you are wrong.

Sara

The name has obscure roots and doesn’t matter; the key is that it makes you think, “Why would you do that?”

Yak shaving can be: I want to make dinner, but I’m doing stairs; moving objects around in order to clear a path to put away the blender which is on the counter in the spot I need to unload the groceries. And then I’ll search through my email to find the name of the recipe so I can google it, and there in my email there will be something urgent to respond to, it’ll make me check my calendar which will remind me that I have to be somewhere tomorrow morning which means I need to tell my husband right now that I’m going to need the car, which starts a discussion. The milk is getting warm on the counter. These are all yaks: they’re not what I want to accomplish, but they are on the way to cooking dinner.Oh and then the recipe says, “Beat the egg whites until stiff” and I look up what that means. I learn that the best tools for beating egg whites are a copper bowl and a balloon whisk — do I go buy these now? Gathering and learning the proper tools is a yak shave, too.

In programming, yak shaving has a reputation as hoop-jumping or time-wasting. Sometimes it is, when I’m shopping for the perfect keyboard under shadow of a promised delivery date. Other yak shaves are key to a smooth development process: activities that save you production outages, that spare your team days of troubleshooting, that guide your users toward the happy path and make them love your app.

There’s a balance here, between making the task doable and forcing the task to be done. Between scrubbing the counters and unloading groceries on the floor. Between researching top balloon whisks, and using a plastic whisk that’s dirty from last week.

Let’s categorize these yaks. Then we can talk about when to fight them, when to avoid them, and when to lovingly shave them clean. Because some of them are worthy opponents! Some of them are distractions, and some of them have secret wisdom on their skin underneath all that hair.

Image description

Yakbreeder.com lists five varieties of domestic yak. I’ll use them to categorize the yak shaves that we might do while programming, so that we can decide which ones to skip, and how to tackle the others.

  • Black Yak, aka Attack Yak: you must defeat them to proceed.
  • Imperial Yaks, aka Yak Stack: one obstacle leads to another and another
  • Trim Yaks, aka HackHacking Yaks: these can increase your speed at many tasks
  • Royal Yaks, aka Yakkity Yaks: relationships with people help us get work done
  • Golden Yaks, the rarest of all: shave them well enough and change the way we work.

The goal is a team development flow that moves forward while getting smoother every day, more predictable and more fun.

Sara

I spend 3 full days looking for a bug during my Spring 3 to Spring 4 migration at work, and finally found the issue:

Spring 3 will autowire beans on the ClassName,Spring 4 does this on the full.package.name.ClassName.

In the controller I was calling

Image description

and in my mapper was this :

Image description

The a.b.c.Languages was an interface, and unfortnuately the implementation, x.y.z.Languages is called the same.Making it very hard to find the issue.

The full stackOverflow post

Sara

Radio Garden is, essentially, Google Earth for radio. You click and drag a 3D globe around, and zoom in on local stations around the world. Every dot represents a feed you can tune in to, and, using the options in the top left of the webpage, you can switch between live streams, historical content, jingles, and recorded interviews. Live streams are the most engaging, and in a few minutes you can browse everything from Ugandan pop to Norwegian evangelical rock to Japanese J-pop to Indian astrological advice. It’s a genuine cornucopia, with nearly 10,000 stations available to tune in to.

http://radio.garden/