Finally getting around to the last blog post on here. I guess the last assignment I did was implementing the process class. I thought this was a pretty interesting assignment especially since it kind of gave me an idea of how an API such as Qt would implement their QProcess class. This assignment wasn’t too bad, but figuring out exactly what we needed to do was a little challenging. After getting and understanding of the classes member functions and what they were to do, actually writing the code wasn’t too bad. Getting all the functionality correct was a little bit challenging like when to close the pipes and what would go into the destructor.
For the write our own assignment, I found this to be more challenging than I initially thought it would be. After coming up with the idea, it was a lot more difficult to put it into exact words that would describe precisely the assignment that I wanted. Even coming up with an idea that would implement certain commands and ideas was pretty hard. The grading rubric was probably the hardest of all, as I just wasn’t sure how to give certain points for certain things, a lot of times my mentality is either it works or it doesn’t, and it was hard to come up with point allocations for an in the middle type situation.
For 3574 we got 2 assignments crammed into 2 weeks, thankfully though neither were too difficult. It was nice to get back into a GUI for homework 8. I got everything up and running pretty quickly but I couldn’t get the GUI to update correctly for the longest time. Eventually I figured out that i was still using a posix pthread join which blocked the main thread from updating until the other thread was done calculating prime numbers. I found a function, pthread detach, which didn’t block the main thread but also prevented any zombie threads.
Homework 9 was even easier especially being able to use QThread which was nice. Once I understood how both the semaphores would work and what the mutex would need to lock setting up the consumer/producer threads was easy. I had a little bit of trouble manipulating the buffer array (it had been a while since I had to work with arrays), but after some careful manipulation of pointers to the buffer I was able to get the circular buffer working properly.
I’ll go ahead and start off this blog by talking about the makefile assignment since I haven’t said anything about that yet. At first, I thought making a makefile would be extremely difficult; I figured that since the process was often automated it must be very hard. I actually found it to be very intuitive for the most part. Each target will be re-created based on any dependencies that it has, so if any of its dependencies change then the target will be recreated based upon the commands listed for that target. I found especially beneficial that you can have multiple targets if they have the same dependencies and are created by the same commands, this came in handy for the parser.tab.hpp, and parser.tab.cpp files which were both dependent on parser.ypp and were created by the same bison command.
The most recent assignment was on forking processes and creating a pipe. The first part of the assignment was to create a makefile which proved to be very easy after the last homework. For the most part the homework was very straightforward and took nothing more than looking at examples and reading the man pages. Of course I had a couple small bugs, but Darren pointed me in the right direction with these issues, and I got the homework finished without too much trouble. I have a lot more experience in C++ so it is a lot easier for me to write C++ code then it was with writing Python which was a struggle especially through poor documentation. I thought this was a cool assignment that showed how the beginnings of a shell may come together.
The most recent assignment in 3574 wasn’t too difficult after some guidance from Sean. This goal of this homework was to use threads to perform matrix multiplication. Reading from the input file actually proved to be more difficult than I had expected since Sean told me he would probably do a of error checking by supplying oddly formatted input files. He showed me how to use QRegExp (regular expressions) to get a good pattern for determining if the input is an int or a float, and then if the input didn’t match either of those then you know that there is something wrong with the input. This eliminates the need to check for a multitude of different things such as if there are letters entered, or special characters, or who know’s what else. The regular expression catches it all with ease. I read the input files into a QList of QStringLists, which gave me access to the matrix elements in a similar way to a 2-D array. After that it was pretty easy just to run a for loop to make the correct number of threads, calculate the correct products then output it to the resultant matrix. I found that there was no need for mutexes since there is no thread was going to access to the same memory location, so this made the assignment even easier.
It’s been a while since my last post so need to get back on it to be sure I get 10 in before the end of the semester. Haven’t had any assignments in Unix lately which has been a nice break. I ended up getting the futures paper done to get me some added points to my total grade. I’ve also gotten a fair amount of work done on our battleship final project. I’ve gotten most of the text based part of the game done and implemented in Qt; this should give us a good base should we have time and choose to implement a GUI. Error checking is always one of the things I hate most about programming because there’s just so many stupid things that a user could input that you have to check for and handle. I think I’ve gotten everything covered in terms of inputting bad coordinates and so on. Currently the ships are only one size big, and they need to be re-implemented to the correct size, and error checking needs to be done in terms of placement, i.e. checking for overlap or run off over the screen.
As for 3574, we had our first test this past Thursday which seemed to go pretty well to me. Most of the information was easily found in the book or online slides from the book, and I can’t imagine getting a poor grade on this test. The past homework has been quite difficult, and it took me awhile to get the thing of moving back and forth between different UI forms via signals/slots, and hiding/showing different widgets. It has however been a lot more fun to write than previous assignments. Getting used to QtDesigner took me a few minutes, but it is very intuitive, and makes creating GUI’s so much easier than coding them by hand. As part of the assignment we had to implement tic-tac-toe and write our own algorithm for the computer. I think I have gotten pretty close to if not an unbeatable computer player. Hopefully the homeworks will remain interesting, but now that I believe we are done with GUI’s, I’m afraid I will lose a lot of my interest.
Had our midterm exam this past Wednesday which went alright. Just barely got it submitted within the time limit wish I had had another half hour just to work on it without a late penalty. I think I spent too much time in the beginning trying to get the commands to return what I wanted that I didn’t have enough time for writing/fixing the scripts in one section. I attempted all 3 of the questions in that section even though we were only required to do 2/3, but after trying question 1, I was pretty sure I did it incorrectly and moved on to questions 2 and 3. I tried to fix the code on 2, but I didn’t know what the program was supposed to do, and I didn’t have time to look through the code to find out. I fixed the syntactical errors and hoped that was good enough then moved on to number 3. I had maybe 10 minutes left to write this script, and I think I got the bulk of it correct, but there were still some errors when I submitted it just because I didn’t have time to debug it. Hopefully it turns out better than I felt after submitting it.
In ECE 3574, we got our first GUI assignment which was kind of cool. It was rather basic, just setting of some buttons to do some things and display some dialog boxes. After getting the signal mapper to work properly, it wasn’t too difficult to write the code for each button. I did have one issue with getting the checkbox in the qerrormessage which controls whether to display the message again to work correctly. From reading through the documentation it seemed that the checkbox should have all the functionality already implemented, but this was not the case for my code. Whether the box was checked or not, the message was always displayed. Even after working with the TA we couldn’t figure out what was wrong with it. I ultimately just had to add my own qcheckbox widget to a qmessagebox and writing the functionality of it myself. Besides that one issue, the rest of the code only took maybe 3 or 4 hours to write everything, so not too bad.
So the python homework do this Wednesday has been the toughest python assignment so far. While it was the hardest, I think it was the most useful to implement, and I think learning how to write our own protocol and such was a useful exercise to do. I found the dictReader and dictWriter functions to be very helpful when working on this assignment as they allowed me to read in data and immediately put it into a dictionary with no parsing and work needed on my part. It even took the first line as field keys for the dictionary. Writing the dictionary back to the file was just as easy as reading from it was, and, after learning how to do this, the rest of the assignment wasn’t too bad. I did have some trouble getting the delete command to delete multiple items in the list but with list comprehension this proved to be a fairly easy task. I wasn’t however able to get the sort by quantity to sort by integers rather than strings. I couldn’t figure out how to set types for the dictionary values by the way that I was creating the dictionary from the data read from the file. Nevertheless, I think I got all the necessary pieces of the code working as they should.
As for ECE3574, we had our easiest homework so far which required recursively moving through directories and determining the sizes of those directories. Qt has some very nice classes to help with this task such as QDir and QFileInfo. QDir allowed me to pull everything was in a current directory into a list of QFileInfo objects. QFileInfo has very helpful functions to determine whether the object is a directory or a file, and the size of whatever object it contains. After figuring these things out, it was only a matter of setting up the recursive routine properly. Parsing the arguments passed wasn’t too bad either, although this is a time where I would have liked to use the argparser in Python. For whatever reason QtCreator did not like the -v argument passed on the command line, and would run nothing when it was passed. I’m still not sure why this is the case. Besides that though the homework was fairly easy.
Not too much happening with Unix this week. No python assignment this week and finished most of project two for ECE 3574 last weekend. That project was quite annoying seeing that book didn’t make much sense with most of what it wanted you to do. After seeing the TA, I realized how many flaws there were in the books spec. Constructors missing members that they needed, parameters that aren’t specified as to what they are to do, destructors with nothing to destruct, are just a few things among many of the problems with the spec. I guess the only good thing about it is that the program can’t be graded as harshly because the spec is so ambiguous. Glad to be done with that one though, hopefully the next one is better.
As for ECE 2524, not sure what the next assignment will entail but I’m not looking forward to it after the exercise on Wednesday. I don’t really understand the protocols at all, and I have no idea how to implement them. I have no idea how to go about creating the project like what was mentioned in the exercise. Hopefully that assignment will make more sense when the spec comes out.
Had my first issue with Ubuntu today, I guess moreso with the VirtualBox which crashed for the first time. Luckily managed to recover everything. Still having issues getting it to have the correct resolution within VirtualBox though, I don’t remember how I got it into widescreen form last time.
Python proved to be more difficult than last weeks assignment. Getting the parser to work along with the fileinput was more challenging than it originally seemed. At first I had a hard time figuring out how to handle each optional argument in the parser. Eventually figured out you can literally say if argument… and handle it. A lot more intuitive than I thought it would be. After getting that, it still wasn’t working because the optional arguments had dashes within them like –ignore-blanks. Turns out Python converts these dashes to understrikes so the statement became if “ignore_blanks”. Then the fileinput tried to take these optional arguments as files which caused more issues. Finally got all of that working and then learned about the shebang too.
ECE3574 continues to have an overwhelming amount of work. Project 2 is some exercises out of the book that are extremely annoying. The exercises require you to implement the functions listed in the book, and you have to figure out what the book wants you to do with each function and what they want you to do with the parameters passed to each function. One of the exercises you have to use some of the source code given and it’s extremely hard implementing classes and functions that you didn’t design. It would be a lot easier just to write everything on my own rather than trying to figure out how their stuff works and then incorporating it. Gunna have to go see the TA just to understand what the book expects you to do in certain parts. Sure hope there won’t be any more assigments out of the book.
Just finished Homework 2 in Python and figured it was time to write another post. I have discovered that I do not like Python very much, while syntactically i like that you don’t need squiggly brackets, and you simply do tab which is what you would normally do any other language anyway; I do not like having a debugger to step through the code. It’s really hard to figure out where an error occurred and which line is causing something to do go wrong. Also not being able to step through and watch the values of variables makes it hard to tell what’s going on. Doing the homework took me quite a while longer than I thought it would, 1. because there is no debugger, and 2. because all the documentation I have found for Python isn’t very useful. While I was trying to look up some of the functions to use they are not very clear how they work. For one function it said it returned a “tuple” which I understood to be three different parts, but I had no idea how to access those three different parts it created…what does it store those parts into? With no useful examples I merely had to search for another way to solve the problem. That’s my work with python so far, but I’ll go ahead and explain a little bit about the qt programming I have been doing in ubuntu as well.
So QtCreator turned out to be more useful than the text editor for python, but its still not nearly as helpful as visual studio. It took me probably a little over an hour just to get things working properly. First off I had to change run settings to output the run to the terminal rather than the rather useful output at the bottom of the screen that takes in no arguments. After figuring out how to pass arguments from the command line to the terminal within QtCreator, I tried to debug it and realized that the debugger had some sort of error which I believe has something to do with outputting to the terminal. After googling some solutions for another half hour, I eventually got it working after modifying a couple files. Once that was out of the way, I was able to get to the heart of the programming and I found that Qt has some nice member function for its types. the QDate type was particularly useful for this assignment which was to create a birthday reminder program. One function which saved me a lot of time was the function for QDate isvalid(). That actually checks the date to see if its an actual date that exists and it saved me a ton of time by not having to write something like that myself. Overall the program turned out to be a little easier than I thought it would be, but it still took a really long time to complete. And that’s about all for this week.
Alright so I guess it’s about time to start the first entry to this blog. This class is my first experience in Unix, and so my first objective was to install Ubuntu. Since I already had a virtual box running on my laptop, I figured that would be the fastest ad easiest way to get Ubuntu up and running. After downloading the ISO file and creating a new partition in the virtual box, all I had to do was simply install it. Once it finished installing, I played around with learning what everything was; I was surprised to see products already installed that were so similar to Microsoft Office. So far everything has been running smoothly, and I haven’t had any problems.
I began going through the lecture and exercise for week 2 today and found the exercises to be very intuitive and easy to complete. Probably took only about 15 minutes to complete and definitely worth not having to go to class on Monday. Also started looking at the commands to learn for Wednesday. Some are very self explanatory, while others took a little bit more time to understand as some commands can be used in different ways to do multiple different things. I’m also programming in Linux for ECE 3574 in the qtcreator. I may also write about some of my experiences with that throughout the semester as they relate to this class.