Homework 1: grade report

·        Annoyance: you will lose points, will bother everyone, PLEASE HELP ME!

o   Submission:

§  Inclusion of useless files: e.g., *.sdf

§  IDE cannot compile! Try it!!

§  Forget the cover page, well, please don't!

§  Please do not submit code you did not write (i.e., ImageLib.h)

o   Help with my grading/testing scripts:

§  .zip submission (not rar, not 7z, simple zip, please!)

§  Do not SUBMIT any .exe files!!

·        Not exe to my solution, not exe that reads "Program_1_Just_To_Prove_This_Compiles.exe"

§  Extra stuff you have done: put in your code comments, I will try to find them

·        Please follow the assignment's input and output requirements!

 

·        Serious errors: (typically -5%)

o   Memory leak, either:

§  CopyImage() in loop without Deallocation

§  ReadImage() in loop without Deallocation

§  Try run your program 100 times by entering 100 different skipping numbers, you will run out of memory!

o   Not De-allocating the one input original image: -3%

o   Missing invert regions by one-line (counting starting from 0 to n-1, or 1 to n-1, or 0 to n, etc.).

o   Crash

§  when skilNumber > image.row size

§  1x1, 1xn, nx1 image

§  When file name is invalid

·        Coding Style:

o   #define: when to use, guide: only for pre-processor, nothing to do with the actual code logic

§  #define OutFileName "MyFile.jpg"  ßgood idea (constant), bad implementation: no data type!

§  const string kOutFileName = "MyFile.jpg";  ß data type included! And notice the "const"!

o   Use of: break/continue:

§  Variation of "go to". Personally I avoid use these in any of my code

o   If you copy/paste source code, STOP and think:

§  Why are you not defining/calling a function?

§  Later on: why are you not subclassing?

o   Working with bool:

// Normal

int b, c;

bool a = (b > c);

if (a) cout << "yes";

 

    // vs.

// Strange and awkward.

if (b > c)

        a = true;

    else

        a = false;

    if (a == true)

        cout << "yes";

 

o   Loop types: Kelvin says, unless there are unusual conditions, non-existing loop termination condition is a bad thing! (e.g., empty for() condition checking, or while(true)):

// GOOD

do {

                // do work

           } while (a);

 

// vs.

 

// EVIL: in Kelvin's book

for (;;) {

           if (a) break;

                // do work

           }

 

o   Function: when does it get excessive?

§  E.g., one line function. Especially when the line is not complicated, and the name does not convey any information

§  E.g., Define a GetImage(string filename) function to call ReadImage().

·        Simple care/style:

o   File comments:

§  Name, date, filename, purpose, credits (to others), purpose (e.g., for HW1)

o   Pre-condition: what this means?

§  Valid image, valid filename, etc. How can your function crash if the user wants to crash it?

o   Use functions to make your code more readable!

o   Indentation

o   Wrap-around lines: -1% for each line that I can find!

o   Color hardcopies: not required. But thank you!!

·        IDE Setting:

o   Tabs vs spaces:

o   IDE: ToolsàOptions: Open TextEditor tab

§  All languages: Display line number

§  BasicsàTabls:

·        Indenting: Smart

·        Tab: size/indent size: set to 4

·        Insert Spaces: selected (DO NOT want any tabs in code)

·        Let's talk destructor

o   Example 1: Simple destructor

§  Remember: the number of copies we need to do!

o   Example 2: Class with dynamic allocations!