Wednesday, December 9, 2020

WFH 2.0

As part of the human specie living the events of the 2020 year,  you are probably very familiar with the top one cliche phrase of the year: "the new normal". This phrase is used to describe what apparently has become our continuous present, implying that there was an "old normal", and we need to accept the new reality. The phrase has a resignation emotional charge, a certain early nostalgia for what in appearance had been lost forever. Nothing is going to be the same... This of course it totally debatable, but I think most of us already consider that sooner or later we will start enjoying those precious things that this virus put on hold. In any case, I do think there are new normal things that came to our lives to stay, probably forever. One of them is what I call the WFH 2.0 (Working From Home 2.0).

 WFH is nothing revolutionary. If you are reading this, there is high chance that you were already enjoying certain level of this benefit that your workplace grants you. Maybe one day, maybe a couple, some were only required to go one day to the office, and some others were 100% from home. We know not all companies can afford this benefit, but for those that can, you could say that the amount of days given to work from home is somehow correlated with the level of trust the company has of its employees. The higher the flexibility to WFH, the higher the maturity a company has in its processes to keep things aligned with the vision, culture, quality, client satisfaction, etc.

Then COVID-19 came and suddenly many companies started to realized that perhaps office space is not a guarantee for work performance. During this pandemic almost every IT company was forced to a POC (Proof Of Concept) to let all employees work remotely for months. And surprise, surprise, nothing really has collapsed (AFAIK). This realization is starting to have great consequences (depending of your point of view). Many high profile companies like Microsoft has already announced measures to let employees work from home permanently And this is not a luxury only big companies can do. All size companies are considering the same. And why not? There is a win-win situation. Employees appreciate not rushing into traffic, spending more time with family, better balance with work and personal life. You name it. Companies in the other hand saves in office space, amenities, water, electricity and whatever other spend that was included to attract high talent.

But if fully remote is going to become the new normal, how can companies spend the money and efforts to create a better "virtual space" to work? I want to give five of my ideas in case it helps a few HR people. Feel free to comment if I'm going too nuts (I'm just a Software Developer with no studies in HR so take it with a grain of salt). 

Entrance bonus for home office improvements. Most of us will start requiring continuous improvements in our work space to make it a better spot. A place where you feel more productive and motivated to give your best. Why not a reimbursement to spend it in a better chair, desktop, extra monitors, keyboard, mouse, even decorations. Sky is the limit...



Team activities that YOU DON'T WANT TO MISS. Yeah, every company organizes team activities like the classics bowling, Go Karts, mini golf, etc. Before these were kind of optional, and let's be honest, who hasn't assisted to one of these just for the sake of not being the "party pooper", or even making excuses because you felt it was not worth to sacrifice family time or other activity for something you really won't enjoy. Having mandatory office days still provided the human in person contact you still need on some basis to keep the team spirit flowing. But now without them, these team activities become more important. Thus, let's make them cooler so people really want to participate. 



More Interactive Corporate Meetings. On the same line of team activities, if the company has recurrent corporate meeting every, like All Hands (or however is called in your workplace), let's please spend less time on executive reports, and leave more room for interacting/partying. A lot of employees really don't have a lot of time due to other responsibilities (mostly family), which often translates in not staying in the post executive reports parties. Yeah, yeah, we know it's important to know the status of the company, but I believe we can make them a little more executive summary.


Perks to release the stress. Free lunch was an ideal perk for anyone going to an office. It released you from the burden of preparing your lunch and warm it on the microwave. Now full remote opens a range of perks that employees can enjoy thinking in releasing the stress of being a little more isolated, and taking advantage of the additional time you get by not commuting, looking for appropriate attire, *cough* not showering *cough*. So how about paying gym, salsa classes, swimming lessons, anything that requires people to leave the house and put the body in motion.



  

Go crazy with the goodies! And with crazy I mean smart, creative and fun. Perhaps your company's t-shirt is a little old and needs a renew. A new edition of stickers to put on your laptop. Caps with a cool logo. Anything that is not a waste enters in this category. This may seem like a silly thing, but without being present physically in office space, little reminders of company's identity can help sustain the culture and pride to work in a place that became virtual.



What else would you suggest????

Thursday, November 12, 2020

Java: Solving Anagrams with streams

I have been playing with code problems. Since I'm studying for Java 11 certification, I decided to resolve the Anagrams problem using streams. Here what I do is sort the two strings characters and then making a comparison.


public class Anagrams {
    static boolean isAnagram(String a, String b) {
        return sortStringChars(a).equals(sortStringChars(b));
    }

    static String sortStringChars(String str) {
        return str.toLowerCase().chars()
            .mapToObj(c -> (char) c)
            .sorted()
            .reduce("", (s,c) -> s.concat(String.valueOf(c)), String::concat);
    }

    public static void main(String[] args) {
        String a = "anagram";
        String b = "margana";

        boolean ret = isAnagram(a, b);
        System.out.println( (ret) ? "Yes, Anagrams!" : "Not Anagrams" );
    }
}

Thursday, October 22, 2020

Gradle: Exclude SpringBoot Application Class from Jacoco Coverage

 

Jacoco plugin is a must if you care about not just writing random unit tests, but to ensure you have the right coverage for your code base. The plugin also comes with a report that shows the coverage at package level.

One thing that has been bothering me with SpringBoot apps I work with is the low number that always appears for the main SpringBoot Application class. This is a boiler plate class with a simple main method to launch the SpringApplication:

@SpringBootApplication
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

Almost in every application we won't need to add any other additional logic to this method which makes it kind of dumb to create a test just to cover this class and main method. Best thing is to exclude it from our coverage using this format (in this case for Gradle):

jacocoTestReport {

    afterEvaluate {
        classDirectories.from = files(classDirectories.files.collect {
            fileTree(dir: it, exclude: 'com/mycom/shoppingcart/ServiceShoppingCartApplication.class')
        })
    }
}

Thursday, April 2, 2020

Spring REST Controller: Resolve conflicts between root controllers endpoints and swagger-ui.html


Our team had some issues setting up swagger. We've been adding swagger to multiple services and for a strange reason, one service was not loading the swagger-ui.html. After some testing, we realize there was a conflict with some endpoint that were mapping to the root of the site:

@RestController
public class ReportController {
    
    @RequestMapping(method = RequestMethod.GET, value = "/{reportId}")
    public ResponseEntity getReport(@PathVariable String reportId) {
        ....
    }
}

As we can see, since controller class has no request mapping, and endpoint method is mapping with /{some_id}, when we try to hit /swagger-ui.html, the request is mapped to this method.

After googling a lot, we ended up just making our request mapping more specific to a certain type of ids. In our case we are using mongo ids for the reports. It means ids can only have number or letters in lowercase.


@RestController
public class ReportController {
    
    @RequestMapping(method = RequestMethod.GET, value = "/{reportId:^[0-9a-f]+$}")
    public ResponseEntity getReport(@PathVariable String reportId) {
        ....
    }
}

Now because swagger-ui.html contains a dot (.) and a dash (-), the request is not being caught by this endpoint anymore.