5 types of Recipes for Services in AngularJS

Share

Each web application you build is composed of objects that collaborate to get stuff done. These objects need to be instantiated and wired together for the app to work. In Angular apps most of these objects are instantiated and wired together automatically by the injector service.

The injector creates two types of objects, services and specialized objects.

Services are objects whose API is defined by the developer writing the service.

Specialized objects conform to a specific Angular framework API. These objects are one of controllers, directives, filters or animations.

The injector needs to know how to create these objects. You tell it by registering a “recipe” for creating your object with the injector. There are five recipe types.

The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe.

Let’s take a look at the differences between each one of them.

Simple, Free Image and File Hosting at MediaFire

Download High resolution version

Get the Angular Pill

Share

Angular frees you from the following pains:

Registering callbacks:
Registering callbacks clutters your code, making it hard to see the forest for the trees. Removing common boilerplate code such as callbacks is a good thing. It vastly reduces the amount of JavaScript coding you have to do, and it makes it easier to see what your application does.

Manipulating HTML DOM programmatically:
Manipulating HTML DOM is a cornerstone of AJAX applications, but it’s cumbersome and error-prone. By declaratively describing how the UI should change as your application state changes, you are freed from low-level DOM manipulation tasks. Most applications written with Angular never have to programmatically manipulate the DOM, although you can if you want to.

Marshaling data to and from the UI:
CRUD operations make up the majority of AJAX applications’ tasks. The flow of marshaling data from the server to an internal object to an HTML form, allowing users to modify the form, validating the form, displaying validation errors, returning to an internal model, and then back to the server, creates a lot of boilerplate code. Angular eliminates almost all of this boilerplate, leaving code that describes the overall flow of the application rather than all of the implementation details.

Writing tons of initialization code just to get started:
Typically you need to write a lot of plumbing just to get a basic “Hello World” AJAX app working. With Angular you can bootstrap your app easily using services, which are auto-injected into your application in a Guice-like dependency-injection style. This allows you to get started developing features quickly. As a bonus, you get full control over the initialization process in automated tests.

Simple, Free Image and File Hosting at MediaFire

Download High Resolution version

The Zen of AngularJS

Share

Angular is built around the belief that declarative code is better than imperative when it comes to building UIs and wiring software components together, while imperative code is excellent for expressing business logic.

  • It is a very good idea to decouple DOM manipulation from app logic. This dramatically improves the testability of the code.
  • It is a really, really good idea to regard app testing as equal in importance to app writing. Testing difficulty is dramatically affected by the way the code is structured.
  • It is an excellent idea to decouple the client side of an app from the server side. This allows development work to progress in parallel, and allows for reuse of both sides.
  • It is very helpful indeed if the framework guides developers through the entire journey of building an app: From designing the UI, through writing the business logic, to testing.
  • It is always good to make common tasks trivial and difficult tasks possible.

Simple, Free Image and File Hosting at MediaFire

Download High resolution version

Courtesy:
AngularJS
Google

7 things Artists and Clairvoyants have in common

Share

The term clairvoyance (from 17th century French with clair meaning “clear” and voyance meaning “vision”) is used to refer to the ability to gain information about an object, person, location or physical event through means other than the known human senses, a form of extra-sensory perception. A person said to have the ability of clairvoyance is referred to as a clairvoyant (“one who sees clearly”).
Source: Wikipedia

Both have ‘real’ existence


Image Courtesy: Vincepal

Many people take clairvoyance as some sort of unbelievable tales and stories. Now the thing is clairvoyance really exists but not anyone could be able to pretend having that gift. Only the ones born with it can use it wisely. Similarly for the artists, any person can pretend to be an artist or a designer, but the real ones are easily picked out based on their application of their talents and skills.

They have the power to see the future


Image Courtesy: nahhan

A clairvoyant is a person who has powers to see the future or see things which other people cannot see. Likewise a great artist can visualize objects and things which normal people cannot imagine and that is why artists are often referred to as gifted human beings. Remember all the great and beautiful things today are once only a streak of imagination in the minds of the great artists and scientists, which was later given birth to reality after years of dedication and hard work.

Self Control


Image Courtesy: Emiel Wendel

Not all clairvoyants are able to translate what they see and feel in words, it takes time, training and a lot of self control. Similarly an artist achieves his greatest masterpieces only after years of practice, training and dedication to his work and passion. One cannot simply imagine the enormous amount of time the great artists spent in developing their skills and styles to feast our eyes with their master strokes. They simply expend hundreds of hours of their time to create a particular piece of art that itself speaks of its greatness once it is completed.

Beauty lies in the eyes of the beholder


Image Courtesy: Manisha

The one that asks a clairvoyant has also to believe in his powers in order to make things easier for both by letting both energies free to connect and show the hidden sides and the unknown future. Likewise any person who appreciates art and design should have a minimal amount of aesthetic qualities, characterized by the recognition of beauty or good taste to encourage and support the artists on their creations, otherwise no matter how beautiful the creation will be, the artist will not get the appreciation he deserves.

Believe in the Impossible


Image Courtesy: Cheryl

The first and the foremost thing for a clairvoyant to develop his abilities is to believe and accept that it is possible. As long as he or she apporaches it with a positive attitude they will succeed. This can be very much the same in case of artists at their early stage of learning and training, since they must believe in themselves and accept the realities to move forward and achieve the greatness in creating art.

Social Isolation


Image Courtesy: Joe Megahan

Once the clairvoyant has developed his skills, he will be more sensitive to energies that are around him. This will allow him to avoid those people that are notorious for their negative energies. Likewise an artist will not want to absorb negative energies from a person or an environment. Most of them prefer to stay alone during their creative process since it allows them the freedom to transcend the practical realities of day-to-day life into their imaginative universe. This does not really mean that all the artists and creatives are solitary people and avoid outside contact, but it really tells that they simply do not allow others to walk into their beautiful minds with their dirty little feet.

They have organized routines


Image Courtesy: Maia Coimbra

Clairvoyants generally have a meditation routine in a secure and serene place for considerable amount of time for meditation each day. They will be consistent and do not let anything interfere with this time period. Similarly an artist like to have a regular time interval for practicing each day. No matter what, they always find time to practice, learn new skills, always looking for new inspirations, in order to achieve the incredible heights of creativity and artistic abilities.

Parting Thoughts…

What other qualities the clairvoyants and the artists do you think have in common?
Do you really think most of the artists are socially isolated people, if yes , why do you think that way?
Did we miss any other important traits they both have in common?
Why do you think that clairvoyants really don’t exist?
Please feel free to share your views and information through the comments…