Computer Science Canada Programming Etiquete |
Author: | Insectoid [ Mon Nov 17, 2008 6:19 pm ] |
Post subject: | Programming Etiquete |
I would like some input as to various coding practices out there, specifically one. (I know, I said several, but I meant one). My teacher hasn't been programming for a long time (a decade or so), and has some odd coding conventions that he forces on us. One such convention is the use of operators '+=', '-=', '*=', etc, or rather in his case, the lack of use of those operators. Seeing as this convention is supported in many languages, and his practices may be quite dated, what is the current norm? Is 'foo = foo+x' still preferred over 'foo += x'? (In fact, when he saw that in my code, he had to ask what it meant). I would like to know, so that when I go to university, and eventually work, I won't get yelled at for stone-age coding. If any other important convention need be stated, feel free. But the important one I want answered is the += vs =x+y. |
Author: | syntax_error [ Mon Nov 17, 2008 6:25 pm ] |
Post subject: | RE:Programming Etiquete |
use either; doesn't really affect; however, the combination of the operators saves space; its read the same way though. |
Author: | Insectoid [ Mon Nov 17, 2008 6:40 pm ] |
Post subject: | RE:Programming Etiquete |
So, in the 'real world', nobody would care if I used +=? I like += because it types faster and reads smother. I also process it faster in my brain. (Foo+= 1 means 1 to itself, Foo = Foo + x means 'add x to foo, assign foo to foo'). Sure, I comprehend both so fast I barely notice a difference, but while I can skim through '+='. I am forced to read the whole line of '= X+Y'. |
Author: | md [ Mon Nov 17, 2008 6:44 pm ] |
Post subject: | RE:Programming Etiquete |
In the real world no one would care. That your teacher doesn't know what they mean though speaks volumes about the state of the education system. |
Author: | Insectoid [ Mon Nov 17, 2008 7:02 pm ] |
Post subject: | RE:Programming Etiquete |
Well, he used to work on many programs and hardware (he used to be a super-mainframe technician), and wrote a program that simulates the stock exchange, complete with automatically-written news reports that were quite funny to read, and a system to allow users to connect to his website and buy/sell fake stocks. This guy was a programming genius. Just a bit out of date. |
Author: | Vertico [ Mon Nov 17, 2008 8:05 pm ] |
Post subject: | RE:Programming Etiquete |
It depends where you work and with who. Usually people will not care, especially in smaller projects, but when you work with larger teams, a continuous programming style needs to be help. For example, I did co-op for a small internet company last year where another student and myself basically updated older code. They asked us to keep the coding at the same standards because management had come use to seeing the code in a certain format. |
Author: | Zeroth [ Mon Nov 17, 2008 10:34 pm ] |
Post subject: | Re: Programming Etiquete |
What matters most is if there is a coding style document. Whatever it is, just follow that. Otherwise, use what you are most comfortable with. |
Author: | Dan [ Mon Nov 17, 2008 11:23 pm ] |
Post subject: | RE:Programming Etiquete |
In the real world most languses have one or more offical style guides from the peoleop that make the langue. Then each project (or at least any project of resoanble size with muptial programmers) will have it's own style guide lines for that project (witch is ushesly an extension of an officle style guide for the langue). For example python has pep8 witch is a Style Guide for Python Code (http://www.python.org/dev/peps/pep-0008/) and invidual projects made in python might have there own style guide witch says somthing like use pep8 with the addtional guide lines of.... In real world enveroments with strict code reviews i could see peoleop caring about things like x += 1 vs x = x + 1. I have aucatal had peoleop care about if my python comments had a space affter the '#' or not. But it is a good thing as you want standaization accorses your project and some times a bad standatrd is better then no standard at all. When it comes down to it you want your code to be the easyest to read by others. |
Author: | Tony [ Mon Nov 17, 2008 11:26 pm ] |
Post subject: | RE:Programming Etiquete |
Performance wise, it doesn't matter -- both compile to identical machine code. University will (ideally) concentrate on your understanding of data structures, algorithms, ect. You will largely be responsible for learning the implementation on your own. As many have pointed out, code is as much about the communication with fellow developers, as it is with machines. As such, coding conventions facilitate easier understanding for the team; and it's up to the team to establish what those conventions should be. |