"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
This is so wrong that it IS religion.> Global variables make it more difficult to verify #2.
> Beyond small programs, global variables make #3 difficult to achieve
There should not be "anything" difficult, let alone "more difficult".
If anything about your program is difficult, I would say YOU need to look for ways to improve YOUR design.
This is the truth. The difference between 2 threads tapping the same data through a pointer or method to a class and 2 threads using global_anyData is that global is direct. The risk of errors and difficulty of tracking errors increase with indirection.
Global is global is global.
Do you people NOT get that?
Why can't any of you hardliners explain why it is that you think global is magically not global if you stick it into a class? Using the same data globally whether directly or indirectly is still using global data.
Yes, I'll admit, using global data can get ugly.
But putting lipstick on a pig does not make him pretty.
All such data requires being "grouped" and requires quality comments.
All such data requires safeguards prior to the actual usage, like checking if null, etc.
But I'll say it again...
Global is global is global.
Yes, it really is. I wouldn't write it any other way.Is your code really more readable?
Is your code really more maintainable?
He sounds like my twin, so we would be best friends.The independent reviewer is a scrupulously honest and cynical bastard, with tremendous experience with large software systems, and also has a reputation for recommending that the customer reject about half of the systems that he assesses.
novacain,
Thanks for staying on topic.
I currently do the same with my top level windows.
I also pack some processing into a few WM_USER+#'s to limit outside functions.
Everyone else,
It is my hope that down deep you know I am right.
Meaning, the goal is 1-efficientcy, 2-stability, 3-readablity.
The rest is bragging rights.
For me, I can brag that I really do have a very nice, well organized GDI app.
That's all that matters.
Thanks, and enjoy your week.
Is anybody else okay with this sort of trolling here? Because I'm not. It took me four pages of comments before I realized it, so hey, he's good. Also, I'm ........ed and don't feel much like contributing today. I'm out.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Sorry, but your claims simply go against the experience of many programmers who work on larger programs in teams. You don't see it because you are working with a program for which you can get away with it. ("It's my project, my code, my app, it's just for me - not a corporate project group of programmers.")Originally Posted by motocross1
I do not think that global state is magically not global if you stick it into a classOriginally Posted by motocross1
Until your code has been reviewed by other programmers, that is just a claim, possibly even delusion. I know I suffer from such delusions of perfection, otherwise I would not deign to show my code to others The difference is that I have the decency to respond positively to reviews and improve my code.Originally Posted by motocross1
No objection to that. The thing is, when you say things like:Originally Posted by motocross1
- There ARE times to use static data.
- There ARE times to use global data.
- For the record, I agree the fewer the better - I strive for none.
I agree. Yet, the overall outlook you give here is that you don't quite practice what you preach, and consequently you have a lower bar for globals than desirable, despite claiming to "strive for none". If you did strive for no globals while recognising that in some cases global state may be appropriate, you would not have started this thread in the first place, since you would have determined that "in my current project, it makes sense to use them" and then just used them where they really make sense.
Calling the ideas of cohesion versus coupling and such "high-minded concepts", attacking strawman arguments concerning the use of classes: these don't help your case at all. They make you appear like you started this thread merely to pick a fight with professionals rather than learn from them.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
For all of the insults.
I AM freakin awesome, period.
Here's my app (no way I'll post the code):Attachment 11541
What are those, simulation statistics? Or do you use realworld data?
Devoted my life to programming...
Real world data - that's today's market.
It's your last chance to buy STRI at those prices.
i don't get it. what's so awesome about those charts?
as to the topic: if you're manipulating globals, a singleton with accessors will give you much better control over how and when they are changed, and will allow you to use them more easily and safely in a greater variety of contexts, for example: multi-threading.
I'm actually stuffing a few globals into a new singleton right now.
I found another C++ standards that I like:
C++ Programming Practice Guideline
Of course, I will still keep a few globals by choice.
"what's so awesome about those charts?"
The features: zoom, trendlines, different timeframes, live prices, price alerts, etc.
O_o
Dude, please don't "like" something I say if you don't understand it; you might accidentally convince me that you are worth helping further.
Thankfully, taking this thread into "Look how awesome I am even though I'm not listening to you!?" territory saves me from my confusion.
[Edit]
Oh, and you weren't insulted until a couple of us realized that you only wanted someone to confirm your preconceived notions.
Strangely, that's exactly why some people seek out religious groups.
[/Edit]
Soma
just so you know, neither features nor speed translate into great code. that's judging a book by it's cover.
good code is like good prose; being factually correct on a wide variety of topics is not the same thing as delivering a message in a consistent, clear, and coherent manner. having code that does many things and doesn't crash is not the same as having good code.
phantomotap,
I "like" what you posted because you obviously understand the difficulties in Windows GDI.
But I "love" it because you said:
"That's the biggest problem with global state; you can decorate it all you like, but you can't solve all the problems unless you literally never use it."
As for:
"you only wanted someone to confirm your preconceived notions"
No, I wanted to know the best way do globals (other than not use them).
That's it.
Surprisingly, brewbuck nailed it when he said "prefix them with g_ or Global or something like that". But what the right hand giveth, the left hand taken away: He then said, "so you can easily search for them and measure just how much the code sucks".
He is the perfect example of the larger problem here (which is actually inescapable)...
There are 3 groups of people who come to this forum:
1) Students
2) Professionals who help the Students
3) Me - Someone needing information, not advice
Sure, Students need to know the "corporate team project" way of writing code.
They come here dumb as a brick and will one day be a Professional, so they need to hear preaching and brainwashing - the more the better.
The problem is that the Professionals deal with so many hordes of Students that they start preaching to anyone who starts a thread.
I KNEW the word "global" would set-off a frenzy.
I tried to curtail it, but then, I TOO got sucked into the debate.
Oh well, I'm sorry I stepped on some toes.
But did I really?
I think it's okay if people disagree with convention.
There's no reason to treat them like they are dumb as a brick, not even if they ARE a Student.
Hey, here's an idea, let people screw-up their own projects if they think it is best.
But when everyone berates you and tells you that you suck, then you gotta say:
"I AM THE BEST - I AM FREAKIN AWESOME - I WILL NOT LISTEN TO ANYONE"
That's it, unless someone wants to say something nice.
Seriously.
Please let this thread die.
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss
I don't think that is quite fair, because I think a troll is someone who intentionally provokes an endless argument by intentionally ignoring/misconstruing everything that has been said and intentionally repeating the same thing over and over again, with the intention of baiting others and de-railing legitimate discussion. If the OP is a troll, he's pretty good at it, lol, because I still believe he believes what he says.
The pragmatic realist in me says, stop responding, because in reality, many (or most) adults, when confronted with evidence of the fact that they are wrong about something they perceive as potentially contentious, will not back down; no matter how strong the evidence, they will reject it in favour of more and more ridiculous justifications for their otherwise rationally untenable belief. In fact, people will ruin themselves and others in this way, so que sera sera.
But the foolish optimist in me says, a person confronted with evidence of the fact that they are wrong about something important to them has a great opportunity, psychologically, to do something that might be new to them: recognize you're wrong, that you've made a big mistake, and that you, way way way more than anyone else involved, stands to benefit by recognizing this and taking it to heart, not just with regard to this issue but with regard to life in general. If you are that kind of person.
Sigh. I don't hold my breath. It hurts too much.
No, you made an app with some graphs and buttons in it. What you are is freaking PARANOID.
Okay, so pretty much everyone in the first two groups has bent over backward trying to help you understand, you can now dismiss this as "advice" and not "information". At this point, I presume the only thing that would count as "information", ironically, would be if we really could send God over to sort your head out.There are 3 groups of people who come to this forum:
1) Students
2) Professionals who help the Students
3) Me - Someone needing information, not advice
I said it before and I'll say it again, lol:
Originally Posted by MK27
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
I'm a believer now, I've seen the light. Glory halleluha!!!
I "Like" it all. Like, Like, Like.
Are you happy now?
How about ending the thread, jerk?