When first starting this class, it was a handful. I did not know C++ at all. Everything we were required to do was a foreign language to me. I did not even know what an algorithm was. Apparently, an algorithm is made so that your program runs as efficiently as possible. It is a well defined set of instructions, designed to perform a task. Learning to use this was important to us as programmers. We are now using it to solve practical and real world problems. That is what lab two was all about. We had to take instructions for a real world application and provide a solution. This time it was combining labs five and six with a lot of conversions to make them work like functions, similar to the way we did the first lab.
Lab five was a practice lab designed to give us practice with the stack function. We had to read from a file and then from that file push and pop on a stack comparing the values of the ( ) [ ] { }. This also tested our ability with legality. We had never done a stack program before and I made the mistake of using the built in stack library. I then had to go back and create a stack class. This consisted of push and pop methods, a find the top item method, and a Boolean method to find out if it is empty. This helped me solve the issues and trace the bracket files that the stack library had.
Lab six was designed as a practice lab with an even more realistic real world problem. It was an application to validate HTML. This was a big challenge since the inside of what we were looking for, < * > or </ * >, was constantly changing. We had to push through, or sort, everything inside. This also changed the way I did lab five. Instead of using “if” and “else” statements, I was able to create a more concrete method that would work for both ways. It was not exact, but the idea was the same. It would find certain items and compare them by pushing all the opening tags or items to the top and then pop them off as the closing was found. If the closing wasn’t found or if the top item didn’t match the pop item, it was a failed or false result. This was a good challenge to elaborate on from lab five.
A big challenge stemming from this was how to make methods from the previous labs. It was a lot easier when all I had to worry about was one function to perform. Now I had to worry about calling up to methods as well. This made it a lot more difficult because I had to make each function into a Boolean function and then give them the ability to be called and perform the function. Then return the value to the final output and determine whether it was a legal or illegal operation. On top of all of this occurring, I then had to take into account comments and line errors. The concept of finding the error and determining the line at which it occurred was very hard to conceptualize. Eventually it made sense to me, but invoking it became harder than expected. You had to determine this while reading in the characters from the file and prior to pushing them onto the stack. This is similar to how the comment situation worked. I struggled for a while trying to figure out how in the world I would recognize a character and ignore everything until the closing, but after a few trial and errors I finally realized that you had to recognize the character prior to pushing it onto the stack, because if you waited until afterwards it would be too hard to determine at which point to stop.
So in the hope of combining these two labs into one larger lab that would act as a syntax checker, I designed the program to be very similar to lab one. The idea is when the user enters a file name, the program automatically checks the extension of the file by reverse searching the string until it hits a period. It takes the characters prior to the period and compares it in a case statement to determine whether to use HTML Balancing for .html and .htm, or C Balancing for C or C ++, or if they extension is not supported by the program. Upon determining which extension to use, assuming it is a valid one, it then calls upon a function, specific to the extension, to determine whether the file is balanced. It also has to take into account comments. If there is a comment in C or C++ (/* /) or HTML ( <!-- -->) it has to ignore the tags and everything inside of that. That was definitely a big challenge to implement in there as well because it must be done prior to the stack.
It is a very simple program from the user side. All they have to do is run the program and enter in the file name. The program does the rest of the grunt work. The program tells you whether the file is balanced, and if you do it incorrectly, it gives you an error and tells you how to use the program. It even tells you the reason that you did fail. When it is printing the legal status, it simply does just that. It prints out legal. However, when it prints illegal, it tells you the line of the error and the reason why. This is a helpful feature since sometimes identifying your error is one of the hardest aspects of coding. I know when I worked on a project I forgot to close my </object> (object tag). Only half of the website would show up in Internet Explorer. Other browsers treated it fine, but until I found the closing tag, Internet Explorer gave me a hard time and only half a page.
The hardest aspects of the project were all conceptual. The coding was actually less than 400 lines, which I consider to be reasonable. It was a lot easier to write this in Java and convert it to C ++. I am more familiar with Java, so it makes the coding process easier. The hardest part conceptually, was finding the comments and then ignoring everything in between them. I don’t have it perfect, but I am close. This is a very practical idea however, because why would they matter if you are balancing an equation. They could make a huge difference in whether it is legal or not.
The results also show how we can use our knowledge to solve real world issues. Being able to validate a file based on certain attributes can be used in many fields of study. If you were in a legal case and needed to find common attributes among a long list of people, you would be able to sort through it. The ease of use with the program really made it ideal for many applications. Since it helped you identify your error and resolve it, the program became very user friendly. If I were to add in a few of the ideas below, it would greatly enhance the user’s experience and make the application usable for a wider audience. This would be especially true if it was a GUI application. Still, it is a very impressive application for me. I never had imagined making something of this nature on my own. It is a good accomplishment and has made me want to develop it further as well as giving me the confidence to try new things. I am considering taking on a part-time programming job now.
While reflecting after any program the first thing is how can I make this better. I can actually think of a few ways this program could be more efficient and more user friendly. One obvious way is that you could make it a GUI interface rather than command line. Although it is not necessary, it would be nice since a lot of people have an easier time with visuals rather than a coding style. In a totally different light, it would be nice to make the program more developer friendly. This could be done by providing a solution automatically for an issue. This is done in a lot of IDE programs. It would be a great feature to aid developers. Another feature would be the ability to print out the HTML or C / C++ with just the tags or the bare outline. That means you could take out all of the other unnecessary code that is inside. Think of how nice it would be to copy a webpage from Intel, for example, and then have it just keep the tags allowing you a similar layout as theirs. Given, you would need the CSS file, but having the ability to start this would be helpful. A step less than this would be just the ability to print out the file so you could view it later. You could also edit a “copy” of the program then without tampering with the original. I know I always make a backup of my files as I go. This way if or when I mess up, I have a back-up plan. This has helped me a lot in the past. For one final suggestion, I would have it create an error log file. That way, every time the program would error, a file is created containing the results of why it had an error and where the error was. This could be used to send back to the company or developer so that it could be fixed in future releases or it could be fixed, perhaps, by the user even if it was simple. These features would take a lot of time and effort, but they would greatly enhance the program for both the user and the developer.