I'm learning Node.js and all back-end stuff and I see there's one way to implement a server by import the module and declare the path and the app a...
For further actions, you may consider blocking this person and/or reporting abuse
In my opinion, it's not the best example to show the OOP style server code.
Server.core + performanceHooks -> Babeljs -> repl.it
repl.it/repls/GrowingBustlingScales
Server.listen + performanceHooks -> Babeljs -> repl.it
repl.it/repls/LameUpsetPdf
Expressjs + performanceHooks -> Babeljs -> repl.it
repl.it/repls/GrubbyMediumConversion
I'm not a fan of OOP, and I'm not strictly bound to pointless or functional programming, but the given an example is, at least to me, not a good example.
Also, the compiled code isn't shorter or faster than the code we've used writing for years.
The Server.listen example is as fast as Expressjs while Server.core example is up to 4 times slower.
Note: benchmarks are always wrong because so many invisible (implicit) variables have an impact on them.
Thanks Denny I understand now
Why would I create a class for an existing Singleton Pattern entity, such as Express.js, just to create methods that merely call the inherited methods from the instantiated property of Express itself? . Your example assigns the app parameter to this.app property, being a direct referral of the
express()Express method.Your proposed approach seems redundant. The purpose of a class is not to create a static blueprint but rather a flexible one that allows not only the use of existing methods and properties from its parent but also the extension of its own whenever needed. In this example, what purpose does the class serve with this approach?
This code seems overrated for a simple task like instantiating a new Express server.