W28Y16 – Fibonacci implementation, compare JS UI frameworks performance, Android viz libraries and Hungarian notation

Fibonacci implementation

Why fibonacci ? Hum, juste because I was asked for this on my last interview and I stupidly failed with it… So, you’ll two different ways of implementing this algorithm:

  • recursive
  • iterative

The first one (recursive), is more elegant but not performant for big numbers (in fact, you’ll crash your memory by doing a recursive fibo for a number like 10000). The second one is in basic iterative loop do/while.

Mathmatics fonction: fibonacci(x) = fibonacci(x-1) + fibonacci(x-2)

Recursive

function fibonacci(n) {
  if (n < 2) {
    return 1;
  } else {
    return fibonacci(n - 2) + fibonacci(n - 1);
  }
}

Iterative

function fibonacci(n) {
  var a = 0, b = 1, f = 1;
  for(var i = 2; i <= n; i++) {
    f = a + b;
    a = b;
    b = f;
  }
  return f;
}

The fibo implementation in a looooot of different languages: http://www.scriptol.fr/programmation/fibonacci.php

JS UI framework perfs

ui_frameworks_comparison My colleague Justin (the tech surveillance killer) just sent me a nice repo about the comparaison most famous UI frameworks you could find. This dashboard allows you to decide regarding performances on:

  • rows creation
  • rows upodating
  • partial rows updating
  • selection of rows
  • swapping
  • etc, etc…

Just follow this link to see the comparison: HERE
And here to see the github repository: HERE

Hungarian notation

The Hungarian notation is very useful for languages with a loosely type like Javascript. This notation method is also used like an identifier to know the expected type of the variable. Some examples of naming variables using this convention:

  • bBusy : boolean
  • chInitial : char
  • cApples : count of items
  • fBusy : float (or flag)
  • nSize : integer (Systems) or count (Apps)
  • iSize : integer (Systems) or index (Apps)
  • dbPi : double (Systems)
  • rgStudents : array, or rangee
  • fnFunction : function name

Wikipedia about Hungarian notation

Android chart/viz libraries

I just tested two different Android chart/viz libraries from this github repo who regroups a good exhaustive list of viz libraries for a lot a languages (including Android of course)

HelloCharts

Very good if you only want to show some column charts, bar charts, lines charts, donuts. Charts are highly customizable :

  • fonts
  • sizes
  • colors (lines, points, axes, …)
  • background
  • with/without points
  • filled spaces
  • etc, etc…

HelloCharts Github Repository

I’ll stress a point, you don’t have any legends for your charts! that’s important because if you want one, you want need to create it manually…

MPAndroidChart

I’ve got some problems while adding MPAndroidChart as a dependency to my Android project, so I switched to HelloCharts. Maybe the wiki was deprecated, in the middle of a new version ?… I don’t know.
Anyway, this library is more complete, and maybe better, so if you are successful on adding this lib to your project: use it!

Animation concept

Nice animation concept by Mario Wahl that you can find on Dribbble.

Because code without design is not really usable, I’ll share, in each weekly article, a design creation that I liked (icon, animation, UI, workflow, …).

preview

2 Comments W28Y16 – Fibonacci implementation, compare JS UI frameworks performance, Android viz libraries and Hungarian notation

Leave a Reply

Your email address will not be published.