PDA

View Full Version : This has really anoyed me



chrismax2
01-31-2006, 04:47 PM
Hey guys.

I been using C++ off and on for years, I got about 7 or 8 books on it, and I been looking at this and other sites for a good number of years, all the books and web sites have always said to implement a number we can use Test++ to of course add by 1. Way I been raised on C++.

So in England, I have stated for anyone in the rest of the world who might not know this a Open University degree in computing, basically its an degree you learn from home and send assignments to your tutor, you have about 1 or 2 classes for the whole course and an exam at the end.

So what they have decided to do on the one and only C++ course (all the others are Java) is not to use ++ because they feel it is a lot easier to get confused by it.

I am sorry but that is just stupid, why would a course decide not to use ++ when everything I have ever looked at as said do it like that. I even told them that I don't agree with that, not that it will do any good.

Chris

Dae
01-31-2006, 04:57 PM
... Yes, lets learn a programming language, functions, and libraries, but not ++ because thats just overdoing it. I agree, thats strange and annoying. However, you'll live, it's not a huge deal.

John_
01-31-2006, 04:59 PM
It probably wont do any good but.

Create a petition on a website like http://www.petitiononline.com/petition.html

Then register on a few other programming forums, normally cross-posting, which is posting the same message on several forums is looked down upon, but I imagine this would be alright.

Try and get as many people to sign it as possible. Post it in a newsgroup which you feel is most closely related to the subject. (cross-posting is not tolerated on usenet) Email people you know, just get as many people to sign it as possible.

It may only seem like a little thing, but when you are a beginner at programming you are most likely to pick up bad habbits, it is also hard to lose a bad habbit once you have gained it.

I would only recommend doing the whole online petition thing if you feel very strongly about it, some people may think it is petty, but you need to do whatever you feel is right.

To be honest though, I don't think most of the home study degrees are taken too seriously by people. But you more than likely have a reason for choosing to do this. Besides it beats sitting down doing nothing.

MadCow257
01-31-2006, 04:59 PM
It could be of the post/pre thing

chrismax2
01-31-2006, 05:08 PM
The Open University is different to normal home study in this country it is considered a proper university and not one of them cheap things. Hard to explain if your not English, but its not like some of that SPAM mail degree courses from America I sometimes get. Your right I will get over it, and at least when I programme my own stuff I will keep using ++.

Chris

sand_man
01-31-2006, 06:58 PM
My course instructors are weird too. The like to use stupid non-standard functions that are simple enough to implement yourself in a matter of minutes :rolleyes:

bithub
01-31-2006, 07:01 PM
What do you mean by them not using ++? Are you talking about the operator, or do you mean they are teaching C and not C++?

two31d
01-31-2006, 07:25 PM
Well... It's just as easy to write int = int + 1, instead of int++... What's the big deal?

Thantos
01-31-2006, 07:37 PM
Well... It's just as easy to write int = int + 1, instead of int++... What's the big deal?
Because the two aren't always equilvent. Say you wrote a class and defined ++ to mean you move on to the next object. It may or may not make sense to add 1 to it.

Also no programmer would be caught dead using x = x + 1; when you have things like ++ and x += 1;

Also consider the case where you want to increment it and do something with the old value. Oh but you need to do it in one statement.

Removing tools out of your toolbag is a stupid idea unless the tool is self destructive (IE gets() );

jrahhali
02-01-2006, 11:04 PM
hi my name is jamal c++ is neat and i need advice for school because there is this assignment that my teacher made us write that i don't like
anyways i have to go because i have a lot of work todo maybe i will see you guys later bye.

ps one more thing wait nevermind

Man! It annoys me when people use absolutely no puncuation when writing.
(I can already see the a response :p)

Rashakil Fol
02-01-2006, 11:55 PM
Because the two aren't always equilvent. Say you wrote a class and defined ++ to mean you move on to the next object. It may or may not make sense to add 1 to it.

If ; x++; doesn't mean the same thing as ; x = x + 1;, then the class is designed poorly. Not that x = x + 1 is better to use than x++...


Also consider the case where you want to increment it and do something with the old value. Oh but you need to do it in one statement.

This case does not exist.

jwenting
02-02-2006, 01:10 AM
it does exist, in student assignments ;)

