1 2 3 4 5
People from the back-end community are calling for major help to curb this madness for some time before things get out of hand.
When those voiced frustrations granted protestations loud enough, someone would sure to come along to rescue us from being ‘drowned’ in this madness.
Thus, a new innovation was born.
This is very true when I first took this mini-video tutorial I found via EggHead online courses.
1 2 3 4 5 6 7 8
1 2 3 4 5
somefunc function with two supposedly string parameters comes to pre-warn developers the incorrect parameter type when making the method call, thus developers can immediately pick up the errors early on without having to touch their debug console to troubleshoot the app, from start to finish.
This is surely amazing!
This is all very encouraging and exciting indeed, for a start.
What’s the catch?
Supposed you’re given this piece of snippet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
which transpiles to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public methods and variables definitions is the correct way to do - design-wise.
When trying to do this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
And it’s transpiled to this…
1 2 3 4 5 6 7 8 9 10 11 12 13
This is starting to look very off for me.
Why would you have a private variable
greeting and a private method
At least, the minimum I was hoping for is it should be re-written like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Now, this truly respects proper encapsulation.
And, you want to access them via ‘public’ methods, you would then write.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
For some reason, Typescript, by default, favours the prototypical properties for all object class definitions and instantiations.
Why they’d rather be doing this than the alternate approach above?…
I don’t know.
I totally get that.
In spite of it, I’m still excited about Typescript developments and its future endeavour and fully support it.
Something for all of us to bear in mind.
PS: Some useful reading here for the curious-minded.
- Typescript learning resources - https://basarat.gitbooks.io/typescript/docs/why-typescript.html
- Try Typescript online - https://www.typescriptlang.org/play/