Crio Portfolio

Back

Buildout - Short URL (XUrl)

A utility to generate short URLs

XURL is a utility that can be used to generate and retrieve short URLs when we don’t want to use the original longer URLs.

During the course of this Micro-Experience, the developer:

  • Created a short url library with required methods.

  • Implemented register method to take a long URL and return a shorter URL.

  • Implemented a method to lookup the long URL by providing the short URL.

  • Implemented hit count to track number of long URL lookups.

  • Tested this implementation with test cases.

image alt text

XURL Interface

Buildout - Short URL (XUrl) Modules

1

Build XURL from scratch

Scope of work:

  1. Create a concrete class which implements a short URL interface class provided. It contains all the methods that can be used to create long URL to short URL mappings.

  2. Implement a method to take a long URL as input, generate a random 9 character short URL and return it. Also maintain this mapping using a hash map for quick retrieval.

  3. Implement a method to take a long URL and a custom short URL as input and register that mapping.

  4. Error handling to make sure each long URL maps to only one short URL and vice versa.

  5. Implement a method to lookup short URL for a given long URL, from the mapping created.

  6. Implement a method to delete the mapping based on a long URL.

  7. Implement a counter to keep track of the hit count for each long URL - which tells us how many times a particular long URL has been looked up.

  8. Test these methods using test cases.

Skills used:

Core Java, Interfaces, Debugging