CornedBee
02-02-2006, 07:21 AM
If ; x++; doesn't mean the same thing as ; x = x + 1;, then the class is designed poorly. Not that x = x + 1 is better to use than x++...

It's interesting that you claim the linked list standard container, as well as instream and outstream iterators are poorly designed. Personally, I don't think so, but I'm sure you know what you're about.

Dweia
02-02-2006, 07:22 AM
What happens if you go ahead and use it anyway? I mean, they can't really mark you wrong for having n++ instead of n += 1 or n = n+1

I've seen similar stuff though, the wonders of the Aussie HSC. You learn an equation in year 10 for science, but then in year 11 it's considered too advanced and you aren't supposed to know it.

jwenting
02-02-2006, 07:31 AM
I've never heard of something being banned from use when it's not being taught, as long as it is proven correct.
I've in fact made good use of that in university. I was taught a rather rapid method to perform a calculation by one teacher, then switched institutions and got another teacher and book that didn't teach that method. Saved me something like 15 minutes on the exam for that course.
Teacher made a remark that the way I'd done it wasn't what he'd intended but that it was correct (so he did know about it, just considered it too advanced for the level of the course as it relied on knowledge we weren't supposed to have yet :)) therefore I was given full credits for the solution.

filker0
02-02-2006, 09:10 AM
Well... It's just as easy to write int = int + 1, instead of int++... What's the big deal?
char *v = "this is a C style string";
int sc = 0;

while (*v++)
{
++s;
}vs.
char *v = "this is a C style string";
int sc = 0;

while (*v)
{
v = v + 1;
s = s + 1;
}Although the two are computationally equivilent, the first is far more concise. If the instructors don't want you to use shorthand, why the heck are they teaching C++ in the first place? Do they skip over the use of "cout << variable" because students might confuse it with left shift operations?

The example is trivial, but I have other things to do.

CornedBee
02-02-2006, 09:33 AM
Try this one:

std::list< int > ints;
ints.push_back(1); ints.push_back(2); ints.push_back(3);

for(std::list< int >::iterator it = ints.begin(); it != ints.end(); ++it) {
std::cout << *it << ' ';
}
as opposed to the (supposedly) equivalent

std::list< int > ints;
ints.push_back(1); ints.push_back(2); ints.push_back(3);

for(std::list< int >::iterator it = ints.begin(); it != ints.end(); it = it + 1) {
std::cout << *it << ' ';
}

RobR
02-03-2006, 12:12 PM
Hi chrismax2

You'll be doing MT262 like me then.

edit>> Bear in mind that this is a low-level course. I don't even think we're going to hit pointers. I'm only doing it for the credits.

adrianxw
02-03-2006, 04:35 PM
Coding standards are a fact of life. If you are going to whine that you can't use "insert favourite construct here" when your house standard says you can't, you'll be out of a job.

Also no programmer would be caught dead using x = x + 1; when you have things like ++ and x += 1; Yes they would if they worked in a multi language code shop where the coding standards had been written to ensure that the majority of code written by the majority of coders in the majority of languages would understand what was going on.

x = x + 1;

Is pretty unambiguous regardless of your background.

Rashakil Fol
02-03-2006, 05:10 PM
It's interesting that you claim the linked list standard container, as well as instream and outstream iterators are poorly designed. Personally, I don't think so, but I'm sure you know what you're about.
That reminds me of a story I once heard.

One day, Bob decided, "If a man and woman marry, his cat better be the same color as the woman's, or else they wouldn't match, and that would be unfashionable." At that point in time, Mr. Uppity was riding by, and he was feeling desparate for a victory, so he stopped to answer.

"You enjoy your delusion!" Mr. Uppity answered. "The Fionas are the most fashionable couple in town, and Mr. Fiona's cat is not the same color as Mrs. Fiona's!"

To which Bob replied, "What are you talking about? Mrs. Fiona doesn't have a cat."

chrismax2
02-03-2006, 05:10 PM
Hey Robr

Good to hear from you, I will look out for you on the course site.

I got enough books, and as for adrianxw , I am not in a job and I don't have to agree with them if I dont want to. I just feel it's the wrong thing to do. Do you really agree with them yourself?

