Journey‎ > ‎Regis University‎ > ‎

MCT 609 Fundamentals of Programming

C++

Overview

In this elective course we researched best practice in programming while working each week to document and develop our own program in the C language using Microsoft Visual Studio. I learned the basics of the C language and also created programs that would do everything from solve basic math to read and write binary data to external files.

Reflection

Wow what a program. I’m pretty proud of what I’ve accomplished (over 700 lines of code in a week) although not every feature I envisioned made it into my submission.

Everything in the main program works such as viewing records, writing records, modifying records, and deleting records. I spent a lot of time working on creating a user interface that was easy to read and understand. I’m really pleased with how the files are open, written to, and close while the program is running. This is possible because of using binary reading and writing and has a few clear advantages over sequential access. I like how if my user enters a new rock account, that the account is immediately created, preventing any data loss if the program for some reason crashed. If my program held the data the entire time, waiting to write the data at exit, all that data could potentially be lost say if my battery died in my laptop.

I felt that my initial attempt helped me a lot as I was writing my pseudocode. I tried to make the code as close as possible to the code that I would enter into my program for a couple reasons. First I wanted to take my pseudocode, cut it, and paste it directly into my compiler one function at a time. This saved me a ton of time than when I first started programming where I was trying to constantly go back and translate my pseudocode into actual code.

One feature my program has is multiple menus inside the program. What I mean is that there’s a main menu, but when a user wants to update a record, they can select what part of the record to update using the switch case menu I built.

If I had more time I would add the following features:

-        Error checking for issues like if a user enters a character  when a int should be entered

-        Functions that actually sort the data and keep track of stats

-        A function so users can modify venue data

-        All users to enter “spaces” in venue names and cities instead of NewYork.

-        Allow users to create files if none exist or open existing files

-        Allocate memory dynamically

My functions worked out well in my head when I was writing my pseudocode but didn’t work so well in my program. I had two functions I wanted to build but spent most of my time on my sort function and not a lot of time on my stat function. I’m not entirely sure why my sort function won’t work. My first major problem was getting my program to copy all data from my rockPtr file to my tempPtr file. I wanted the data sorted in the temp file, then displayed, but none of the actual data in the rockfile to actually be changed. I feared that an error could destroy the data in the main file which is why using the temp file was a good option. I couldn’t get this to work so I went ahead and copied the data manually (by opening each file in Notepad and copy/pasting the data). When I ran the function on my temp file I debugged where the reading/swapping occurred. Basically using strcmp the program looks at the two band names. If a band name was larger (alphabetically) than the second one, the program would write the smaller record then the larger record using fwrite. As I monitored the compares the program did everything it was supposed when comparing strings however, my while (!feof) never would  reach the end of the file and it would infinitely loop, comparing, and writing the records. I simply ran out of time to troubleshoot this so I would love some feedback if I was going in the right direction and how to fix this.

Dynamic memory never got much attention as this program took every waking moment and I was more concerned about getting everything working for submission.

Overall a very time consuming, but fun final. It truly makes me appreciate the work that goes into programs like the one I’m using right now to type this reflection. Although my major isn’t programming this experience will better help me understand the devices I use daily and give me a little control of the ones that allow for code manipulation.

Artifacts

Artifacts

Below you'll find documentation of all the programs I created. Each program varies in complication and documentation. My two favorite projects are Global Rock Event Tracker and the 'Ed' sort programs.

The Global Rock Event Tracker used two binary files that allowed the user to enter and store information about rock bands and venues. A manager thus could enter any new rock bands that they take on and that information would be stored in a binary file, which could be retrieved at a later time. The manager could also record when one of their bands played at a specific venue which would be written to another binary file. Thus the user could at any time search for any kind of information in the files from how many times a band performed at a specific venue or a list of all the bands that played at a specific venue.

Sort 'ed' is similar to the Global Rock Event Tracker program in that it reads ands write to a file, however, in this case I use a text file instead a binary file. With this program a user can input any amount of words into the program. These words are written to the text file, then read back into the program into an array. Using a loop the program then goes through and finds all the words containing any variation of the letters 'ed', 'Ed', 'eD', and 'ED'. Once the program has found all the words it prints that list of words to the screen.

I feel that these artifacts are some of my most challenging as I spent hours upon hours developing the code for these programs. You would think that all code would look the same but programmers really are creative artists, adding their own flair to each line of code. As I mentioned in one of my other posts, being creative was incredibly difficult for me as I was never challenged to growing up. I truly believe that programming brings out creativity in people who may not enjoy photography, painting, playing guitar, or other traditional creative fields. One day when I have my own school every student will be required to take one "creative" class a year of their choice from music, art, digital media, or programming.

List of Artifacts

Programming Projects


Creative Commons License
This work by Daniel Sharpe is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


Standards

NETS-S

6. Technology Operations and Concepts

a. Understand and use technology systems
b. Select and use applications effectively and productively
c. Troubleshoot systems and applications
d. Transfer current knowledge to learning of new technologies

Bibliography

Books

AlgoList. (2008). Quicksort. Retrieved from http://www.algolist.net/Algorithms/Sorting/Quicksort

Codemesh. (2013). Lesson 7: Strings in java and c . Retrieved from

http://codemesh.com/products/vfour/tutorial/cpp/v3/L_07_strings.html

Coding Unit. (2013). C tutorial – call by value or call by reference. Retrieved from http://www.codingunit.com/c-tutorial-call-by-value-

or-call-by-reference

Cprogramming.com. (2011). C and c for java programmers. Retrieved from http://www.cprogramming.com/java/c-and-c -for-java-

programmers.html

Roberts, F., & Roberts, D. (2013). Sorting arrays. Retrieved from http://mathbits.com/MathBits/CompSci/Arrays/Sorting.htm

Comments