Jump to content
  • Advertisement

Archived

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

Promit

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!