Yeah they dont even talk about pointers in the course, but then I got 8 different C++ books, so I can learn that through them. I kind of know them

chrismax2
02-03-2006, 05:13 PM
Do they skip over the use of "cout << variable" because students might confuse it with left shift operations?

The example is trivial, but I have other things to do.

Guess what? Yes they do skip cout <<
and cin >> as well!!!!

filker0
02-03-2006, 08:45 PM
x = x + 1;

Is pretty unambiguous regardless of your background.

There are places where post increment and post decrement are very valuable, and not using them requires the addition of a temporary variable to hold the old value of the variable.

Also, with pointers, though it's equivilent, which looks clearer?
struct foo *ptr;

ptr=get_FirstFoo();
while (ptr != NULL)
{
do_something(ptr);
ptr++;
}or
struct foo *ptr;

ptr=get_FirstFoo();
while (ptr != NULL)
{
do_something(ptr);
ptr = ptr + 1;
}More people have trouble with explicit pointer arithmetic than have trouble with post-increment.

Coding standards, however, trump all. I've had to forego all sorts of things I like to use (function pointers, conditional expressions (cond?v1:v2), #defines (yes, #define, in C, is banned one place that I worked. Don't ask), and arrays (in C++). You must adhere to the coding standards set by your employer, even if you think they're stupid.


I'm currently working at a place where the C coding standard requires casts wherever a "safe" type promotion might occur. There are some folks in the C programming forum who believe that an explicit type cast is an indication that the programmer is less than competant. (I'm not one of them.)

Syneris
02-03-2006, 09:35 PM
There is quite a difference in using x = x+1 and x++
Guess the output :P

#include <iostream>

using namespace std;

int main()
{
int x;
x = 5;
cout << (x++) << endl;
x = 5;
cout << (x = x+1) << endl;

system("pause");

return 0;
}

jwenting
02-04-2006, 12:46 AM
your example is contrived. It is never necessary to use x++, though x=x+1 might require more lines of code (which itself in many companies is a good thing because they judge programmer productivity based on the number of lines of code they produce).

CornedBee
02-04-2006, 04:49 AM
your example is contrived. It is never necessary to use x++, though x=x+1 might require more lines of code (which itself in many companies is a good thing because they judge programmer productivity based on the number of lines of code they produce).
Have you tried my example yet? There are classes that quite reasonably overload ++, but not += or +. Using x=x+1 with those results in a compile error.


yes, #define, in C, is banned one place that I worked. Don't ask
I do ask. How do you do symbolic constants then?

jwenting
02-04-2006, 05:16 AM
Have you tried my example yet? There are classes that quite reasonably overload ++, but not += or +. Using x=x+1 with those results in a compile error.

That is an error in the implementation of those classes, don't blame the operator for that...


I do ask. How do you do symbolic constants then?

you don't. You define some globals and hope noone changes them.

CornedBee
02-04-2006, 05:19 AM
That is an error in the implementation of those classes, don't blame the operator for that...
No, it is not. It is a logical consequence of the fact that these classes, by design, do not support arbitrary jumps other than by repeatedly using increment. It makes sense, it's intuitive.
I don't blame the operator. I blame the assumption that every class implementing ++ must implement +=.


you don't. You define some globals and hope noone changes them.
That's not sufficient. You can't use globals as sizes for static arrays.

jwenting
02-04-2006, 06:27 AM
no class needs to use an operator for anything. Operator overloading is a luxury, not a necessity.

You indeed can't use globals for array sizes, but you can use magic numbers.
Some people have decided that magic numbers are better than #defines, others have decided to use #defines everywhere.
Both decisions are flawed in that they don't take into account the inherent truth that there's a time and place for everything.

CornedBee
02-04-2006, 06:44 AM
no class needs to use an operator for anything. Operator overloading is a luxury, not a necessity.
Completely irrelevant. Whether the method is called inc() or operator ++, whether it's called add() or operator +=, the principle is that there are cases when incrementing makes sense, but adding doesn't. Thus, having a ++ operator but not a += operator makes sense, and any coding standard that says it must be written as x=x+1 is ignoring that.

filker0
02-04-2006, 11:34 AM
I do ask. How do you do symbolic constants then?
enums. *sigh*