Sabrina Rispin
sabrinarC
Python
Calendar With Blogs and Submissions
Intro
Craftsmanship is all about developing pride in your work. It sounds silly, but I feel that sums up all of its componenets. Creating readable, well commented code so that you can share easily with others, testing it thoroughly to ensure its correctness and creating code that does its intended task. I take pride in what I have acomplished throughout this course, even more so as the tasks got harder. Harder to write, harder to test, harder to keep clean and nice. I feel that I have a better understanding of what craftsmanship is, and have a new found respect for debugging and testing. Having started this course with programming experience it wasn't long before I learned I was doing it wrong (no tests, no breaking up into functions no comments etc). I hope that with these newly acquired skills I can write better and better code in the future.
All Claims
1. Correct C code that follows the style guide (activities)
2. Clear and correct C code for all assignments
3. My contribution to the project
5. Reflections on my craftsmanship
8. Extended quality outside of C code
1. Clear and correct code to all programming activities
Claim: All code that I have submitted complies with the C style guide and is correct.
Summary: I have completed all of the activities before the deadline every single week with correct and stylish code .
Evidence:
- Link to my Current Progress Page - This lists all of my activity submissions showing that I have 100% completion of all activities.
- My Calendar - This link shows all of the activities I have completed and their submissions
Activities:
- Below is one activity from every module showing my style guide complient code (Submission, code if can't be seen from submission)
- Module 0 - no C code yet but here is my 4003 subtract
- Module 1 - Danish Flag, code
- Module 2 - Sort 3 Numbers, code
- Module 3 - C Wonderous, code
- Module 4 - Simple Encoder, code
- Module 5 - Chess Board, code
- Module 6 - Reverse a string, code
- Module 7 - testGame.c first Submission, code (no more individual activities, but the functions I wrote are named)
- Module 8 - Game.c first Submission, code
- Module 9 - no activites
- Module 10 - no activites
Example (reverse.c):
// by Sabrina Rispin // Activity Section: 6 // Date: 18/4/15 // Description: the function reverse takes in a pointer and returns a // pointer to a string that is the reverse of the string taken in. #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> char *reverse (char *message); void testReverse (void); int main (int argc, char * argv[]) { //testReverse (); return EXIT_SUCCESS; } char *reverse (char *message) { assert (sizeof (message) != 0); // sets aside memory for the new pointer with length of message char *buffer = malloc ((strlen (message) + 1) * sizeof (char)); // clear the memory int count = 0; while (count <= strlen (message)) { buffer[count] = '\0'; count++; } // for each char in message store them in buffer going backwards int counter = 0; while (counter < strlen (message)) { buffer[strlen (message) - 1 - counter] = message[counter]; //printf ("%c\n", message[counter]); //printf ("%c\n", buffer[strlen (message) - counter - 1]); counter++; } printf ("%s\n", buffer); message = buffer; //free (buffer); return message; } void testReverse (void) { char *pointer = "tree"; printf ("%s\n", pointer); printf ("%s\n", reverse (pointer)); pointer = "abcdefghijklm"; printf ("%s\n", pointer); printf ("%s\n", reverse (pointer)); pointer = "1234aBcD"; printf ("%s\n", pointer); printf ("%s\n", reverse (pointer)); pointer = "treesAreGreen"; printf ("%s\n", pointer); printf ("%s\n", reverse (pointer)); pointer = "right"; printf ("%s\n", pointer); printf ("%s\n", reverse (pointer)); }
2. Clear and Correct code submitted for assignments
Claim: For every assignment I have submitted clear and correct code
Summary: All of my submissions have been according the the style guide and are also well commented to increase clarity.
Evidence:
All of the major assignments (latest submission) have correct code:
- Task 1 - Doomsday, code, blog, 2 submissions
- Task 2 - Mandelbrot, mandelbrot.c, pixelColor.c, blogs (0, 1, 2, 3, 4, 5), 1 submission
- Task 3 - testGame.c, code, struct _game, code, Game.c, code, runGame(), code
- Task 3.1 - Mr Pass, code, mechanicalTurk.c, code
Example (2 of my functions from Game.c):
// Function 1 - newGame Game newGame (int discipline[], int dice[]) { // malloc memory in the heap for game struct with ptr Game Game g = malloc (sizeof (struct _game)); assert (g != NULL); // check that the memory was correctly malloced and got the ptr // set the disciplines array int count = 0; while (count < NUM_TILES) { g->disciplines[count] = discipline[count]; count++; } // set the dice array count = 0; while (count < NUM_TILES) { g->dice[count] = dice[count]; count++; } // set the vertexes array from the #define above vertex boardVertexes[NUM_VERTEXES] = VERTEXES; count = 0; while (count < NUM_VERTEXES) { g->boardVertexes[count] = boardVertexes[count]; count++; } // using the defined indexes to the vertexes set up the array of // ptrs for each arc int boardARCsIndex[NUM_ARCS][NUM_VERT_ARC] = ARCS_INDEXES; count = 0; while (count < NUM_ARCS) { int startIndex = boardARCsIndex[count][0]; int endIndex = boardARCsIndex[count][1]; vertex *start = &g->boardVertexes[startIndex]; vertex *end = &g->boardVertexes[endIndex]; arc a = {start, end, VACANT_ARC}; g->boardARCs[count] = a; count++; } // do the above for the tiles int boardTilesIndex[NUM_TILES][NUM_VERT_TILE] = TILES_INDEXES; count = 0; while (count < NUM_TILES) { int ind1 = boardTilesIndex[count][0]; int ind2 = boardTilesIndex[count][1]; int ind3 = boardTilesIndex[count][2]; int ind4 = boardTilesIndex[count][3]; int ind5 = boardTilesIndex[count][4]; int ind6 = boardTilesIndex[count][5]; //printf ("%d, %d, %d, %d, %d, %d\n", ind1, ind2, ind3, ind4, // ind5, ind6); tile t = {{&g->boardVertexes[ind1], &g->boardVertexes[ind2], &g->boardVertexes[ind3], &g->boardVertexes[ind4], &g->boardVertexes[ind5], &g->boardVertexes[ind6]}, g->dice[count], g->disciplines[count]}; g->boardTiles[count] = t; count++; } // setup game variables g->turnNumber = -1; g->mostPubPlayer = NO_ONE; g->mostARCsPlayer = NO_ONE; // setup players - note the player name will be the index of the // player in the players array contained in Game. // number of each student the player has - index corresponds to type /* typedef struct _player { int KPI; int numOfCampuses; int numGO8; int numARCGrants; int numOfPatents; int numOfPapers; int students[NUM_STUDENTS]; } player; */ player setup = {20, 2, 0, 0, 0, 0, {0, 3, 3, 1, 1, 1}}; count = 0; while (count < NUM_PLAYERS) { g->players[count] = setup; count++; } return g; } // Function 2 - pathToVertex // pathToVertex takes in a string of type path composed of L, B and R. // It then converts that into a vertex through a series of calculations. // This resultant vertex is compared with the vertexes on the board. // If this vertex is found in the boardVertexes then the pointer to that // vertex is returned. // // Note: if at any point the vertex calculated is not on the board then // a null pointer is returned (hence the path was not valid). static vertex *pathToVertex (Game g, path p) { int validPath = TRUE; // Takes the start vertex coord 5, 0 and index 0 in boardVertexes vertex v = g->boardVertexes[0]; // This is the change in x and y that must occur to go... // Left Right Back // x y x y x y direction change = {{1, 0}, {-1, -1}, {-1, 1}}; int count = 0; while (count < strlen (p)) { // current place in the string path char currentChar = p[count]; // printf used for debugging to show each step and direction // change along a path. /* printf ("(%d, %d)\n", v.xPos, v.yPos); printf ("L: %d %d, R: : %d %d, B: %d %d\n", change.L.x, change.L.y, change.R.x, change.R.y, change.B.x, change.B.y); printf ("%c\n", currentChar); */ // sees what direction the path is going, applies the correct // operation and the changes the orientation by changing the // L R and B operations. if (currentChar == 'B') { v.xPos += change.B.x; v.yPos += change.B.y; change = changeDirection (change, 'B'); } else if (currentChar == 'L') { v.xPos += change.L.x; v.yPos += change.L.y; change = changeDirection (change, 'L'); } else if (currentChar == 'R') { v.xPos += change.R.x; v.yPos += change.R.y; change = changeDirection (change, 'R'); } else { // char is not a valid part of a path validPath = FALSE; } // checks that the vertex lies on the board by finding its index // in boardVertexes. If it cannot be found NO_VERTEX == -1 is // returned instead. if (vertexIndex (g, v) == NO_VERTEX) { validPath = FALSE; printf ("%d %d\n", v.xPos, v.yPos); } count++; } vertex *vPtr = &g->boardVertexes[vertexIndex (g, v)]; // if any vertex along the path was not on the board then return // null -> this allows pathToVertex to test for valid paths. if (!validPath) { vPtr = NULL; } return vPtr; }
3. Contribution to the project with correct code
Summary: I have written many test functions as well as functions in Game.c, debugged my own code as well as others, created functions for the sole purpose of fixing the game and create new necessary functions for the running of Game.c.
Evidence:
- Here is our excel spreadsheet as of 6 Jun with what functions each person did and when, outlining my specific contributions and each function I completed
- Blogged about by our "keeper on tracker" here
- 2 of the functions I wrote are in the example above, but here are 2 more
// Function 1 - getWhoseTurn // return the player id of the player whose turn it is // the result of this function is NO_ONE during Terra Nullis int getWhoseTurn (Game g) { int turnNumber = g->turnNumber; int whoseTurn; if (turnNumber == -1) { whoseTurn = NO_ONE; } else { whoseTurn = turnNumber % NUM_UNIS + 1; } return whoseTurn; } // Function 2 - vertexIndex // This function takes in a vertex and searches the boardVertexes array // for it. Once found it returns a pointer to that vertex (the vertex // from boardVertexes). If no match is found it will return an invalid // index i.e. -1 (aka NO_VERTEX). static int vertexIndex (Game g, vertex v) { int count = 0; int vertexIndex = NO_VERTEX; while (count < NUM_VERTEXES) { // take the vertex at index count to compare to v vertex test = g->boardVertexes[count]; // compare the vertexes - if the same save the index if (v.xPos == test.xPos && v.yPos == test.yPos) { vertexIndex = count; // this ends the while loop - job done! count = NUM_VERTEXES; } count++; } return vertexIndex; }
- My role in the team was Code Quality manager as well as the Rule keeper, below are some blogs regarding that role
- 8 Reflection - team delegation, code quality management and Game.c contribution
- Link to group page
- Game cleaning
- Game debugging (pathToVertex) using my printGame function
- Becoming the Game.c compiler, putting everyones functions together and making sure Game.c compiled before submission
- Finding causes of failures during Game/testGame simulations
- Blogs by me and others that outline my contribution
- blogs by me regarding The Game - (Playing the game, testGame, 7 Reflection, more testGame, Game cleaning, Lab teamwork, printGame and Amelia teamwork, 8 Reflection team delegation, Game completion, Game results, team gratitude)
- blogs by others - (Comp Lab 29/4, First Group meeting 3/5, Comp Lab 6/5, Group Meeting 13/5, Working with Amelia 17/5)
- blogs by me regarding mechanicalTurk - (Mr Pass, my work on mechanical turk, mech turk more)
4. Commitment to Testing
Claim: I have commited to testing most of my submissions for both individual and team work
Summary: Added many tests to testGame, had testing in most of my activities
Evidence:
Some activities with tests include (but are not limited to)
- Module 2 - Doomsday Assignment doomsdaytests.c (open learning tests + my own), my contribution to open learning tests blog
// Openlearning unit tests + extra void testPrint(int testGroup) { printf("Group %d has passed - You are awesome!\n",testGroup); } void runUnitTests (void) { printf ("Testing group 1: Doomsday's\n"); assert (dayOfWeek (THURSDAY, FALSE, 4, 4) == THURSDAY); assert (dayOfWeek (FRIDAY, FALSE, 6, 6) == FRIDAY); assert (dayOfWeek (MONDAY, FALSE, 8, 8) == MONDAY); assert (dayOfWeek (WEDNESDAY, FALSE, 10, 10) == WEDNESDAY); assert (dayOfWeek (FRIDAY, FALSE, 12, 12) == FRIDAY); assert (dayOfWeek (THURSDAY, FALSE, 9, 5) == THURSDAY); assert (dayOfWeek (FRIDAY, FALSE, 5, 9) == FRIDAY); assert (dayOfWeek (SUNDAY, FALSE, 7, 11) == SUNDAY); assert (dayOfWeek (TUESDAY, FALSE, 11, 7) == TUESDAY); assert (dayOfWeek (WEDNESDAY, FALSE, 3, 7) == WEDNESDAY); testPrint (1); //JANUARY leap year testing printf ("Testing January Leap Year\n"); assert (dayOfWeek (MONDAY, FALSE, 1, 1) == SATURDAY); assert (dayOfWeek (MONDAY, FALSE, 1, 29) == SATURDAY); assert (dayOfWeek (MONDAY, FALSE, 1, 31) == MONDAY); assert (dayOfWeek (WEDNESDAY, TRUE, 1, 1) == SUNDAY); assert (dayOfWeek (WEDNESDAY, TRUE, 1, 29) == SUNDAY); assert (dayOfWeek (WEDNESDAY, TRUE, 1, 31) == TUESDAY); testPrint (2); //FEBRUARY leap year testing printf ("Testing February Leap Year\n"); assert (dayOfWeek (MONDAY, FALSE, 2, 1) == TUESDAY); assert (dayOfWeek (MONDAY, FALSE, 2, 28) == MONDAY); assert (dayOfWeek (TUESDAY, TRUE, 2, 1) == TUESDAY); assert (dayOfWeek (TUESDAY, TRUE, 2, 28) == MONDAY); assert (dayOfWeek (TUESDAY, TRUE, 2, 29) == TUESDAY); testPrint (3); // Test cases further than one week behind doomsday printf("Testing > 1 week before Doomsday\n"); assert (dayOfWeek (SATURDAY, FALSE, 12, 1) == TUESDAY); assert (dayOfWeek (SATURDAY, FALSE, 10, 1) == THURSDAY); testPrint (4); // Test one week ahead printf("Testing > 1 week after Doomsday\n"); assert (dayOfWeek (FRIDAY, FALSE, 6, 30) == MONDAY); assert (dayOfWeek (FRIDAY, FALSE, 6, 13) == FRIDAY); testPrint (5); // First day of each month printf("Testing first day of each month\n"); assert (dayOfWeek (MONDAY, FALSE, 1, 1) == SATURDAY); assert (dayOfWeek (MONDAY, FALSE, 2, 1) == TUESDAY); assert (dayOfWeek (MONDAY, FALSE, 3, 1) == TUESDAY); assert (dayOfWeek (MONDAY, FALSE, 4, 1) == FRIDAY); assert (dayOfWeek (MONDAY, FALSE, 5, 1) == SUNDAY); assert (dayOfWeek (MONDAY, FALSE, 6, 1) == WEDNESDAY); assert (dayOfWeek (MONDAY, FALSE, 7, 1) == FRIDAY); assert (dayOfWeek (MONDAY, FALSE, 8, 1) == MONDAY); assert (dayOfWeek (MONDAY, FALSE, 9, 1) == THURSDAY); assert (dayOfWeek (MONDAY, FALSE, 10, 1) == SATURDAY); assert (dayOfWeek (MONDAY, FALSE, 11, 1) == TUESDAY); assert (dayOfWeek (MONDAY, FALSE, 12, 1) == THURSDAY); assert (dayOfWeek (MONDAY, TRUE, 1, 1) == FRIDAY); assert (dayOfWeek (MONDAY, TRUE, 2, 1) == MONDAY); testPrint (6); // Last day of each month printf("Testing last day of each month\n"); assert (dayOfWeek (MONDAY, FALSE, 1, 31) == MONDAY); assert (dayOfWeek (MONDAY, FALSE, 2, 28) == MONDAY); assert (dayOfWeek (MONDAY, FALSE, 3, 31) == THURSDAY); assert (dayOfWeek (MONDAY, FALSE, 4, 30) == SATURDAY); assert (dayOfWeek (MONDAY, FALSE, 5, 31) == TUESDAY); assert (dayOfWeek (MONDAY, FALSE, 6, 30) == THURSDAY); assert (dayOfWeek (MONDAY, FALSE, 7, 31) == SUNDAY); assert (dayOfWeek (MONDAY, FALSE, 8, 31) == WEDNESDAY); assert (dayOfWeek (MONDAY, FALSE, 9, 30) == FRIDAY); assert (dayOfWeek (MONDAY, FALSE, 10, 31) == MONDAY); assert (dayOfWeek (MONDAY, FALSE, 11, 30) == WEDNESDAY); assert (dayOfWeek (MONDAY, FALSE, 12, 31) == SATURDAY); assert (dayOfWeek (MONDAY, TRUE, 1, 31) == SUNDAY); assert (dayOfWeek (MONDAY, TRUE, 2, 29) == MONDAY); testPrint (7); //One day before doomsday printf("Testing one day before doomsday of each relevant month\n"); assert (dayOfWeek (THURSDAY, TRUE, 2, 28) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 2, 27) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 4, 3) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 5, 8) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 6, 5) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 7, 10) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 8, 7) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 9, 4) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 10, 9) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 11, 6) == WEDNESDAY); assert (dayOfWeek (THURSDAY, FALSE, 12, 11) == WEDNESDAY); testPrint (8); //just a test printf("Just a test.\n"); assert (dayOfWeek (FRIDAY, FALSE, 11, 9) == SUNDAY); testPrint (9); //Test Christmas Day and Boxing Day assert (dayOfWeek (SATURDAY, FALSE, 12, 25) == FRIDAY); assert (dayOfWeek (SATURDAY, FALSE, 12, 26) == SATURDAY); // Test Pi Day assert (dayOfWeek (TUESDAY, FALSE, 3, 14) == TUESDAY); testPrint(10); //Group 12: Test for Unexpected Inputs assert (dayOfWeek (THURSDAY, FALSE, -1, 31) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (THURSDAY, FALSE, 1, 31) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (THURSDAY, FALSE, 2, 29) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (THURSDAY, FALSE, 13, 46) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (7, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (8, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (9, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (-1, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (-2, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); assert (dayOfWeek (-3, FALSE, 2, 4) != MONDAY || TUESDAY || WEDNESDAY || THURSDAY || FRIDAY || SATURDAY || SUNDAY); testPrint(11); //Test for every 3rd of Ludvig A. Løddesøls birthdays assert (dayOfWeek (MONDAY, TRUE, 3, 12) == SATURDAY); assert (dayOfWeek (FRIDAY, FALSE, 3, 12) == WEDNESDAY); assert (dayOfWeek (TUESDAY, TRUE, 3, 12) == SUNDAY); assert (dayOfWeek (FRIDAY, FALSE, 3, 12) == WEDNESDAY); assert (dayOfWeek (TUESDAY, FALSE, 3, 12) == SUNDAY); assert (dayOfWeek (SATURDAY, FALSE, 3, 12) == THURSDAY); assert (dayOfWeek (WEDNESDAY, FALSE, 3, 12) == MONDAY); assert (dayOfWeek (SATURDAY, FALSE, 3, 12) == THURSDAY); testPrint(12); assert(dayOfWeek(FRIDAY,FALSE,1,8)==WEDNESDAY); assert(dayOfWeek(THURSDAY,FALSE,1,8)==TUESDAY); assert(dayOfWeek(WEDNESDAY,FALSE,1,8)==MONDAY); assert(dayOfWeek(MONDAY,FALSE,1,8)==SATURDAY); assert(dayOfWeek(SUNDAY,FALSE,1,8)==FRIDAY); assert(dayOfWeek(SATURDAY,FALSE,1,8)==THURSDAY); testPrint(13); // Test for my birthday last 10 years assert (dayOfWeek (SATURDAY, FALSE, 11, 18) == WEDNESDAY); assert (dayOfWeek (FRIDAY, FALSE, 11, 18) == TUESDAY); assert (dayOfWeek (THURSDAY, FALSE, 11, 18) == MONDAY); assert (dayOfWeek (WEDNESDAY, TRUE, 11, 18) == SUNDAY ); assert (dayOfWeek (MONDAY, FALSE, 11, 18) == FRIDAY ); assert (dayOfWeek (SUNDAY, FALSE, 11, 18) == THURSDAY); assert (dayOfWeek (SATURDAY, FALSE, 11, 18) == WEDNESDAY ); assert (dayOfWeek (FRIDAY, TRUE, 11, 18) == TUESDAY); assert (dayOfWeek (WEDNESDAY, FALSE, 11, 18) == SUNDAY); assert (dayOfWeek (TUESDAY, FALSE, 11, 18) == SATURDAY); testPrint(14); // Test 1st of Jan on some special year assert (dayOfWeek (TUESDAY, TRUE, 1, 1) == SATURDAY); // year 2000 assert (dayOfWeek (WEDNESDAY, FALSE, 1, 1) == MONDAY); // year 1900 testPrint(15); } void testConstants (void) { // Are the days their assumed values assert(THURSDAY == 0); assert(FRIDAY == 1); assert(SATURDAY == 2); assert(SUNDAY == 3); assert(MONDAY == 4); assert(TUESDAY == 5); assert(WEDNESDAY == 6); // DAYS_PER_WEEK is the number of days above assert(DAYS_PER_WEEK == 7); // Basic logic check for TRUE FALSE assert(TRUE != FALSE); printf("\nAll constants are correctly defined.\n"); }
- Module 4 - simpleEncode.c
- Module 6 - reverse.c, reverse blog
- Module 7 - testGame.c contribution
- Using round results and tests to fix functions in Game.c
- And almost any other activity involved testing - see my wonderous 8005 blog about testing with microprocessors
5. Additional Evidence
Claim: I have continually reflected on my craftsmanship throughout the course
Summary: My weekly reflections would often include sections reflecting on my craftsmanship throughout the course
Evidence:
- (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) Module Reflections that have an emphasis on craftsmanship are bolded and underlined
Claim: I have helped others improve their craftsmanship
Summary: In both my team projects I would help others understand the problem and pair program with them to write their code
Evidence:
- Collabedit with Amelia
- Game Completion - helping everyone to add their functions!
- helping others with their functions - see the second half of the blog
Claim: I have developed my debugging skills over time
Summary: Debugging is hard, especially with the 8005 task which I use as my evidence for debugging (when debugging is the most difficult).
Evidence:
- wonderous 8005 blog
- half() 8005 blog
- Going through the round results - I also went through the testGame/Game results and would use that information to find the problem functions to fix them