The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
"What's the point in declaring things as private? Just declare everything as public. That way nothing will break."
To which you replied the following.
that last sentence demonstrates without a doubt that beneath the haughty 'I'm a real programmer' exterior lies a secret - 'I have got no idea what I'm talking about'.
I contend that it is you who does not know what they are talking about. While declaring variables locally within a function has it's uses, so does declaring the variables globally so that the whole program can see and use those variables.
The way it works is that every time you enter a function, locally declared variables have memory allocated to them, and when you step out of that function, the memory is de-allocated. This takes time, ok sure it's only a few microseconds but consider this. If you write a program where timing is a critical factor and you are running through a particular function 6000 times or more, which would you choose? If you answered privately declared variables you would be wrong, the reason being is that those few microseconds add up, they are the difference between a program taking 1.5s to execute from beginning to end, and the same program taking 15 seconds to execute from beginning to end.
Yes it is generally an unsafe practice I will agree, and should only be used when absolutely necessary, but when you have something that is time critical there really is no other viable option than declaring globally.
it also has the added bonus of forcing a dev into being more diligent in their programming, because they are forced to check their program a whole lot more often than what you would otherwise, knowing which variable is used, when it is used, how it is used, and when it can be reused, if indeed it can be reused at all.
So yes, programs written where everything is declared publically has their uses, but it is a very niche market, crytography is the prime example.
I think you missed the point. There may well be times when making all of the variables public is the right way to go, but based on what that guy said he wasn't in one of those situations, he was just clueless. If the argument is to make them all public so "nothing will break," then it's obvious that there's a serious underlying problem, and making everything public so "nothing will break" just hides the problem and makes it worse.
No matter how many cases there may be for using global variables, the statement "What's the point in declaring things as private? Just declare everything as public. That way nothing will break" is a very dumb statement that reeks of programming ignorance. The guy who said that clearly doesn't get "the point" of making members private, so it's very clear that he has no idea what he's talking about and knows next to nothing about OO programming. If I heard another team member say that, I'd make a mental note that the guy is dangerously incompetent.
Yes the statement "So nothing will break" is completely incompetant, the point I was making was that If you are going down the path of global variables, for whatever reason, you have to pay a whole lot more attention to what you're doing, to make sure nothing will break, ever, under any situation you can possibly ever concieve of no matter how unlikely it may be. It may increase dev time significantly to ensure that level of unbreakabbility, but in some situations it's worth it. I am not saying nothing will break ever, because it's impossible to develop any software that is entirely 100% bug free within the time constraints that dev's are given, but declaring globally helps put a dev into the mind set of extreme mitigation, the person who made the statement could have been good enough to declare globally and have the program unlikely to break, or he could have been utterly incompetant, the choice of words is unfotunate, assuming the former rather than the latter, a better choice of words would have been "so it's unlikely anything will break". I got the impression the OP was saying that declaring globally for any reason is bad, when it's not, sometimes it's the best thing you can do, so I made that point.
I find that anti VB.NET zealots are useful:
1) I know not employ them.
2) I can use VB to make and sell successful products without their "competition".
3) They give me great amusement in their twisty attempts to justify their biogtry!
"What's the point in declaring things as private?...
That's definitely the statement of someone without nearly enough training in coding. Hopefully it was meant as a sincere question from someone seeking knowledge, instead of a self-satisfied ignorant comment and you didn't hear the real question. It does read like an ignorant comment on the language.
I don't mind asking ignorant questions when I already know I'm ignorant of the answer. You could have asked him "Do you really want an answer to that question? I'd be happy to spend a little time explaining it to you." That would cover your mishearing the real question AND telling him his statement was wrong if he really was giving an opinion. Gives him a chance to realize he still has things he needs to learn or to look for better ways of asking real questions.
To me, anything that will alter the behavior of the machine was written by a "real" language. It just may not be one I'm familiar with. Therefore HTML is a "real" language. (I've heard opinions that it also isn't a real language.) Of course XML wasn't a real language until the DOM drivers became common-place.
Your three options seem a little narrow and biased, exactly what you are accusing those who do not like VB.Net of being.
For me personally I do not like VB.Net as a language. It it far too verbose and has way too many keywords. For a number of years it lagged behind C# on supporting new features of .Net. And Microsoft should have never created the Visual Basic 6.0 Compatibility library. I prefer languages that have a statement terminator that is not a new line and just gravitated to C# because I come from a C-based background and enjoy its terseness.
Warning, I am using a broad stroke to generalize below and know that there are good and crappy programmers regardless of the language.
My biggest grip with VB.Net however is the type of developer that it tends to attract, that being people from pre-.Net VB. VB was never a very good language and didn't have good OO support. Putting a blob of procedural code in a Class file in VB6 seemed to be as object oriented as most pre.Net VB developers went.
The majority (again, not all) of VB.Net developers I have seen over the last 3 years or so haven't even put in the effort to learn the greatness and fullness of the .Net library, instead opting to use the Visual Basic 6.0 Compatibility library to hold their hand.
To me it seems languages such as VB and Cobol tend to attract someone who is more of a business person over a developer. The type of person who isn't as passionate about the technology and more about just getting a job done (there is nothing wrong with that). I am just the polar opposite; I am very passionate about the technology and always want to stay current (it provides for my family and I) as well as the overall quality of the final solution.
When you mix in the people who are passionate about the technology with those that are only interested in learning the minimum tools to get the job done you will get petty squabbles. This is nothing new and will continue in the IT departments around the world. The business-geek versus the uber-technology-geek.
VB.NET is the language that really got me interested in programming in the first place. I took a Java class and by the end of it I didn't really enjoy it that much and started to think that programming was not for me. Then I took a VB.NET course and everything changed. Programming was fun. I built good stuff with VB and was able to pick it up quickly. By the end of that class, I was in love with programming. Now I program mostly in C# and I actually prefer it over VB after having used both for a while. Regardless, VB is a real language that you can do anything you want in. Anyone saying otherwise is either clueless or just a jerk. There has been great stuff built with VB, for example The Ocean Framework[^].
Personally I am happy with visual basic and no longer care about other languages struggling to make their mark. If you have a good look at what is growing in momentum is SQL Server. It is now powered by visual studio the home of visual basic that houses the other languages through .net.
I believe that we will have to learn how to become DBA and learn SQL. If the power is given back to the DBA the only options coders will have are to drag a Data Object to a html 5 form and any code will just take away from what is supplied.
Microsoft SQL Server just another tool in VB Land.
Redundancy is another word for coders
Coders creating a service, coders creating forms to recreate the same code, who create code full of vulnerabilities and holes.
Why not make and set the rules on the server and drag and drop away?
I've pretty much only used vb6, vbscript and, of course, vb.net from 1.0 through 2.0. I've taken an extended break from doing any dev work and have been learning C# off and on for a few years now but haven't actually tried my hand in putting anything together.
I bacame frustrated as I observed fewer and fewer people writing coding tutorials and other examples with VB (including msdn magazine, as I once noted on here). I started to see that nearly everything being written and done was with C#. This trend has continued for several years now. It is because of this that I have decided that I will just switch over and move forward with C# even though everything I already know isn't C#. Without all those examples and how to's that are tremendously avail for C# but not so much with VB.NET (any longer), the choice for me has become more clear.
A number of times in the past when I was creating more complex project with VB.NET, I was unable to find the code/example/help I needed or I'd get some example written in C# that I was unable to convert properly (after using converters or asking for help in converting or trying it myself).
I've decided to move on from vb.net because .. it appears, most everyone else has (or everyone else that was providing code examples/articles/help).
I'm sure if we compare the number of new articles and code examples between the two, we'd see a massive, Massive gap.
Well, instead of acting like a gerbil, you could act like a lemming and jump off a cliff. Or, you could run to the nearest saloon and order as much beer as you can handle. Or, you could decide to go to bed because that was a stupid statement. When you die in the morning because the super-nova burned you to a crisp, you might have a split-second to think "Oh, I cudda had a V-8" (I hear its good for the hangover you might have had if you had time to have one.)
Kinda reminds me of the short-story where the moon was suddenly 10 times brighter. Everyone is enjoying the evening event except one guy who realizes right away this is his last night of life. Turned out half the planet died because of a superflare, not a nova and they were OK. Then the catastrophic weather killed everyone else, it just took a while to reach them. Real up-beat story.
Time and again we witness people desperately cross-posting the same query across multiple forums in the website. I trying to see if instead of reprimanding them why can't we have smart validation of 'similar'* messages posted by the same user in a 'specified'* time-frame.
* These can be configurable parameters based on user behavior and can be used as a valuable heuristic tool later.
And again I am not sure if this strategy would immediately befit as a site suggestion and hence initiating this brainstorming in Lounge.