Observables and Finnish Notation

const click$ = Observable.fromEvent(button, 'click');

Hungarian Notation

const sTest = "test";
const nShortPI = 3.14;
const obsClicks = Observable.fromEvent(domButton, 'clicks');
  • In an untyped language like JavaScript, it becomes clearer what type might be in your variable.
  • In an untyped language like JavaScript, sometimes variables like arguments to functions take more than one type, then what do you do?
  • It’s a lot more typing for minimal benefit.
  • May hurt readability in some cases?
  • With the advent of TypeScript and modern IDEs, Hungarian Notation isn’t really necessary in most languages, because the IDE gives you a lot of information about the variable while you’re working.

Non-Finnish Notation (ordinary variable names)

const test = "test";
const shortPI = 3.14;
const clicks = Observable.fromEvent(button, 'click');
  • Generally easy on the eyes. Not a lot of special character clutter or non-words. Just words you can read that ideally signify the intent of the variable.
  • Easy to use in situations where a variable may store more than one type at any given time. This happens a lot in JavaScript code, whether it’s good practice or not.

Finnish Notation

const test = "test";
const shortPI = 3.14;
const click$ = Observable.fromEvent(button, 'click');
  • Observables are REALLY easy to spot now. Before you might have just looked for a `subscribe` call or something.
  • Might be ideal for codebases where observable use is prolific. Things like Cycle.js or Angular 2 applications.
  • Things aren’t always pluralized with an “s”, so $ doesn’t always make sense.
  • Why are we doing this with just observables? what about promises? or functions?
  • You have to reach for $ a lot on your keyboard (your IDE will probably solve this problem though)

Finnish-Goldman Notation

const oxeÑ = Observable.from(olleyOlleyOxenStream());
const mic€ = Observable.from(threeBlindStreams());
const peopl€ = Observable.from(allPeopleReadingThisNow());

So what do you choose???



RxJS Lead. Views are my own

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store