TIL(20.02.18)

Hyerang Kim·2020년 2월 19일
0

TIL

목록 보기
1/1

I just signed up velog to see how my developing skill gets improved day by day. I've been working on a javascript basic syntax, error handling, general concept of algorithm, pair-programming, and gooling strategy. By the end of the day, me and my partner has completed an assignment about string using a website called coplit.

1. Error handling in coplit

Coplit

Coplit is a website that identifies our code accuracy based on the test code

  • Important to utilize the error message so that we can approach the error with clues given by the error message without simply assuming and fixing it

1. Read and understand the requirments

  • Check the Return Type!
    ex) function isOldEnoughToDrink returns true if given age is greater than 21 and returns false if given age is less than 21. (Boolean)

2. See the test case

expect(isOldEnoughToDrink(40)).to.be.true;
  • expect function is an assertion function that is given by the test framework

3. Figure out why the test has failed

expected undefined to be true
  • What it means is this function returns undefined instead of expected value true.
  • The general way to solve this problem is analyzing the error message and track the passed test case back, which is called debugging(will be discussed later).

2. Algorithm

Pseudocode

Write out the every single step of the program with an everyday language. It does not work out properly with the actual computer programming code, but we can just see how it flows.

Practice with the sample function

Conditions

  • (100-90) --> 'A'
  • (89-80) --> 'B'
  • (79-70) --> 'C'
  • (69-60) --> 'D'
  • Need to put the negative sign at the end if the first digit is in 0~2
  • Need to put the positive sign at the end if the first digit is in 8~9

*Bad way: manually write out the every single condition!

Writing a Pseudocode

  • if score is 100, then returns A+ immediately
  • get a tenth digit value from score
  • get a first digit value from score
  • if the tenth digit is 6, then the grade letter turns out to be D
  • ... and so on up to grade letter A ...
  • if the first digit is 0~2, then the sign would be '-'
  • ... same thing for the rest ...
  • the final result could be combination of the grade letter and the sign
  • return the final result

No post for the actual code: This problem was the most challenging and the longest one of the all assignment for yesterday

3. Debugging: Problem Solving

What is Debugging?

Type of technique that analyzes a cause of unexpected action of the program

  • There should be no such case that determines a problem with a simple assumption without any evidence

What if the result is incorrect?

Not a syntax error but seems to be a logical error

  • Set up a presumption from a specific part that might cause an error
  • Justify whether the presumption is correct by using console.log

"Don't make multiple presumptions. If so, there must be all independent each other!"

Useful test method (Unit Test)

  • Make up some test cases
  • Compare the expected value and the actual value for each

4. Googling Strategy

Even if you face some unfamiliar topic that is yet to learn, you need to have an ability to figure out by yourself by searching

  1. Take keywords out of the problem
    ex) Please convert a given variable to string
  2. From the search result, we can see there might be some better keywords and search with that keywords again
  3. If error occurs, search with the entire error message
  • Stack Overflow is reliable
  • Especially the answers with the check mark
profile
Backend Developer

0개의 댓글