Little description:
Encoders come in two variants: contacting and optical. A contacting encoder has switches that close or open as the encoder is turned. As the switches are contacting, you must consider contact bounce. Read more on contact bounce if you need to. Contacting encoders often have detents that 'click' through an entire A/B cycle per detent.
Optical encoders have a slotted disc with two led/photo-transistor combinations. These sensors are arranged around the disc such that when the disc is turned, the A/B pattern is output. Take an old-fashioned computer mouse apart and you'll understand.
Contacting encoders usually have three pins: the centre pin goes to Ground, the other two are A and B that switch to Ground. So, reading the switches involves no more than connecting them to two AT90S2313 inputs. I always use 10k pull-ups on these input pins.
Optical encoders often have pull-up resistors built-in. (Check the datasheet!) They have a power-supply, a Ground and A/B pins. Sometimes they have an 'index' output, a pin that switches independently of A/B. Optical encoders have a transistor that does the switching, so you need not worry about contact bounce.
Source:
http://www.qsl.net/pa3ckr/bascom%20and%20avr/encoders/index.html