M

Miško Hevery

misko.hevery.com · Personal blog · on HN since 2008

Miško Hevery, creator of AngularJS, writes about testable code, dependency injection, and object-oriented design pitfalls.

What HN saysCommenters cite his posts on singletons and static methods as excellent explanations of why they make code hard to test, though they note he no longer posts.
36HN people shared it
19linked it in comments
22stories submitted
150story points
3 years agolast shared
2008people per year2026

Most-shared posts

  1. 1
    Singletons are Pathological Liars
    9 people · 13 points · first shared 2009 · 1 comments on HN
  2. 2
    Guide: Writing Testable Code
    6 people · 9 points · first shared 2008 · 2 comments on HN
  3. 3
    What Pair-Programing is Not
    3 people · 45 points · first shared 2009 · 9 comments on HN
  4. 4
    Guide: Writing Testable Code [pdf]
    2 people · 62 points · first shared 2014 · 7 comments on HN
  5. 5
  6. 6
    Hello AngularJS
    2 people · 1 points · first shared 2014 · discussion on HN
  7. 7
    Homepage
    2 people · first shared 2011
  8. 8
    Static methods are death to testability
    2 people · first shared 2013
  9. 9
    How to think about OO
    1 people · 4 points · first shared 2009 · 1 comments on HN
  10. 10
    Cost of Testing
    1 people · 3 points · first shared 2009 · 1 comments on HN
  11. 11
    Misko Hevery - Design for Testability
    1 people · 2 points · first shared 2010 · discussion on HN
  12. 12
    Computer Engineer vs. Computer Scientist
    1 people · 2 points · first shared 2009 · discussion on HN
  13. 13
    Software Testing Categorization
    1 people · 2 points · first shared 2009 · discussion on HN
  14. 14
    Flaw constructor does real work
    1 people · 1 points · first shared 2013 · discussion on HN
  15. 15
    Managing Object Lifetimes
    1 people · 1 points · first shared 2009 · discussion on HN

What HN people wrote when they linked it

