W4D5: GET OUT OF MY HEAD CHARLES


A lot of my cohortmates have also noticed -- the 2 day, down, then up sprint trend.

Surely Makersquare didn't expect us to finish these ridiculous sprints without any guidance, with only the less-than-helpful videos to direct us? Surely all this is all part of their plan?

The mindgames are #real
What are you doing MKS? Why you do this?
ARE THEY DOING THIS JUST TO TORTURE US


No, Hyungki, no.

There MUST be a reason for this.

They are doing this to prepare you for the real world. We're going through a ton of these stressful  situations in the form of sprints. If we are faced with similar situations on the job, in which no one knows what the hell to do, we can take the reign because we've got this. MKS prepared us for this.

Or... it could just be MKS trolling us, and I'm just convincing myself otherwise.


What we did today:
1. Toy Problem

Tree Breadth-First Select

Implement a breadth-first method on a tree class.
BFSelect accepts a filter function, calls that function on each of the nodes in Breadth-First order, and returns a flat array of node values of the tree for which the filter returns true.
Example:
var root1 = new Tree(1);
var branch2 = root1.addChild(2);
var branch3 = root1.addChild(3);
var leaf4 = branch2.addChild(4);
var leaf5 = branch2.addChild(5);
var leaf6 = branch3.addChild(6);
var leaf7 = branch3.addChild(7);

root1.BFSelect(function (value, depth) {
  return value % 2;
}) //=> [1, 3, 5, 7]

root1.BFSelect(function (value, depth) {
  return depth === 1;
}) //=> [2, 3]
CODE TEMPLATE:
var Tree = function(value){
this.value = value;
this.children = [];
};

Tree.prototype.BFSelect = function(filter) {
var firstTime = true;
var results = [];
//Your code here

var recurse = function(node_list, depth){
if(firstTime){
firstTime = false;
if(filter(node_list.value, depth)){
results.push(node_list.value);
}
if(node_list.children){
recurse(node_list.children, depth+1);
}
}


else{
var store = [];
for(var i=0; i<node_list.length; i++){
if(filter(node_list[i].value, depth)){
results.push(node_list[i].value);
}
if(node_list[i].children){
store = store.concat(node_list[i].children);
}




}
if(store.length >0){
recurse(store, depth+1)
}
}


}


recurse(this, 0);
return results;
};

/**
* You shouldn't need to change anything below here, but feel free to look.
*/



/**
* add an immediate child
* (wrap values in Tree nodes if they're not already)
*/
Tree.prototype.addChild = function(child){
if (!child || !(child instanceof Tree)){
child = new Tree(child);
}

if(!this.isDescendant(child)){
this.children.push(child);
}else {
throw new Error('That child is already a child of this tree');
}
// return the new child node for convenience
return child;
};

/**
* check to see if the provided tree is already a child of this
* tree __or any of its sub trees__
*/
Tree.prototype.isDescendant = function(child){
if(this.children.indexOf(child) !== -1){
// `child` is an immediate child of this tree
return true;
}else{
for(var i = 0; i < this.children.length; i++){
if(this.children[i].isDescendant(child)){
// `child` is descendant of this tree
return true;
}
}
return false;
}
};

/**
* remove an immediate child
*/
Tree.prototype.removeChild = function(child){
var index = this.children.indexOf(child);
if(index !== -1){
// remove the child
this.children.splice(index,1);
}else{
throw new Error('That node is not an immediate child of this tree');
}
};


var root1 = new Tree(1);
var branch2 = root1.addChild(2);
var branch3 = root1.addChild(3);
var leaf4 = branch2.addChild(4);
var leaf5 = branch2.addChild(5);
var leaf6 = branch3.addChild(6);
var leaf7 = branch3.addChild(7);

root1.BFSelect(function (value, depth) {
return value % 2;

})
2. Reflective feedback session
I don't complain easily -- so it bothers me that with every feedback session, the volume of complaints are increasing. Most of these are legitimate complaints, but some of them are straight up baby howlings. I cringe a little inside as they go on about how their life sucks because of x and y.

One of the things I will back them up on though, are the complaints about the video lectures. The video lectures, for lack of a better word, are ass. Most of them are recordings of lectures from Hack Reactor, and they are long and stale. A good portion of each video is spent answering questions from the students, which, a lot of the times, is boring and useless information. But dang, my cohortmates were HOUNDING on the video lectures like savages... they really don't like the video lectures!

MKS, pls.

3. Lecture on Databases

3. Pair Programming on SQL + Dabases
Sprint Description: Store data persistently using the languages provided by database packages, including both traditional relational model and more recent non-relational technologies. You'll also learn to build your own ORM, a technique for shortening the gap between in-memory programs and the Database interface.

No comments:

Post a Comment