Skip to content

Instantly share code, notes, and snippets.

@yowchun93
Created October 25, 2020 08:21
Show Gist options
  • Save yowchun93/0a360d4cd76eecb98867b685e129bde9 to your computer and use it in GitHub Desktop.
Save yowchun93/0a360d4cd76eecb98867b685e129bde9 to your computer and use it in GitHub Desktop.
CoinGecko job application

1. Tell us about a newer web technology that you like

The one technology that piqued my interest in TypeScript. As a software engineer that has work mostly on dynamic typed languages such as Ruby and Javascript, learning TypeScript has been a really eye opening experience for me.

My general experience of using TypeScript and this is based on my personal experience , using a typed language does the following things better than a dynamically typed language:

  1. Types together with Automated tests, give developers the confidence to refactor code, because of the help you get from the compiler and IDE. This generally means that the code will have less technical debt.
  2. Modelling domain objects using Typescript' structural sub-typing. As opposed to the classic typing from c# and java, typescript's type system .

Now code are written coupled to interface, as opposed to class-typing done in Java.

  interface Named {
  name: string;
  }

  class Person {
  name: string;
  }

  let p: Named;
  // OK, because of structural typing
  p = new Person();
  1. In my opinion, Typescript will slowly take over javascript as the default language used in the frontend, when more and more people realize the benefits of a typed system.

Explain Stack vs Queue

Stack uses LILO ( Last in last out) The last object into a stack is the first object to leave the stack, used by a stack

Queue uses FIFO ( First in first out ) Every element which enters a queue is the first object to leave the queue, used by a queue.

Below is a sample example of Stack and Queue implemented in Ruby.

module Sample
  class Queue
    def initialize
      @array = []
    end

    def enqueue(elem)
      @array.unshift(elem)
    end

    def dequeue
      @array.pop
    end
  end

  class Stack
    def initialize
      @array = []
    end

    def push(elem)
      @array << elem
    end

    def pop
      @array.pop
    end
  end
end

queue = Sample::Queue.new
stack = Sample::Stack.new

queue.enqueue("apple")
queue.enqueue("orange")
queue.enqueue("pear")
queue.dequeue # => apple

stack.push("apple")
stack.push("orange")
stack.push("pear")
stack.pop # => "pear"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment