Tuesday, February 21, 2017

The weight of decisions – moral machine

At some point, if you're developing some system, you will have to make decisions. But what if your decisions have real life impact? If you had to choose between killing yourself or another person? What's the rationale?

Here's an interesting test:

(Click on the image. Then just press Start Judging. In the end, you'll have a nice report)

Thursday, February 16, 2017

Top 5 funny things about JavaScript

The year was 1995, Google wasn't born yet. Mark Zuckerberg was 10 years old. Javascript was making its first steps. 22 years latter and JavaScript is everywhere. It's probably one of the most simple programming languages around and it's a good choice for someone that wants to start programming. However, there are some funny things about Javascript that anyone entering the language might find odd. Here's my top 5 funny things about the language. Just open a Google Chrome window and press F12. Have fun.

#5 – null is not an object?
What does a null look like in JavaScript? Well, let's check:

null is not an object

Object? Shouldn't null be the absence of meaningful value? Well, yes. Despite the above result, null is not considered an instance of an object:

null is not an object

Looking at the language specification, you can see that:
44.3.9 *undefined value*: primitive value used when a variable has not been assigned a value.
4.3.11 *null value*: primitive value that represents the intentional absence of any object value.

So, it's a case of misinterpretation.

null is not an object

#4 – NaN is a Number
What's "Not a Number"? Well... a number!

NaN is a Number

Funny as this might look, there's more. Not a Number has "identity issues" and is not equal to itself:

NaN is a Number

Well, the technical explanation for this is complex and it's related to the types of NaN (quiet NaN and signaling NaN). You can read more here, but the real way to check for a number is using the function isNaN():

NaN is a Number

#3 – Math.min() > Math.max()
Hum... So, the minimum value is higher than the max?

Math.min() Math.max()

Let's look at what they "represent":

Math.min() Math.max()

Well, seems to be wrong. These don't represent the max or min values for a number, but actually functions that given two numbers return the max or the min of the provided parameters.

Math.min() Math.max()

But why Infinity? And, apparently, in the inverse order? Well, looking at min(), "all numbers that are lower than positive infinity should be the smallest from a list, if there aren't smaller". So, the below makes sense:

Math.min() Math.max()

Number 5 is the minimum between 5 and positive Infinity.

#2 – true + true === 2
Let's do the math:

true + true === 2

So, someone entering the language might think that true === 1. Lets check:

true + true === 2

As odd as it might look, it actually makes sense. "EcmaScript standard specifies that unless either of the arguments is a string, the + operator is assumed to mean numeric addition and not string concatenation." So, it was the sum of the conversion to integer. As for the second part, true === 1 yields false because it's also comparing type and

true + true === 2

#1 – 0.1 + 0.2 !== 0.3
This is the coolest one and it's not a bug or anything. And it actually happens on several other programming languages, like C# (.NET) and I've written about it in the past

0.1 + 0.2 !== 0.3

"Computers can only natively store integers, so they need some way of representing decimal numbers. This representation comes with some degree of inaccuracy. That’s why, more often than not, 0.1 + 0.2 !== 0.3."
You can read more here (Floating Point Math) and see the behavior in other languages as well.

There is more to it, but these are definitely my favourite. If you want more, there's a cool video about JavaScript:

JavaScript Like It's 2013 (OutSystems)

Here's the full presentation at OutSystems Next Step 2013.

What's your favourite JavaScript funny fact?

Saturday, February 4, 2017

A huge handmade progress bar

We're all used to have everything digital nowadays. Onenote, outlook, notepad++, whatever-tool-to-take-notes-not-in-paper. We also have all the tools in place for a proper project management, from Microsoft Project to JIRA, Asana, whatever-tool-to-make-sure-your-project-is-successful. It's a digital world and there's no need to run from it. It's good. However, there's something all these tools cannot give: the sense of reality. Really see the finish line.

One of the best places to run in Portugal

What does this have to do with a progress bar? Well, I'm an old school guy. I like paper books rather than PDF. I spent more than a decade learning in chopstick boards. And the first years of your life are spent drawing things. So, I'm one of those that religiously believe that the first step of a task is always either a whiteboard or a blank piece of paper. The great news is that I have the privilege of working in a place where almost every wall is available to write. So, we draw a lot.

In the past months we were "under water" (again) with milestones to hit. Our attention was again starting to get scattered. "What needs to go to production when? What does JIRA say?". Argh, this is hard. Hum, drawing boards...

César Afonso
We have whiteboards everywhere

And magic happened. We decided to draw a progress bar on one of the walls next to the team (The little man walking the progress bar is actually a joke from a contest, "Right Price"). A small thing that made a huge difference. Everyone sees it when they arrive. Everyone knows when they leave. Everyone understands the weight of it. Everyone is focused on our progress. When someone comes to our team with a feature request we can quickly give visibility of "can or can't do". We even get creative around it.

So, the wall behind me is now a huge handmade progress bar that we updated everyday. It's a small detail but for me makes a huge difference.

Monday, December 19, 2016

Sex is easy. Love is hard.

My career is not going as I expected. It really isn't. When I graduated I thought "I would like to have my own company. But for now, I better have some real world experience. Plan: I'll work one year at a company, jump to another after another year and so on until I get tired. It's the best way to get experience and make more money". So, my first job was in a small software company. I was working 15 hours a day, doing project management, visiting clients and developing at the same time. VB6 and ASP.NET 1.1 with VisualBasic.NET. Argh... I survived for 1 year just because I was too proud to quit. But I couldn't keep on like that forever. It was easy to quit, no regrets. Like sex. So, sticking to the plan: next! Bad luck. I fell in love with that company. It was one of the best places to work ever. I thought of leaving several times, but I was just too in love with it. I stayed for as long as I could. 6 years! I had a really great time working there.

Well, it's the future that needs oxygen, so, lets move forward. Back to the plan. In business, "always leave your emotions at the door".

Sex is easy, Love is hard

So, I though: The next is it. I'll be there 2 years and done. "No love, just sex!" Guess what? I'm screwed! Two years have gone by and I'm starting to love this company. It's unique in so many ways, it's just from another world! So much for my plan...

But I'm fine with it. Sex is easy. Anyone can do it. Love is hard.
Love what you do. Love the company your work for.

Tuesday, November 22, 2016

Quick guide to generate your mobile app with OutSystems

OutSystems 10 brought low code development for mobile apps to a new level. You can now generate mobile applications in a matter of minutes. Literally.

OutSystems 10 Revolution

The final step to have your mobile application is, of course, generating the apk (application package) or ipa (iOS application archive) to install on your device. But what kind of package/archive should you generate? Lets demystify the several types of builds in a simple way. Developer to Developer. No more than 300 words. Ready?

Android World
Well, you only have two options to choose from: Debug or Release.

OutSystems 10 Revolution Android
(click to enlarge)

What do they mean?
Debug: Want to play around and install on your device? Troubleshoot some error? Just pick Debug, choose your app id (uniquely identifies your app) and you're ready to go. 2 minutes and you'll have your app. That simple.
Release: Second use case, share it with some friends or publish to Google Play? Pick Release. Fill the signing information (it's all free until this point) and that's it. More info about how to sign your app in "Signing Considerations".

Android - Done!

iOS World
Of course, it's more complicated. In the Build type dropdown, you're presented with four options. Lets go through them one by one.

OutSystems 10 Revolution iOS
(click to enlarge)

In-House: forget it. This type is used by enterprises that have an Apple Enterprise Account (which costs some money and has strict policy rules). As a personal developer, you won't be using it. If you do want to know more, check the link at the bottom.
Development: It's the only build type that will allow you to connect your iOS to a mac and troubleshoot issues. So, if in an initial development phase, it's a good pick.
Ad-Hoc: Allows you to install your app without going through the Apple store. However, different from the Android World, you can't just share the IPA. The devices of your friend or whatever must be pre-registered in Apple's Center.
App Store: Nothing to add. It's the only way you'll put your app into the Apple Store. You won't be able to install it in any other way, so, this will be the final step after you've developed and tested your app.

If you want to better understand both these worlds, OutSystems has a great article in the Engineering blog that will bring more light to this: Cruising through the Complexities of Signing Native Mobile Apps

Monday, November 14, 2016

Macs are like Sushi

I've always been a Windows user. The first version I had in my Desktop was 3.1 and, until Windows XP, I kept up to date. Windows 95, then 98, then XP. With Windows XP, I stopped the upgrade process. No Windows Vista or Windows Seven. Why? Well, I use a PC to perform some task. So, if Windows XP was providing me everything I needed to be productive, why go to Windows Vista or Seven? Just because "You should always upgrade"? I didn't. I kept using Windows XP until Windows 8.1 because I didn't feel the need to change. I was productive with Windows XP.

With Macs it's the same thing: every time I have a task to do and I try to use a Mac, my rhythm slows down and I get irritated pretty fast because I'm taking so much time to perform simple things. But it should be fine because I'm not an experienced Mac user and I don't know the shortcuts nor the intrinsics of the Apple world. And quickly the Windows Vista and Seven Syndrome comes to my mind: Why? Why should I adapt? I'm productive using Windows, so why go through the learning curve to perform the same tasks? "Because the Macs are better", they say. Are they? I've been in these type of discussions a million times. Some will tell you that Volkswagen is the best car manufacturer in the world. Others will argue it's Honda. Some will say Nike produces the best shoes, others will say Adidas. Is it .NET better than Java? You get the point...

The best laptop to me is the one that allows me to be more effective and efficient. That's it.

Mac and Sushi

So, bottom line: Macs are like Sushi. Some people like it, love it. Others don't. The ones that do like Sushi will argue that you never tasted really good Sushi and they know "a place" that will make you like it. It never happens. I like other food. It's "Ok" to like sushi. It's "Ok" to like other food. It's pointless to discuss why you don't eat Sushi. It's pointless to discuss why you don't like Macs.

Notes: This post could be "Windows is like sushi." And I do like iPhones.