Saturday, December 19, 2009

OOP344 Assignment 2 Implementation

With exams done at last, I can finally take a minute to write about OOP344 A2. We have decided to build a text editor, which keeps getting more complex each time we talk about it. I am currently writing a word wrapping feature for the text editor, that is taking longer than expected but it should be done soon enough, I am just hoping that I don't hurt the team with this little tangent I decided to follow.
The program is going to need a whole new batch of classes to work correctly, first the controller, which will actually control the program and will act as the programs root class, which will organize all the classes and access the programs menu manager, file manager, and settings classes, while containing all the forms and fields it requires. I am responsible for the controller, so that is my mess to figure out. The menu manager system controls the primary menu and holds a series of other menus and function pointers inside of it, so when a menu item is selected, it either displays another menu, or calls a function that will accomplish some task. This has already been completed by northWind, and he did it in such a way that adding, organizing and displaying menus is very simple, which makes my job of creating the controller a bit easier. The file manager allows the program to open, read, write and close files on the fly, this will allow the controller to access files more easily, this is being handled by Ausley. The settings will be a class of their own and this will allow a function based interface with all of the program settings, and quick access to all the setting variables, I think northWind wants to do this class as well. The rest of the work is still kinda up in the air, but we are planning on making specialized forms, a small button system, a highlighting system (which I plan on doing, if the dead line doesn't come up too quickly), copy, paste, ect. So, this is the plan, for everyone else planning on making a Text Editor program, see you at the finish line >:-D

Monday, December 14, 2009

Onward into the shadows

Well, this is the last week... I just woke up from a great little sleep and now its time to get ready and study for my INT322 exam that is in 6 hours. My biggest advice to anyone reading this, is make damn sure you have a good night's sleep before an exam, I really messed up some of my other tests because I simply didn't allow myself time to sleep. I plan on going over my previous two INT tests and writing out the two pre-tests we were given in the tutorials to hopefully get my self set for INT, then all I got left is DBS and I am gone.
I also wanted to post my opinions about the OOP344 exam here too. I have always hated the concept of a programming exam, essentially writing some small piece of junk code, in a short period of time. I have two methods of writing tests: take my time and write it correctly, but lose a bunch of marks at the end for questions I don't have time to answer, or write it quick and sloppy and finish all of the questions, but lose marks on questions answered incorrectly, often on purpose. I usually take the former method, but for the OOP344 exam I thought I'd try the latter, but it nearly killed me doing so, I intentionally wrote at least 3 questions completely wrong, simply because I knew I didn't have the time to write the whole thing out correctly, which is really infuriating, because I already know how it is supposed to be written, but I know my hands simply can't write fast enough to allow me to write it. For the save and load functions on the exam, I simply wrote something like 'f.write((char*)this, sizeof(queue);', I know how completely wrong this is, but I didn't have time to write it correctly. Exams should be short IMO, but w/e, its water under the bridge, or w/e that saying is.
I am gonna end this off with the OOP344 assignment, which is gonna be worked on through out the holiday so by the time it is time to hand it in, we have something that is actually worth something, an actual working text editor. Lets see how it goes.

Wednesday, December 9, 2009

The time of darkness draws near

So, the exam is in a few hours, and I just woke up from a beautiful 17 hours of sleep, and I am set and ready to do some last minute cramming. I will explain my studying plans each day for the next few days so anyone who doesn't know where to start will have a good idea, mind you, this will include all of my classes, not just OOP.
So, for tomorrow, I have SYS366 and OOP344, and I have a detailed plan already set. For SYS366, I will simply review my previous two tests, see what I did right and what I did wrong, then I will re-write it so that it matches what should be worth a perfect mark. That should take about two hours, and then I figure I am set for SYS366, for anyone reading this that thinks they need more help than that, I would also suggest checking out the slides and example models that Mary-Margaret Walton has posted on her class schedule.
For OOP344, I will be looking at my previous tests, but since I got perfect on one and near perfect on the second, I won't spend much time on them, I will also re-read chunks of the Evan Weaver text and look over the quizzes, then I will assign myself random programming tasks on areas that I am not too confident in, and do my best to make complete and working examples of how that specific area works. This will likely add up to 5-6 hours of studying, Then I guess I am as ready as I am going to be.
As a final note, with all that is going on, I want to stress the fact that everyone has to remember to do the INT322 assignment 2, do not forget, do not leave an inadequate amount of time for it.

Friday, November 27, 2009

School is becoming a pain the in asterisk

The OOP344 Assignment 2 just seems to be getting bigger and bigger each time I look at it. My group plans to make a text editor, meaning there are a lot of things we are going to have to change to properly implement this thing. By the looks of it we will need a minimum of 5 new classes not specified on the wiki, and that will just give us a barely functioning text editor, with nothing fancy at all. I've already finished IO_Field and IO_Form for my group, now I am grinding through IO_TextEdit, which is taking me MUCH longer than expected, and its still not completely debugged. With each bug I find, it usually means an extra 5 - 10 lines of code, so by the end of this IO_TextEdit will easily be over 300 lines without comments, which is taxing to think about when the 'due date' is tomorrow. My group members are having problems with some of their tasks as well, which makes our outlook kinda bleak. But of course, I am sure we will get things running smoothly, I'm just saying a lesser group would be dead in the water by now. The week from hell starts tomorrow, test after test, assignment after assignment, coming next week, then exams, this semester went by WAY too quickly.

Thursday, November 12, 2009

A return to form

For the last while, I haven't been paying the same love and attention to OOP344 as I usually do to my C++ programing courses. Enough of that, I'm back into the coding mood, by the looks of things, my group will have A2 done by the end of this week. Which means I have to haul ass and finish my assigned work too, so I will be getting back to my roots of all-nighters coding C++ until my eyes bleed. This may sound bad but it makes me happy. Even once we are done A2, we will be adding a megaton of features, hopefully, so that this text editor (which will actually be a text editor when we get a some file manipulation functions going) will be seriously worth its salt.
I plan to make a formatting tool for it, which will, upon activation, format the text into properly indented and stylized C++ bundle of code, and I also hope to make it so that it highlights and colors in braces, quoted words, functions ect. Now I'll give credit where its due, I will likely be using a similar method to the one tdot posted on his blogg (and no I won't link you to it, find it yourself) because he seems to have it nicely explained there.
Anyways, I figured it was about time I updated this blogg again, but now I must tie it up because I have some classes to write!

