Posts

Showing posts from July, 2017

6.00.1x - Week 5

Image
5.9.1 Object Oriented Programming Object:  3 pieces: type, internal data representation, and set of procedures for interaction with the object Instance is a particular type of object. 1234 is an instace of an int, a = 'hello' is an instance of a string Data abstraction:  represent internal data (private) using attributes, interface for interacting with object through methods Advantages of OOP:  bundle data into packages, divide-and-conquer development, and ability to reuse code 5.9.2 Class Instances class Coordinate(object): class: class definition class name: Coordinate class parent: object 5.9.3 Methods def __init__(self, attr): special method (constructor) to create an instance and initialize data (optional) __str__: equivalent to toString() in other languages to print custom string for class representational invariant: enforce a particular rule by code 5.9.5 Why OOP? 5.9.6 Hierarchies 5.9.7 Class Variables 5.9.9 Generators \

6.00.1x - Week 4

Image
4.7.1 Programming Challenges Check soup for bugs = Testing Keep lid closed =  Defensive Programming Clean kitchen = Eliminate source of bugs - debugging 4.7.2 Classes of Tests Defensive programming:   write specifications for function, modularize programs, check conditions on inputs/output (assertions) Write code to support easy testing and debugging, module, document constraints, document assumptions Classes of Tests:  Unit testing, Regression testing (rerun unit tests after bug fixing), and Integration testing (multiple unit testings). read 1 How to test:  Use intuition, random testing, black box testing (use specification without looking at code), or glass box testing (use/look at code) Path-complete glass box test:  find test cases that go through every possible path in the code. Glass box Recursion test cases: test recursion depth of 0, 1, and many While/for loop: loop not executing, executing 1, and executing more than 1 4.7.3 Bugs Do 3 things: isolate it, fix it