Google Interview Question
SDE1sCountry: India
Some thoughts with respect to each phase ... please help improve
Requirements:
Pastebin utility or pastebin service
Should paste some text - max. limit of text, only ascii characters or symbols (i.e. Roman characters or any other alphabet)
Location of the destination document in which text is to be pasted, i.e. server, disk etc.
Text should be accessible with the help of a URL - so URL-text relationship, is it one-to-one or one-to-many? How about one-to-none? I.e. URL exists but does not map to any text. Should we use already exisiting URLs? Can new URL be created on fly?
Is there a maintainable URL repository?
Details about invoker(s) of this service
Details about end-users of this service - what happens once a URL-text mapping is established - any persistence happening here? Or notifications being sent to the invoker?
Design:
URL - string (starting with http, https or ftp)
URL repository - memory(list), database, cache, file (application/disk)
URL creation - pre-existing or on-the-fly
URL-Text map repository - database, cache
URL-Text mapping - one-to-one, one-to-many
Architecture:
Namespace: com.gooogle.pastebin
driver - main driver class - PasteBinDriver
processor - PasteBinProcessor
service - PasteBinService
persistence - PasteBinPersistence
Patterns used:
Factory/abstract factory for creating objects in each layer
Singleton for driver class
here are some basic Idea.
- suwei19870312 June 17, 20141. there should has many file server, which used to store data from user client.
2. master web server tell user client send the file to which file server. and save the file with encode name, or even data encode.
3. and use the encode name and file server to generate url, user then can use this url to access the text.
4. there should has account service, which used to make sure this user's storage limitation.
5. there should has duplicate logic, which make sure the file is can not access because file server down.