Skip to content

Instantly share code, notes, and snippets.

Hey everybody --

I just wanted to send out a few notes about homework. I saw some common issues while grading, and wanted to give some reminders, tips, and tricks which I think are going to be pretty useful for your upcoming homework assignment.

Commenting

When commenting method headers, make sure you always do the following:

  1. Describe what the method does (without describing what the code does)
  2. Describe what every parameter does
--------- beginning of /dev/log/main
D/skia ( 1225): purging 197K from font cache [27 entries]
W/PowerManagerService( 2474): Timer 0x7->0x3|0x0
V/WindowManager( 2474): Dsptch > Window{4817ffb8 mobi.mgeek.TunnyBrowser/mobi.mgeek.TunnyBrowser.BrowserActivity paused=false}
D/dalvikvm( 1860): GC_FOR_MALLOC freed 4008 objects / 531920 bytes in 27ms
This file has been truncated, but you can view the full file.
========================================================
== dumpstate: 2013-01-13 19:41:29
========================================================
Build: FROYO.UCKB1
@Michael0x2a
Michael0x2a / gist:182ec57bfe5e72a487eb
Last active August 29, 2015 14:02
CSE 142: BankAccount

Well, first off, the problem states that our method should accept a second BankAccount, not a String. So, our method header will look like:

public void transfer(BankAccount other, double amount)

I think this was the main thing you were stuck with -- getting the correct type signature. Apart from that, it looks like you were on the right track.

Then, we can get to the business of writing the code. If the balance in the current bank account is too small, we'll just terminate early:

Feedback: July 27, 2014

For reference, here is your original code:

#!/usr/bin/env python

def encrypt (raw_string, shift):
    encrypted_string = ""
    for letter in raw_string:
@Michael0x2a
Michael0x2a / gist:da6a731a8da375b75077
Created July 10, 2014 05:30
Feedback: July 9, 2014

July 9, 2014

Introduction

The primary lesson I want to go over today is [separation of concerns][soc].

When coding, there are often many different tasks or components that make up the entire program. For example, gathering user input, displaying data, running algorithms, and storing data are all examples of different "tasks" or "concerns".

One problem many beginning coders have is a tendency to "blur" these concerns together, and end up writing functions that try and do too many things at once.

@Michael0x2a
Michael0x2a / math-308-midterm-1-review.ipynb
Created October 16, 2014 06:29
Math 308 Midterm 1 Review
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Michael0x2a
Michael0x2a / braces.clj
Created December 7, 2014 00:40
Clojure: is string balanced?
; Given a N different open and close braces in a string ""( { [ } ] )"".
; Write a program to check to see if the braces in the string are balanced.
(ns braces
(:require [clojure.string :as str]))
(def braces #{\( \) \[ \] \{ \}})
(def pairs { \) \(,
\] \[,
@Michael0x2a
Michael0x2a / SortTwoQueues.java
Created January 27, 2015 21:06
A short program that takes two queues and sorts them without using any auxiliary data structures
// Michael Lee
// January 27, 2015
// Section BP
//
// This file takes two queues with numbers in random order and sorts them.
import java.util.*;
public class SortTwoQueues {
// The main starting point of the program.
@Michael0x2a
Michael0x2a / SortTwoQueuesV2.java
Created January 27, 2015 21:10
A short program that takes two queues and sorts them without using any auxiliary data structures.
// Michael Lee
// January 27, 2015
// Section BP
//
// This file takes two queues with numbers in random order and sorts them.
import java.util.*;
public class SortTwoQueuesV2 {
// The main starting point of the program.