Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Gearing up for the stretch run CSCI 21, Spring 2013.

Similar presentations


Presentation on theme: " Gearing up for the stretch run CSCI 21, Spring 2013."— Presentation transcript:

1  Gearing up for the stretch run CSCI 21, Spring 2013

2 Some tips  Search for answers on Google  Watch YouTube videos  Find a student or students in the class who are doing well and put together a study group  Do not leave lab hours when you finish your programming challenge – stay around and get help on your projects  Take advantage of the instructor’s office hours and (priority answers are given to those who attend ALL of our lecture and lab meeting hours)

3 Some tips (cont.)  Read the book before coming to class  be prepared to ask questions in class  Attempt the programming challenge before coming to class  be prepared to ask questions in class  We all know this is a very difficult class, and it requires a lot of hard work on your part – unfortunately, there is no easier way to learn this stuff  minimum (‘C’ effort) time spent each week outside of class: 6 hours

4 More tips  Read each project carefully as soon as it is posted – ask for clarification in lecture, lab,by , or in office hours when needed  Start your project early (as soon as it is posted)  Try and keep your code in a compiling state constantly  Strive to do more than the bare minimum – ‘C’ students do the bare minimum

5 Makefile  always named Makefile  not makefile, or makefile.txt, or anything else  always do the following  have a target to link the executable  have a target to compile each class separately  have a target to compile the driver separately  have a target to clean (rm/del *.o)  have a target to cleanall (rm/del *.o and.exe)

6 Makefile (cont.)  What does a Makefile do?  runs a series of compiler/linker commands for you  make  allows you to specify a single target and only run that single command  make target  What is a target?  one compiler or linker command

7 Makefile (cont.)  example: a program that only has a single source file source file: myprogram.cpp Makefile: myprogram.exe: myprogram.o g++ -o myprogram.exe myprogram.o myprogram.o: myprogram.cpp g++ -c myprogram.cpp

8 Makefile (cont.)  example: a program that only has a single source file  make  executes the topmost target and all of its dependencies  typing make on the Makefile on the last slide would cause the following to happen:  topmost target: myprogram.exe (executes second)  dependency: myprogram.o (executes first)  result: if no compiler/linker errors, will create myprogram.o and then myprogram.exe

9 Makefile (cont.)  example: a program that only has a single source file  make myprogram.o  only executes the command associated with the target myprogram.o

10 Makefile (cont.)  example: a program that has several source files source file: myprogram.cpp, myclass.cpp, myhelper.cpp, myclass.h, myhelper.h Makefile: myprogram.exe: myprogram.o myclass.o myhelper.o g++ -o myprogram.exe myprogram.o myclass.o myhelper.o myprogram.o: myprogram.cpp g++ -c myprogram.cpp myclass.o: myclass.cpp g++ -c myclass.cpp myhelper.o: myhelper.cpp g++ -c myhelper.cpp

11 Makefile (cont.)  example: a program that has several source files  now you can type any of the following make commands:  make (topmost target and all of its dependencies)  make myprogram.o  make myclass.o  make myhelper.o

12 Makefile (cont.)  add clean and cleanall targets to your Makefile Windows clean: cmd /C del *.o cleanall: clean cmd /C del myprogram.exe

13 Makefile (cont.)  add clean and cleanall targets to your Makefile Mac/Linux clean: rm –f *.o cleanall: clean rm -f myprogram.exe

14 Makefile -- exercise  Create a Makefile to compile the following source files and build an executable that links them all together:  executable: project3.exe  source files:  project3.cpp  DLNode.cpp, DLNode.h  DLList.cpp, DLList.h  clean and cleanall targets

15 Project 3  Hopefully you have read the Project 3 specs, which were posted on Wednesday evening, March 27  The spec is complex, so will require your careful attention  Questions or any points of clarification?

16 Project 3 – getting started  How do I start Project 3 when I do not know how to code a linked list?  First Iteration  stub out the classes and driver  create a Makefile  make  Second Iteration  stub out the functions in the DLNode class  make

17 Project 3 – getting started (cont.)  Third Iteration  stub out the functions in the DLList class  make  Fourth Iteration and on…  implement a function in DLNode or DLList (complete DLNode before moving on to DLList)  make  implement a test of the function in your driver  make  run the executable to view the test output

18 Project 3 – getting started (cont.)  Final Iterations  after all of the functions have been implemented and tested, clear out your driver and begin implementing the driver as needed for the final project  do it in steps – one small part of the driver functionality, make, run executable  When you think you have everything in place  test with many, many input files – do your best to break your program before you have to submit it

19 Linked lists  What is a linked list?  a data structure  what is a data structure?  a dynamic data structure  grows and shrinks as you add/remove data  dynamic: think dynamic memory  dynamic memory: think pointers  built by linking nodes

20 Linked lists (cont.)  What is a node?  a container for a piece of data and one or more links (pointers) to other nodes  linked lists are built dynamically by creating nodes, storing the desired data in the nodes, and then linking the nodes together

21 Linked lists (cont.)  Note how the nodes are linked together – this is a linked list  Conceptually, a node looks like this

22 Linked lists (cont.)  What does a node look like in code? class Node { private: // data type depends on what you //want to store in your list int data; // link to next node Node* next; };

23 Linked lists (cont.)  This picture looks like a bunch of nodes – where is the list?  The linked list is just the algorithms that are used to add, retrieve, update, and delete the nodes, plus some tracking sentinels that keep track of where the first node is – see Start above?


Download ppt " Gearing up for the stretch run CSCI 21, Spring 2013."

Similar presentations


Ads by Google