Day 3 – data structures

Day 3 is the first day of 4 days of data structure.

First, we talked about high level concepts.

To break down a big problem into smaller problems and come up solutions, it is nature to do: modular -> isolate each module -> make sure each module are loosely coupled -> make sure each module has an interface -> make sure each module has some privacy

We also talked about abstraction. A good example is: a remote control abstracts the RC car. Abstraction is introduced for many reasons, including:

– to interprate js code to byte code

– to introduce modularity

– to digest complex ideas (so you can ignore most part of the idea and just focus on one tiny piece)

Second, we reflected on the previous sprint – re-implementation of the pre course work. The criterion we use are: clear / actionable / compassionate / honest. Key questions to address are: who drove / were you engaged / how could each of you improve? Because my pair in this previous sprint has three people instead of two people, we sit together and give each other feedback. My negative feedback is that I didn’t mention that we should continue to work on the extra credit.

Third, we talked about class. Interestingly, class in js is defined as “a function that produces many objects”. There are four ways to create a class. (I miss you, Python!) They are: functional, functional with shared methods, prototypal, pseudoclassical. The current sprint requires us to implement Stack and Queue in four different ways. Jake and I move fairly fast and we even had time to compare the performance of those four types of implementation. It is not surprising that pseudoclassical was about one order of magnitude faster than the functional and functional shared.

A couple of notes on those four ways of doing it:

– When use new Class1(), two magic lines code are inserted in the body of the function where Class1 is defined.


//the first magic line appears at the very top

this = Object.create(Class1.prototype);

...

...

//the second magic line appears at the very bottom

return this;

The effect of those two lines are such that we don’t need to redefine a new object and try to return it manually.

– No function can be both shared and have access to private variable inside class definition. Does this mean that the classical way of doing OOP (such as Java) is better in this regard???

– We also had tons of confusions about prototype during class. The only thing that seems to solve the problem is prototype basically means delegation of failed lookups.

Advertisements
Standard