hayst4ck · 2023-06-12
http://highscalability.com/ http://misko.hevery.com/ Old, and Hevery no longer contributes, but lots of great stuff.
ivanche · 2017-10-27
>That said, if you go for functional style in OOP, i.e. shoving as much as you can into static helper functions and most of the rest into dumb private stateless functions, you suddenly gain both a clean architecture and lots of test points to use in unit tests. So you can have testable code, but you have to chill out with the OOP thing a bit. Wow, this is exactely totally opposite of how one can achieve testability in OOP! For more details I recommend excellent Misko Hevery's article "Static Methods are Death to Testability" [1]. Also, I'd argue that "functional style in OOP" is an oxymoron - you're either OO or something else (functional, imperative...) [1] http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testabi…
throwaway613834 · 2017-09-20
Very relevant (and, I think, excellent) article: http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/
davidjnelson · 2014-02-28
Growing Object Oriented Software Guided By Tests is a great book on the topic: http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp… Misko Hevery's (also happens to be creator of angularjs!) Testability Explorer blog is also a great resource: http://misko.hevery.com/category/testability-explorer/
V-2 · 2013-11-25
The use of statics makes mocking and testing very difficult. A few thoughts on the subject: http://misko.hevery.com/2008/12/15/static-methods-are-death-to-testabi… If you use static classes for business logic, you typically end up with a tightly coupled system in which managing class dependencies is a pain. I think that "messing around with interfaces all the time" is worth the fuss in the long run.
room606 · 2011-07-09
Misko's blog is brilliant and it is truly a shame he isn't posting as much as he used to Some posts relevant to this discussion http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state…
eneveu · 2011-07-08
Misko Hevery - one of the developers of the GSD - has a blog were he talks about testing, dependency injection, and global state. He hasn't posted a lot recently, but there is a lot of interesting stuff if you dig through his archive. http://misko.hevery.com/
inglor · 2015-07-12
No no, singletons are pathological liars http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ Atomic mutable global state is still mutable global state. DI containers mean you don't need a singleton but can just create a single instance which lets you scope it and does not mix lifetime duration and object properties.
gordonzhu · 2014-10-21
I just had a flashback from one of Misko's early talks about Angular's original vision as a full set of tools that included a managed database and security rules. Here's his blog post about the topic: http://misko.hevery.com/2009/10/04/sweet-spot-for-angular/ Some quotes: "<angular/> provides the database hosting as a service so that your <angular/> application does not have to worry about it." "The cost of building security and authentication into your web-application is often overlooked when building web-applications. <angular/> offers both out of the box."
SoulMan · 2014-09-18
Could have just posted the HTML link :) http://misko.hevery.com/code-reviewers-guide/
georgemcbay · 2014-07-15
AFAIK it was more inspired by Adobe Flex (though like WPF and other frameworks, Angular took the data binding idea further with full two-way binding), which predated WPF (at least in terms of public releases) by a couple of years. See, for example: http://misko.hevery.com/2010/08/10/what-flex-thought-me-about-data-bin…
lazydon · 2014-01-30
Singletons are always a lazy solution to the problem. For me the rule of thumb is if there's some class requiring lots of work to test, I've been lazy. So, go back and review my sloppiness. The questioner was in a way implementing a poor man's cache using Singletons (I wonder how was he planning to test it); some use it for connection pooling instead of a specific library. I've heard even GoF regretted including Singletons in the s/w patterns club. I'm a big fan of Misko Hevery's (now working on Angular) work on this. http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ http://misko.hevery.com/2008/08/25/root-cause-of-singletons/ http://misko.hevery.com/2008/08/21/where-have-all-the-singletons-gone/ I miss this guy in Java world.
neilk · 2012-08-20
Misko Hevery (author of AngularJS) wrote a good blog post about how if you pair with a new hire for a day, you can bring them up to speed almost instantly. I tried it and it works - my new hires were committing real fixes by the end of day one. http://misko.hevery.com/2009/06/12/what-pair-programing-is-not/ An additional benefit is that the experienced and more senior developer will also have to endure the pain of setting up, and the undocumented parts, and may even fix them. However, if I was looking for a technical fix, I think using Vagrant is far better than anything cloudy. The cloud is a tradeoff - you get the benefits of virtualization, if you accept the downsides of it being all remote. The OP's solution doesn't even allow you to choose your editor! Vagrant gives you all the upside and none of the downside.
zoul · 2011-05-02
The post is down, so I can’t comment on that, but getting rid of singletons was the single most effective thing I did to improve my software design. I also summed up my objections to the singleton pattern in a blog post: http://zmotula.tumblr.com/post/1390385240 There’s also a blog post called Singletons Are Pathological Liars by Miško Hevery, which is very well thought-out and contains links to other related topic: http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ Hope that helps somebody, reading Hevery’s articles was a huge eye-opener for me.
rubentopo · 2009-02-05
No one method works all the time, this depends on the paradigm of the target language. At least i can't use one method. One thing that makes it much easier (at least for me) is trying to use dependency injection, otherwise i get lost. Misko Hevery said it better. http://misko.hevery.com/2008/11/11/clean-code-talks-dependency-injecti…
nailer · 2014-05-01
1. Angular is maintained by Google, but it was not created there. 2. Getangular was an online JSON storage service where Misko worked. AngularJS was announced on getangular.com (which was a product, not a project), and copyrighted Angular / BRAT Tech. LLC. getangular's website: http://web.archive.org/web/20100413141437/http://getangular.com/ http://misko.hevery.com/2009/09/28/hello-world-angular-is-here/ (original angularjs announcement, which mentions getangular.com) You might also want to check out this early reviews of getangular's product: http://www.niden.net/2009/12/world-with-part-1-reviewhow-to.html http://en.wikipedia.org/wiki/AngularJS#Development_history Or just ask Misko, Brian or any of the other Angular developers. 3. Search for 'Angular / BRAT Tech. LLC' for additional references

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close