diff --git a/_posts/2019-09-15-day-9949.md b/_posts/2019-09-15-day-9949.md new file mode 100644 index 0000000..7aa77a9 --- /dev/null +++ b/_posts/2019-09-15-day-9949.md @@ -0,0 +1,150 @@ +--- +layout: post +title: "Day 9949" +date: "2019-09-15 00:30:14 +0530" +tags: + - daily + - amazon_principles + - rakuten +--- + +## Morning + +I woke up around 11:30 AM. I then washed clothes and then I rushed to took bath. +I took brunch and reached office around 1:00 PM. I know it is too late than what +I should be. From Tomorrow, I will start sleeping early. I will decide my goals +and I will stick with achieving them. + + +## First half + +I tried too start preparing for Object Oriented Design and System Design +questions. I revised documents shared by Rogers and tried to read Object +Oriented Design PDF. That document was a clear cut from Cracking the coding +interview book. It wasn't looking like it is from a latest version, so I am +concluding that it is from previous version. + + +### Design Online Book Reader + +I tried to design an object oriented program of online book reader. To be +honest, I found myself confusing between a System Design question and a question +related to object oriented design question. + +I spent identifying various component of online book reader. I spent some time +observing how Amazon shows a preview of a book to their customer. I tried +loading Google books and read few pages of any random book. After observing +requests cycles at Network tab, I found each of them show book pages as a image. +When user opens any book for reading, it start loading images of pages in +background. Book pages are not requested and loaded in one request, rather they +are queried by a restful service which accepts various query string parameters +to get next page from current page. + +If a book reading service was storing a book in a one single PDF file, then it +would burnt with an overhead of loading entire book. As a solution to this +problem, single book in one PDF could have divided into small PDF which only has +single page. But non of the online book reading service I observe were +transferring PDF pages to and fro. + +They were using images to store pages. So here I got my first clue that storing +PDFs and transferring them, distributing them over network can be a costly +operation. It will also prevent plagiarising in a book by preventing user from +copying text from PDF. + +Images of books were not stored in any other format, but they were in PNG. +Second question I had was, why not JPEG for storing images of pages? After +reading a Wikipedia of each of them, I found PNG is good at doing looseness +compression. Comparing this with JPEG, it is loosy when it comes to image +compression. JPEG is good for storing user images, photographs where more colors +and detailing are there. For mostly monotonic images like book pages, PNG is a +appropriate format to store. + +After that I decided to find various ways to store images of book pages. Quick +search landed to a few Stackoverflow questions which were telling that these +question is duplicate and asked multiple times at Stackoverflow. Answers were +clearly telling that images should be stored in a file system and link to them +should be stored in database. I would say that one should store images in an +object storage like Amazon S3 or Red Hat CEPH. + +I then tried to think from the beginning. How books should be added into the +system? They should have uploaded by a user. And best uploading format or most +common format in which books will be uploaded is PDF. I designed a +`BookUploader` interface. And then created some concrete implementation like +`BookPDFUploader` based on that interface. I created `BookUploaderFactory` which +registers concrete book uploader implementation and generates instance of them. + +Though this was looking like an interesting brainstorming, but I found this +unrequited at the end, because I spent most of my time in book uploading part +where my goal was to design online book reading. Ideally this should be done at +last if I have successfully designed all other important components of my +system. + +I also think that the time I spent on observing various online book reader was +not worthy because this question was object oriented design, not a system design +question. + +I then designed a few interfaces for entities like Book and Pages, but I missed +one important entity here User. I stored pages as a Doubly Linked List. Storing +of pages could have also done by using Hash tables, but I didn't felt that we +can track previous and next pages by using Hash tables. When using Doubly linked +list with pointer having reference to first page and another pointer having a +reference to last page makes more convenient. But traversal to any linked list +node is linear so if my user want to read book from page N, I have to first +traverse to page N linearly in my Linked List. Rather this was in constant time +if I was using Hashtable. To be honest, I am confused here. I can't predict what +to use, but I want to stick with LinkedList approach because its great track to +have next and previous connected objects. + + +## Second half + +### Rakuten + +I was trying hard to give Rakuten test Yesterday, but I didn't found any good +time to give it. Today I had decided to give test after evening, but I received +an email mentioning that the test has been cancelled. This was completely +unexpected. I was very much excited for Rakuten. I have dropped an email asking +for re-creating a test so that I can give. Let's hope for the best. + +### Amazon Learship principles + +The LinkedIn blog post by one of Amazon's recruiter is great. It explains the +culture of Amazon. I am truly impressed with the culture of Amazon. I wasn't +aware before that Amazon is such a good company. I cried many times while +reading Amazon airship principles. + +Amazon expects different from their candidates. They expects that they should +never satisfy and they should always expect more from them self because there +will be always a room to improve. One takes ownership of what they are working +on. A failure is a failure for a company even if any other team is failing. It +is important to stand on your opinions and fight hard for proving your point. +Amazon expects that their candidate form their opinion and conjure hard so that +their company can win. Amazon expects that their customers are always serve +better. At Amazon there will be always less resources for completing given task. +There will be tight deadlines to complete things. For that one has to start +developing things with quality compromise, a thing which can be prototyped +quickly and served to test their actual performance. Amazonian learn things from +their experience. One should commit even if it was a major mistake. Any mistake +is costly, but that cost goes up and up if one do not learn from it. + +Amazon treats their employee in different manner. A high performing candidate +treated differently from the company than a candidate who is performing low. + +Amazon likes to experiment, but it is very important to measure a success of an +experiment and continue or stop based on results of measurement rather than +following their instinct. + +Amazon focus their customer. Every thing is designed in a manner which increase +trust of their user on them. Doing this is hard, but Amazon does that. Amazon +even loses their profit for increasing their user trust sometimes. + +I am sure I will be missing not some, but most of other important principles +that was mentioned. I would try to make my notes on them first. I will try my +best to make notes as quickly as possible. + + +## Tomorrow + +I will solve two questions of Object Oriented design and I will not tream them +as a system design question. I will try to focus on implementing as many design +patterns as I can.