Thursday, October 29, 2009

My blogg is hungry...

I have been neglecting my blogg for some time now, probably due to lack of excitement, but Fardad insisted I feed it so it didn't whither up and die. So, to the point, the irc meeting, which was conducted on Wednesday, went down with a fair level of success. Fardad wasn't too strict on how the meeting was to be conducted, so I was allowed to goof around a bit as to keep myself from getting disinterested in the whole affair. He made sure the four of us had a reasonable understanding of SVN and how to organize our group, plus gave us a hand with a few things to prevent future conflicts. He also helped give us a grasp how much our group members understood in terms of SVN and A2 as a whole. While most of this turn out well, I would suggest to everyone that you listen in on other group meetings, as there were a few things he didn't cover with my group that he did cover with others.
When it comes to the actual assignment, I went ahead and grabbed the io_field section to write, which I'll have done by the end of next week. I also plan to write a formatting program in my spare time, because I really hate some of the things my group decided on for the coding standards, so instead of pestering myself by abiding by them while I code, which would wear down my productivity, I plan to just write a formatting program that will swap my code between my format and theirs. If I finish this and it works, I am willing to provide the binary program (to hell with open source XD) to all those who suffer a similar ailment.

Wednesday, October 7, 2009

Bugs in OOP344 As1tester.c V0.9

Hey, just thought I'd point out some bugs that may prevent As1tester.c from running correctly on some Borland compilers and the matrix compiler.

In the ResetStr function there is a line of code that looks like this:

