1 |
>> #include <iostream> |
2 |
>> using namespace std; |
3 |
>> int main(){ |
4 |
>> cout << "Hello World" << endl; |
5 |
>> return(0); |
6 |
>> } |
7 |
> |
8 |
> |
9 |
> according to the ml posts I've read this is bad practice and one |
10 |
> should use std::cout whenever/wherever there is need of it. I'm |
11 |
> good at bad practice though ;) |
12 |
|
13 |
That's people getting carried away with a rule-of-thumb and taking |
14 |
it to it's black-and-white extreme while forgetting the whole reason |
15 |
for the rule in the first place. |
16 |
|
17 |
The more namespaces you have, the more likely you are to confuse |
18 |
them, thus the rule that objects should be expressed in their |
19 |
namespace prefixed form. No problem there. |
20 |
|
21 |
But what is the point in the above example? None and the "using |
22 |
namespace" form works just fine. In fact it could be the prefered |
23 |
form on a large program with a simple namespace schema. The reason |
24 |
for this is the simple fact that working memory can only hold on |
25 |
average 12 items. By not having the objects prefixed with their |
26 |
namespace you can hold more code in working memory when, for example, |
27 |
debugging, making the job easier on you. |
28 |
|
29 |
-- |
30 |
Thomas M. Beaudry |
31 |
k8la / ys1ztm |
32 |
|
33 |
If at first you don't succeed, work for Microsoft. |