Question: Hi I am new with Angularjs. I am reading about Angular service. I have read the following 
[what-is-difference-between-factory-service-and-provider](https://stackoverflow.com/questions/24342244/what-is-difference-between-factory-service-and-provider) and [service-vs-provider-vs-factory](https://stackoverflow.com/questions/15666048/service-vs-provider-vs-factory). To me, it seems like they are just different way of achieving same goal (please correct me if I am wrong.) Now I am wondering as they all serve the same purpose which one is idea to use and considered as best practice?

Answer: 
There is no best practice, no one is going to tell you that one is better than the other (service vs factory).

Use a provider if you need to configure your service at run time (like you configure your router for example).

To when to use a factory or when to use a service, they are the same.

Factory has the easiest syntax to understand (using reveal module pattern) so that is the most common choice.

On the other hand, services are now more "useful" because they use the same syntax as the Angular 2 services, so if you plan in migrate someday, using services now will help the transition.
Sounds like the question is when to use which. First it's important to note that they are all providers. Each is a more specialized version of the other starting with `provider`. `factory` is a specialized version of `provider`. `value` and service in turn are specialized versions of `factory`.

And `constant` and `value` are specialized versions of each other. Because `provider` is at the top can therefore can do what all the other providers do you could get away using just providers. But you would be writing a lot of unnecessary code.

Each specialized provider down the chain, if you could use it would allow you to accomplish the same thing in less code. So you could say the best practice is to use the provider furthest down the chain that accomplishes what you wanted.

Here is a high level image showing you what I mean:

[![enter image description here](https://i.stack.imgur.com/jnKe8.png)](http://www.simplygoodcode.com/2015/11/the-difference-between-service-provider-and-factory-in-angularjs/)  

(source: [simplygoodcode.com](http://www.simplygoodcode.com/wp-content/uploads/2015/11/angularjs-provider-service-factory-highlight.png)) 

And below is the link to the blog post the image is from that gives you additional examples:

<http://www.simplygoodcode.com/2015/11/the-difference-between-service-provider-and-factory-in-angularjs/>