Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What the actual fuck is this? I read this as "in order to do a hello world, you must first create a hello world service to create the hello world factory to create the hello world sercice so you can print hello world on the screen."

Well, you misunderstood, and now you're ranting according to your misunderstanding.

I'm not an Angular, expert, but I'm pretty sure that the situation is this:

1. "Hello world" does not require any dependency injection whatsoever. (ie. it does not require services, providers, or factories). Note: if this was not true, I would agree with this rant completely.

2. If and when you decide you want dependency injection, if what you want to inject is a simple value, you can just provide it directly, without using a service, provider, or factory.

3. If and when you decide that you want to provide a dynamically-generated value, you can specify a function instead which will get called whenever the value is requested. This is called a "factory."

4. If and when you decide that you want your factory to just "new" an object instead of running an arbitrary function to provide the value, you can register that object type as a "service."

5. If and when you decide that you want to configure that object type first, you can register it as a provider.

If you want to stay at step 1 forever to keep things simple, groovy.

This is a example of success, not failure: you pay for only as much complexity as you actually want to use.



You should absolutely propose to put this into the main page of the documentation of angular.js, please.


As a newbie to all of this stuff (and yet still reading through this thread trying to keep up), thank you. This was the clearest explanation & summary I've read.


Note that you'll find nothing of the sort in the Angular docs. I believe this is at least part of what the author is really railing against. If the docs were crystal clear as to how Angular actually works, doing stuff in Angular would be a lot easier and keep devs from getting pissed-off enough to write rants like this.


> If you want to stay at step 1 forever to keep things simple, groovy.

You can use Grails with Groovy to go to steps 2-5, tho all Grails does is use Spring which it bundles. In fact Grails started off as a thin wrapper around other software like Groovy, Spring, and Hibernate, and was really intended as a vehicle for its despot to muscle in on the consulting and conference markets for the bundled products, tho it's since grown its own codebase by signing up volunteers willing to sign the onerous VMWare contributors agreement signing away all copyright and patent claims over to VMWare.


Not gonna lie, this is the best explanation I've heard of these patterns.

I'm echoing the other comments here. All documentation should be written like this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: