#### Archived

This topic is now archived and is closed to further replies.

# Is it just me, or do the AP Comp Sci classes really SUCK?

This topic is 5802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m planning on taking the AP Comp Sci test this year, so I was looking through the AP headers and other things. There are 5 of them: apstring, apvector, apmatrix, apqueue, and apstack. I was looking at the implementation for them, and some were just sickening.
  istream & getline(istream & is, apstring & str) //description: reads a line from input stream is into the string str //precondition: input stream is open for reading //postcondition: chars from input stream is up to ''\n'' have been read { char ch; str = ""; // empty string, will build one char at-a-time while (is.get(ch) && ch != ''\n'') { str += ch; } return is; } 
OMFG. Were they not aware that istream provides a istream::getline function?
  const apstring& apstring::operator +=(const apstring & str) //postcondition: concatenates a copy of str onto this string { apstring copystring(str); // copy to avoid aliasing problems int newLength = length() + str.length(); // self + added string int lastLocation = length(); // index of ''\0'' // check to see if local buffer not big enough if (newLength >= myCapacity) { myCapacity = newLength + 1; if (str.length() == 1) // special case for catenating one char { // make room for future catenations myCapacity *= 2; } char * newBuffer = new char[myCapacity]; strcpy(newBuffer,myCstring); // copy into new buffer delete [] myCstring; // delete old string myCstring = newBuffer; } // now catenate str (copystring) to end of myCstring strcpy(myCstring+lastLocation,copystring.c_str() ); myLength = newLength; // update information return *this; } 
strncat, anyone?
  apstring apstring::substr(int pos, int len) const //description: extract and return the substring of length len starting // at index pos //precondition: this string represents c0, c1, ..., c(n-1) // 0 <= pos <= pos + len - 1 < n. //postcondition: returns the string that represents // c(pos), c(pos+1), ..., c(pos+len-1) // { if (pos < 0) // start at front when pos < 0 { pos = 0; } if (pos >= myLength) return ""; // empty string int lastIndex = pos + len - 1; // last char''s index (to copy) if (lastIndex >= myLength) // off end of string? { lastIndex = myLength-1; } apstring result(*this); // make sure enough space allocated int j,k; for(j=0,k=pos; k <= lastIndex; j++,k++) { result.myCstring[j] = myCstring[k]; } result.myCstring[j] = ''\0''; // properly terminate C-string result.myLength = j; // record length properly return result; } 
uhhh...ever heard of "memcpy"? And that''s just a few examples from the apstring class. The other classes have some memory manipulation that is just plain bad . Why would they do this? WHy did they even write these headers? For the last 10 years, I believe developers have used a little something called the Standard Template Library. What is the point of these simple, inefficient classes? Or is it just that I thirst for speed and efficiency in code because of my game programming? I just don''t understand these crazy AP people... ----------------------------- Direct3D vs. OpenGL The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence. Democracy is where you say what you want and do what you''re told.

##### Share on other sites

Errr. Did you stop and think that maybe they wrote those teaching versions so you could read the source and see how those tasks might be done?

##### Share on other sites
quote:
Original post by Promit
Why would they do this? WHy did they even write these headers? For the last 10 years, I believe developers have used a little something called the Standard Template Library.

The STL only became part of Standard C++ in November of ''97, IIRC (it might have been ''98).

Also, consider that performance is not the overriding consideration in these classes. Proper programming methodology probably is (I never took them, so I speak from an outsider view). There''s probably more emphasis on algorithms and data structures than on APIs and optimizations. Also keep in mind that back then the ap* classes were easier than most other (portable) options.

Yes, they suck. Unless the AP classes really provide you a major benefit (like skipping a 200-level CS class), I''d say they aren''t worth it. You obviously know enough to place out of elementary classes, so spend your time doing more gainful things.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
Ok, 5 years, not 10. I can sort of see the sense in reimplementing the STL classes, but did they have>/i> to do it in such simplistic and inefficient fashion?

/me suddenly remembers that they don''t teach basic C functions such as memcpy and those functions would be meaningless to ppl taking the class

*Sigh* can''t they at least teach programming right?

-----------------------------
Direct3D vs. OpenGL
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Democracy is where you say what you want and do what you''re told.

##### Share on other sites
When I took the AP comp sci test it was still in (*cringe*)Pascal, so there!!!!!!

##### Share on other sites
Sigh, yall r making me feel bad that I took AP Comp Sci a year ago.

Yeah, those AP classes are pretty stupid. And the even worse thing is that they''re training the teachers not to let you change anything in them. In my opinion, if there is something that could be upgraded, the change should be shared with the class, and everyone should update.

I guess the only thing you can really do is email the College Board and tell the computer science people over there that they''re dumb. It''s really funny. When I took it, everyone in my class was really smart, and we finished assignments really quick, then went and played with opengl and networking. We all ended up knowing the apclasses and then teaching eachother the STL classes, so we could use those in our own little programs.

Yeah, those apclasses really are for learning purposes. No one said you have to use the apclasses for all your non-AP C++ projects. Lord knows I don''t. Or, your class could write a new version of the classes and send em off to the college board and hope they replace the old dinky ones.

Alot of the stuff you do in there is pretty dumb, but efficiency isn''t always their main concern. I remember we once had something where we had to read some apstrings into a file or something, but it wouldn''t work because some function only accepted char*''s and not apstrings. So, I used char*''s instead of apstrings and I got an F for the assignment. Guess they don''t want us to know what arrays are for fear of us accessing the wrong index and blowing up the world or something.

Have you guys started on the case study yet? with the fish? that''s a classic. My friend''s taking the class right now. He gets his to race across the screen and they all place bets on who will win.

##### Share on other sites
quote:
Original post by Promit
*Sigh* can''t they at least teach programming right?

I''ve been arguing this myself for a while now: if you''re going to teach programming, teach it right. Use the appropriate terminology and techniques, etc. I''ve been campaigning at my school for widespread adoption of the STL, for instance. I tutor C++, and I simply do not answer questions on char * strings (for example) for anyone in CSC 230 and above. I tell them to use std::string and tell the professor I told them to.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
You must remember that in ''the real world'' when people program in C,C++, etc. they do not always have the access or ability to use all of the standard libraries. My wife, who was doing programming for a major phone line here in Japan, not only had to use the company''s libraries (even their memcpy routine). Why? One is portability. People like Sony and NTT make different hardware that uses the same libraries that she made. Yep, it sucked, but there was nothing she could do about it.

It is great that you are questioning the reasoning behind a teachers methods, it is how you learn more. It is also great that you are pursuing other ways (like using STL). Please remember though, it gets stupid and limited out there also. I feel sorry for those students who get tutored by Oluseyi, and never get a grasp of using char* for strings.

##### Share on other sites
quote:
Original post by Taulin
I feel sorry for those students who get tutored by Oluseyi, and never get a grasp of using char* for strings.

I expect them to know how to use it. Note that I said CSC 230 and above; the 100-level grunts still have to go through C99 boot camp!

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
What does a AP Comp Sci test consist of? What kind of stuff do you have to do? I know C++ pretty well and am planning to take the test, but my school only has really stupid Comp Sci classes in Visual Basic, so I have no idea what to expect. I''m just having a little trouble envisioning a computer science exam. What are these AP headers?

##### Share on other sites
Like the AP and Oluseyi said there is a method to the madness sometimes and classes tend to focus on understanding fundamental concepts. Just watch out for some teachers, I had a college professor in CS101 who was lets call it misinformed. She was teaching linked lists and when she dynamically allocated memory for it she never released it. When i brought this up she said she''d have to "check it out". She came back the next day and announced to the class that u did indeed have to release allocated memory when u were done with it. It just really got me that she actually had to go check (go home at that), combined with the fact she had a degree in CS (and if i remember right a masters). Scary isn''t it???

##### Share on other sites
quote:
Original post by Infinisearch
When i brought this up she said she''d have to "check it out". She came back the next day and announced to the class that u did indeed have to release allocated memory when u were done with it. It just really got me that she actually had to go check (go home at that), combined with the fact she had a degree in CS (and if i remember right a masters). Scary isn''t it???

LOL

##### Share on other sites
She probably learned to program with java

##### Share on other sites
but you HAVE to go to university and feed them money to give you a piece of paper just so you can get a job and not learn anything

I frickin learned ASM, C++ and VB at home and have a kickass game brewing up, but you still need a degree and not skills

##### Share on other sites
quote:
Original post by Cybertron
but you HAVE to go to university and feed them money to give you a piece of paper just so you can get a job and not learn anything

I frickin learned ASM, C++ and VB at home and have a kickass game brewing up, but you still need a degree and not skills

You''d have to make a major effort to go to university and not learn anything.

So you know programming languages? So what? You don''t know computer science.

##### Share on other sites
this whole ap thing sucks i am in ap comp sci. is sucks BAD

-take me to bed and rip me apart-*LAM*

##### Share on other sites
There was no such thing as AP Comp Sci when I went to school. Most colleges didn''t have a dedicated CS department yet.

##### Share on other sites
I've been in college for 3 years and really haven't learned much of anything new along the lines of CS. All it has done is to formalize what I already knew intuitively from 12 years of my own tinkering.

And, yes, I know that CS is not exclusively programming; at best, programming is 1%.

Edited by - merlin9x9 on February 26, 2002 1:14:37 PM

##### Share on other sites
Oh, and those AP classes (the C++ kind) suck. They''re intended to teach how do do things, but they don''t teach them properly. For example, non-const references and general inefficiency. No, I don''t necessarily advocate one-fell-swoop methods like memcpy but teaching the use of exceptions, unsigned integers (instead of always int), and using prefix rather than postfix increment and decrement are all good things. Kids just aren''t taught that sort of thing.

##### Share on other sites
quote:
Original post by THE Omega
Have you guys started on the case study yet? with the fish? that''s a classic. My friend''s taking the class right now. He gets his to race across the screen and they all place bets on who will win.

Lmao! Yes, I had to do that in my AP CompSci class..

That fucking thing was so pointless it wasn''t even funny..

##### Share on other sites
I think what makes me most angry is that they don''t teach the function sprintf. I think that sprintf is possibly the most useful function in the world. I can''t count how many times i''ve wanted a sprintf in VB...

I have a dedicated CS department at my HS, but the teachers know next to nothing about C++. I am good friends with both teachers, but I know more C++ and VB than them, and I know it, and they know it and admit it. They are just the typical math teacher who likes computers sort of people. But then again, most people fully qualified in C++ won''t take a job at an HS at that sort of salary...

quote:

Like the AP and Oluseyi said there is a method to the madness sometimes and classes tend to focus on understanding fundamental concepts. Just watch out for some teachers, I had a college professor in CS101 who was lets call it misinformed. She was teaching linked lists and when she dynamically allocated memory for it she never released it. When i brought this up she said she''d have to "check it out". She came back the next day and announced to the class that u did indeed have to release allocated memory when u were done with it. It just really got me that she actually had to go check (go home at that), combined with the fact she had a degree in CS (and if i remember right a masters). Scary isn''t it???

Are there words in existence to express just how incredibly bad that is?

-----------------------------
Direct3D vs. OpenGL
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Democracy is where you say what you want and do what you''re told.

##### Share on other sites
quote:
Original post by Promit
I think what makes me most angry is that they don''t teach the function sprintf. I think that sprintf is possibly the most useful function in the world.

snprintf is better. std::stringstream is even better.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
My AP Computer Science "teacher" doesn''t know C++. In fact, he doesn''t understand computer science. Don''t ask me how he majored in it. I''ve got a ways to go before I will be willing to call myself a good programmer. But I''m sure I passed this guy a long time ago.

I finish all the labs on the first day they are asigned, and then do nothing - well, except maybe homework for other classes (and I talk to other people in the class, who don''t code because they use the CTRL+C, CTRL+V technique). Needless to say, I get bored. So one day I brought in a disk with an A* demonstration I had written previously, and ran it. He was curious, so I told him what the program did. I told him I used A*. He hadn''t heard of it. However, he said, "This is interesting, because we''re discussing shortest-path algorithms in my graduate class right now. I''d be interested to see the source code for that." Well, since I''m such a nice guy, I printed the source and gave it to him! At least this way it''ll take some effort to plagiarize off of me!

This guy doesn''t understand a linked list, or any of the standard libraries. In fact, he had never even heard of printf!

You may ask, "How does he teach?" Well, there''s a teacher from a neighboring town who did him the favor of giving him a copy of a CD full of powerpoint presentations covering the AP Compsci syllabus. This is the extent of his teaching.

At the beginning of the year, I was a nice guy. People would ask me for help; I''d give it to them. I''d try to explain things to them (because he sure as hell wasn''t), but they''d get frustrated with me, and say "Ok, you''re just confusing me. Gimme some code!" After a few days of this, I gave up, and when people asked me for help, I''d tell them to go away. Somehow, they managed to pull off the feat of creating working programs. I guess it''s just a coincidence that their whole side of the room had identical code.

The "Marine biology" case study is written in C++. After going through the Powerpoint presentation presenting the "Aquafish" class, one student asked, "So what''s a class?" It''s funny, since he never taught the class.

Nobody in the class understands what a class is. Few people understand the difference between floating point and integer types. Nobody (except me) understands the difference between signed and unsigned types. Etc. Etc. Etc.

My biggest problem with the AP syllabus is that it doesn''t teach a damn thing about the language. It just gives you a couple of code snippets, and expects you to create working code. Most people, not understanding what things do, simply copy the demonstration code, and, through trial-and-error, the population manages to find a working program, which it them distributes among its members. (It''s a victory for genetic algorithms!) Perhaps if the class understood C++, they might be able to write code.

In teaching C++, I strongly believe that the absics of the language should be taught, and individual examples should then be given. As it stands, the reverse is done. examples are given, and then, months later, these "secret codees" are explained. This is the wrong way to go about it. Explain what a function is before having people use it. Most people in the class didn''t even understand that a function can be treated as a value. When I told people that functions in C++ were like functions in math class, some light bulbs went off. It''s a shame the teacher couldn''t even get that much across.

I could go through my entire plan for revamping the AP Compsci course, but I know that posting it here wouldn''t accomplish much; I''d - to abuse the cliché - be preaching to the choir. You know how to program. You know how to teach. It''s a shame that these "professionals" don''t. This raises a major concern of mine: If these people got Computer Science degrees, and still don''t know how to code, then what''s the point in taking CompSci?! My teacher is in a graduate course; I started learning C++ as a hobby last summer, and I can run circles around him. I hope college won''t be as big a waste of money for me.

##### Share on other sites
as for your freaking out about getline, they want to store the line into the apstring using the istream that is sent to it, otherwise anotherassignment operator would have to be written (it really does serve a purpose).

aa for strncat, an operaator is much more suer friendly to a n00b that a function with a parameter, you can see that the += will concatonate without having to know anything about about the class (thus promoting information hiding, an inportant cs concept incase you didnt know).

If you want to complain about something, wait till you get to the Marine biology case study, which this far in (just finished unit 7) is just just bad code (very slow for large test data for many steps).

##### Share on other sites
You are really harsh on your teachers. You need to look at the whole situation before you start bashing. Teaching Computer Science/Programming courses in High School is still a farely new program. The average High School teacher has not been in school for about 10 - 15 yrs. You can''t expect the teachers to be as up-to-date as you are. They do their best to learn the material, and teach the best they can. School systems cannot afford to hire dedicated Comp Sci teachers for these classes, so they ask anyone interested if they would pick it up. Naturally the math teachers are looked to first. Give them the benefit of the doubt.

Technology moves at such a pace that not everyone can keep up. Most college professors have been out of industry for some time, so they don''t know the latest greatest techniques. STL is one of these techniques. And Comp Sci is not all about programming. A complete Computer Science program teaches all around knowledge of systems architecture, CPU architecture, Operating Systems, software design and modeling, and finally programming.

Oluseyi, as a tutor you are an extension of the professors. Your methods can be detremental in two ways: 1. The student is coming to you because he doesn''t fully understand what the professor is asking. He/she may not fully understand what a char * is, even at the 230 level, and it is your job a tutor to help them. By telling him to use std::string instead of char *, that student may not get his question answered. 2. Also by saying to them use this and tell the professor I said so, you are disrespecting that particular professor. Professor''s ask students to do things a certain way for a reason. They are trying to teach concepts, not implementations.

Without understanding of the concepts, optimization is next to impossible. There is a reason why the professor is having you use char * strings instead of std::string. By understanding how to do string manipulation with a char *, you can better appreciate what std::string does for you. An no, not every programmer may understand it as well as you do, and you can''t expect them to either. Promit, the AP classes, apstring, apvector, apmatrix, etc..., are not perfect implementations, they are used to demonstrate concepts. Look at every tutorial you see here, all of the authors use code that is clear to the concept, but not the best implementation.

Be fair to your teachers, they are most likely learning along with you.

-----------------------------
kevin@mayday-anime.com
http://games.mayday-anime.com