Which strategy of content architecture is best with unit testing in mind in TypeScript? Creating modules or classes?
module: moduleX.method1();
// Exported method
class: var x = moduleX.method1();
// Public method
best with unit testing in mind in TypeScript
If you have a function that doesn't depend on local state in a class .... then it should just be a function. No need to new SomeClass().foo()
when you can foo()
Here you can use namespaces to offer a nice consolidation of different function into a single object : https://basarat.gitbooks.io/typescript/content/docs/project/namespaces.html and you get something like Utils.foo()
Be warned that I would prefer you just make a javascript module instead of a namespace : https://basarat.gitbooks.io/typescript/content/docs/project/modules.html
Most importantly have fun 🌹 As long as you are consistent and considerate of the next developer (leave comments / types) you can focus on the business logic.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.