while(str[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ Garbage after data"[i++]);

On some borland compilers this will result is messed up data, to fix this change it to:

while(str[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ Garbage after data"[i])
i++;


And on the matrix and borland compilers, the function prntextbox is broken. The line:

from = from + len + 1;

Allows the compiler to pass the null char, allowing it to read into data that does not really belong to from. Change it to:

from = from + len;

And it works!

Tuesday, October 6, 2009

An Interesting Discovery With Linux

While this will probably be well known to those familiar with Linux, I made an unexpected discovery while I was figuring out the key codes for the Linux platform for assignment 1. I am not sure if it was because of the shell I was using or the OS itself, as I was using PuTTY to connect with the matrix servers and didn't test any other methods. But I noticed that when I used the restore buttons on the PuTTY window (the small window button and the maximize window button) that the keycode.c program picked up 2 key strokes, much like the function keys in windows. The value returned was -1, so the program itself didn't know what it was looking at, but something was definitely passed through as a key stroke. This may or may not cause problems for our programs, but it definitely holds potential for the text editors projects we will be making later this semester.

It is possible someone may have already blogged about this, or it may even be in the instructions, but it caught me by surprise so I figured I might as well post it here.

Friday, October 2, 2009

Finding Middle Ground

Surprisingly this post will have nothing to do with the fact that it is 5:00 am and I've been programming all night.

I seemed to be having trouble finding middle ground in terms of code readability now. I just don't know how readable I should make it vs how compact and clean it should look. For example, the code in assignment 1. The backspace code Fardad wrote for us to be used in assignment 1 (which btw is broken, because it will corrupt the string if you press the backspace key when cursor is at the beginning of the line (curpos = 0 and offset = 0)(I'll remove this upon request since A1 is individual)) is about 9 or 10 lines of code, but I rewrote it to be less lines even though it included an addition condition statement (to fix the broken code) and I don't know if I have really impeded on the readability of the code. I won't post it due to the nature of the assignment but I know its gonna pester me while I write the code. Any general tips would be appreciated ^_^

Wednesday, September 30, 2009

Assignment Progress and Bloody Braces

Well, I've finally started seriously working on Assignment 1 for OOP344, and I have noticed a few things about myself. First off, I am a much sloppier coder when I am working with someone else's code, I go through and figure out what the code does, then I proceed to roughly patch each individual problem piece by piece, and I find that by the time I have completely fixed the problem, it looks ridiculous, for example, by the time I was done fixing one of the parts in Assignment 1, I realized I had three consecutive if statements that could have easily been packed into one. There are often other redundancies as well, but since I am satisfied that it finally works, I just write a comment in caps the clean up the code, which I hopefully won't miss when I finally submit it.
Which brings me to my next problem... Braces, more accurately, brace styles. The standard, or at least what I often see from other programmers looks like this:

Function(arg, arg){
code;
if(arg){
code;
code;
}
code;
}


I HATE this style, it makes it so damn easy to misplace a brace, put the a line of code in the wrong block, and in general is a pain in the ass to read. I much prefer this method:

Function(arg, arg)
{
code;
if(arg)
{
code;
code;
}
code;
}

This looks so much better, easier to read, if you misplace a brace, it will glare out at you, you can easily see what code belongs to what function or what code belongs to what conditional or loop statement. I realize it takes up an extra line every time, but I'd easily be willing to pay that for code that isn't so infuriating to look at.

Friday, September 25, 2009

Challenge II

Here is my result for challenge 2, she works but she is ugly.

void io_display(const char *str, int row, int col, int len){
io_move(row, col);
len <=0?io_putstr(str);:{int i=0; while(len--) io_putch(str[i]?str[i++]:' ');}
return;}

In fact, I'll do one worse.

void io_display(const char *str, int row, int col, int len){
io_move(row, col);
len <=0?io_putstr(str);:{int i=0; while(len--) io_putch(str[i]?str[i++]:' ');}}

Since most compilers don't need the return to be specified. I'm not sure how she works in terms of efficiency, but this is a small piece of code IMO, and a great way to get your co-workers to hate you.

Thursday, September 17, 2009

OOP344 GetInt Challenge

Well, here she is, written from scratch and shiny as a penny, and no I don't know what I mean by that. I tried to eliminate any limitations or inefficiencies as I could, I don't think its perfect, but I tested it and it seems to run beautifully. I managed to accomplish this on my bus ride home from york to Hamilton, and subsequently haven't had anyone look it over yet, but I don't think I made any "no-no's" as Fardad calls it.

*EDIT* I noticed some mistakes in the code, I used C++ comments in C, for whatever reason I used val -= val * 2 instead of val = -val.

-------------------------------------------------------------------------------------------------


/*This GetInt fuction was written by JP Hughes (CloudScorpion)*/
/*This function first checks to see if val is negative, inserting a - in the first slot of the
strint array if it is. The function then proceeds to find the remainder of a divition of the
int val by 10, storing the value in the next slot in the array. Once complete, the function checks
if there is a - in the fist slot, if so if increases count to account for the difference, then
proceeds to reverse the values in the array so they do not appear backwards, then corrects the
count to its original value. Finally the function caps the array with a NULL byte at the end
of the string. */
void GetInt(char *strint, int val)
{
int count=0, c2 = 0; /*two counters required to keep track of the placement in for statements*/
char tmp; /*A char to hold a temporary value during the reversing process*/

if(val < 0) /*checks if the val is negative*/
{
strint[0] = '-'; /*if so, it inserts the - in the array*/
val = -val; /*inverts the value of val so it is positive*/
count ++;
c2++; /*counters are ajusted for later use*/
}
if(val > 0) /*This is used to ensure the value is not 0*/
{
for(; val > 0; count++)
{
strint[count] = val % 10 + 48; /*systematically inserts the numbers in reverse order*/
val /= 10; /* using ascii numbers, then removes the number from val*/
}
if(strint[0]=='-') count++; /*checks if the number is negative and adjusts the counter*/
for(; c2 < count/2 ; c2++)
{
tmp = strint[c2]; /*reverses the order of the numbers in the array by swapping the*/
strint[c2] = strint[count - c2 - 1]; /*numbers with the number on the other side of*/
strint[count -c2 - 1] = tmp; /* the array*/
}
if(strint[0]=='-') count--; /*corrects the counter if it was adjusted*/
}
else
{
strint[0] = '0'; /*if the value is 0, it is simply put in the first slot of the array*/
count++;
}
strint[count] = 0; /*finishes off the string with a NULL byte*/
return;
}

Tuesday, September 15, 2009

OOP344 prelim progress

All the early stuff is almost done on my end, and I got myself a group so I'm feeling pretty good, though I accidentally missed half a class and insanely missed my first quiz, but that is just my luck.

I realize we will be covering the primary platforms (VCC, Linux, ect) but I am also wondering if we might be covering some more abstract platforms such as gaming platforms or compilers for small devices like smart phones or PDAs, even briefly. This is likely more complicated that I know of and from what little I understand about this topic we would likely need some form of SDK to be able to build programs for such devices or whatnot. Eh, I'm really just thinking out loud, but more info on this would be awesome.

Tuesday, September 8, 2009

OOP344 Blog

Well, here it is, my new blog, though I hate the word blog and I don't know why blogs didn't get called something more reasonable and logical but w/e. I've always avoided blogs because I consider the act of frequent blogging to be nearly as vile as participating in social networking sites, which is, as far as I am concerned, the cancer of the internet that usually accomplishes next to nothing and is infested with juveniles frantically trying to relate to others and gather as many "friends" as possible so they can convince themselves that they aren't the awkward social outcast that they truly fear they are.

But enough of my miserable ranting, as ranting on a blog about the uselessness of social networking sites and blogs is in itself borderline hypocritical. For once owning a blog makes sense in the context of the OOP344 course, as it may actually aid in programming and communication with my classmates. The idea of open source programming is interesting, though I do not honestly think the ideal of open source programming will be overly applicable to the field I plan on entering, video game programming, as that industry has a fairly secretive and closed source environment. None the less, I am sure I will find this course absolutely brilliant and essential to becoming a more efficient and skilled programmer.

As I final note, from now on I'll keep my posts to minimal length as I can't imagine what I am writing to exquisitely interesting. I will likely not refer to this as a blog for much longer and instead call it a journal, because as far as I am concerned a blog is a sea creature from metroid, shown in the picture I have posted. (Well its a blogg but w/e)