Showing posts with label apply SOLID principles to CSS. Show all posts
Showing posts with label apply SOLID principles to CSS. Show all posts

Tuesday, January 17, 2017

Suffix Rotation - a test case tells the truth

January 17, 2017

Introduction
Julia had some study on Leetcode 17 - a phone number algorithm, one of studies is on stack/ queue implementation of the algorithm in May 2016. After more than 6 months, in January 2017, she worked on suffix rotation algorithm in the contest, she made a mistake to choose using queue instead of stack.

So, after the week code 28 contest, in 1 - 2 day, she studied suffix rotation's test case provided by hackerrank: a string "lcatqjejhpgkrkhnxsfyqlulncefeytykwnqbfmqaduldwhgwruwkdvojexefcmfrlfuzzcurjgnnbkskbzw", the code has issues related to out-of-memory, queue size is over 11,387,997, 10 millions, stop after processing first 12 chars "aaabbbbbccc", over one minute at least.
code with bugs is here.
Suffix Rotation C# practice, with a bug running out of memory.
working code is here.

Problem Solving 

Thank you, a small test case helps me to understand the issue again. Queue vs Stack, for phone number less than 7 digits, queue is still ok - not causing out-of-memory issue. But with string with length over 20, the problem quickly comes out easily.

lcatqjejhpgkrkhnxsfyqlulncefeytykwnqbfmqaduldwhgwruwkdvojexefcmfrlfuzzcurjgnnbkskbzw

Remember this test case, as a programmer, Julia has to work on a test case more often; build a good habit to figure out issues in the design with help of test cases, specially in any hackerrank contest. Kind of boring talk, let us talk about a song.

The solid Rock, corner stone or sinking sand

Julia has a favorite song she likes to sing along a lot of times, specially a lot of years ago (2000 - 2010) in Boca Raton

Related to being a hackerrank contest player, Julia has some hope, the test case can be her solid rock if she has weakness in the design, and flaws in thinking process.

The test case is the solid Rock, I stand;
All other ground is sinking sand, 
All other ground is sinking sand.

Code review study

Julia chooses to study more on phone number related algorithms.

1. Code review: Phone number.
2. Very good Dynamic programming explanation, read the phone number's code review by Google engineer.
3. Phone number code review - group of 3 digits with no lone digits.


At last, review algorithm code review made by a google engineer, click here.



CSS style sheet guidelines - study

January 17, 2017

Introduction
It is time to learn more about CSS at the beginning of 2017. Julia still remembered that a few years ago (maybe in 2012) she had to answer the question - what CSS stands for, actually she did not answer correctly. In 2013, she decided to spend 2 months to read "Head first html and CSS", and fell in love with solving the puzzles at the end of chapters, she spent over 20 hours to learn rule, specificity, box model, and then she studied all CSS selectors, and then she started to read CSS code like other language she likes. Learning a language takes some determination

Always Julia learns one term a time, write down, practice, talk about or use it, and then come back to review them. This blog she will learn something about CSS and SOLID principles. 

Study
Design for real life - click here.
Css style guidelines - a summary on CSS - tricks.
Read the article:
http://cssguidelin.es/

Great time to read single responsibility principle, how to apply .css class design. Read Open/close principle, how to apply to css class design. Read Writing DRYer vanilla CSS