|
I might offend, I'm also a vb guy!!
At least, a I try to be as [C]sharp minded as possible
|
|
|
|
|
Alberto Biasiutti wrote: I'm also a vb guy
Maybe you don't have a choice, in that case you're forgiven as long as you keep that C# minded brain working
V.
|
|
|
|
|
Alberto Biasiutti wrote: I'm also a vb guy!!
We'll.
Speak.
Slowly.
Then.
I worked in VB for about 15 years and I am pleased to have escaped. For now.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Every time I come to CP, I feel dirty because I use VB!
I'll denounce you for discrimination!
|
|
|
|
|
Nagy Vilmos wrote: I worked in VB for about 15 years
That explains the lunchtime drinking...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
OriginalGriff wrote: That explains the lunchtime drinking.
No, that was the early part of career working in COBOL. VB is responsible for the night time drinking.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
I needed a series of random numbers, so I used the following code:
Dim t As Integer = Environment.TickCount
Dim n(9) As Double
For i As Integer = 0 To 9
Dim r As New Random(t)
n(i) = r.Next
Next
You would not believe the facepalm I gave myself when I saw what I did wrong.
|
|
|
|
|
I'm sure you know the err, but some other points:
0. If you need random, use at least two unrelated sources to seed the sequence. I use a combo of ticks from the clock and position of the mouse.
1. Within an application only ever instantiate a single randomiser and do it as the first step of the run.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
I know, but there are just some times, especially when constantly interrupted. I usually get one or two of these a week, where I just look at something I did while trying to juggle too many things, and go WTF? Something basic, that I learned in high school, and I just space out or something.
At least it always provides some comic relief later. And I usually need it
|
|
|
|
|
Why bother passing in a custom seed if you don't need one anyhow?
The default constructor of random seeds itself appropriately
|
|
|
|
|
Are all the numbers the same? At least that would make it a lot easier to find.
|
|
|
|
|
I usually just use this[^] when I need random numbers.
|
|
|
|
|
Do you work for Sony, by any chance?
|
|
|
|
|
That was my first thought when I saw the post. The only difference is that he needs to roll the dice 9 times .
|
|
|
|
|
Don't be too hard on yourself. Most people never realize what the 'pseudo' in 'pseudo random number generator' is about. Just turn things around and it may even come in handy at times.
Do you remember the old game Elite? The game had about five galaxies with 256 star systems each. Each system had its own coordinates, a description of the planet and inhabitants and individual prices and stocks for all goods. A good old C64 would have to sacrifice a good part of its tiny memory to store all that.
I'm quite sure they did not. For example, you might generate a hashcode from the coordinates of a system. Then you initialize a random number generator with this hash code and use it to randomly generate the parameters of that system. Since the hashcode will always be the same for that system, the result will be the same every time and can be recreated at will. This completely eliminates the need to store any of the static information. Just the things which are variable, like the current stocks, need to be stored.
For a 'small' game I'm working on I have made a star map with 4 billiion universes with up to 4 billion galaxies, each with 4 billion x 4 billion x 4 billion coordinate points. Each coordinate point has a chance to contain a solar system, each with one or more stars of different types, a variable number of planets of many types and the planets may also have moons. Memory or storage costs: The XML configuration files to work out a convincing star system.
"Dark the dark side is. Very dark..." - Yoda
--- "Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi
modified on Wednesday, September 14, 2011 9:43 AM
|
|
|
|
|
The whole point was I know better... it's just sometimes I get ahead of myself when I type, and then when I see what I did I'm going "WTF?". Sometimes, you just know better, and do it anyway.
|
|
|
|
|
Sure, but then I would not really see it as something to be ashamed about. Such things do happen. Real code horrors come from people who don't know better and don't think twice about what they did. Many of them simply are inexperienced and will learn in time.
"Dark the dark side is. Very dark..." - Yoda
--- "Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi
|
|
|
|
|
That may be true, but there are days when you can identify me by the palmprint on my forehead.
|
|
|
|
|
|
I screw up as much as anyone... I just consider it a plus that I notice when I do.
Of course, if I don't notice a mistake, did I really screw up? I'm going with no.
|
|
|
|
|
I think the error was naming the variables as "n", "t" or "i".
|
|
|
|
|
Last week I wrote a small library that would either startup a Form or focus an already open one, based on the Form you wanted to start. My boss wanted me to make a prototype that he could approve (approval can be reached by not using to much interfaces... He doesn't like them because it will make code harder to read and debug). So I was done writing it and showed him what I had made. First thing he said was that I didn't have comments in my code (well duh, he told me to finish it asap and he wanted to approve it first). So I had to put a comment above the Function FormCanBeShown that returns a Boolean. Yeah, what possibly could it do?
Even better, I had the code
frm.Select
Boss: "What does this do?"
Me: "It selects the Form... Basic Microsoft functionality..." *Hoovers over it to get MS IntelliSense prove of what I just said*
Boss: "Well, I wouldn't know that, put some commentary there."
And then the code looked like this:
frm.Select
Really, was that necessary[^]?
It's an OO world.
|
|
|
|
|
No, what's necessary is to say "It selects the Form... Basic Microsoft functionality... Hovers over it to see what MS thinks it does" instead of
Naerling wrote: Me: "It selects the Form... Basic Microsoft functionality..." *Hoovers over it to get MS IntelliSense prove of what I just said*
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Considering that your boss asked you to write something up (who should have some knowledge of coding) and you gave him a one liner to get what he wanted working and couldn't understand that really does raise questions about his compentency. But there are two things you can learn from this.
First you said that it's the default microsoft functionality (for the dot net framework I'm assuming you are saying here) which is really good but what if the person hasn't programmed using the dot net framework or didn't even know that function existed. I self teach myself a lot of stuff but unless you get training covering every functionality of each object model you can't know everything that's 'default' unless you have heard of it. You can't know that your boss knows about it and even if he did how does he know your extending the functionality or writing something totally seperate.
Secondly not all people are good at reading things and having a code comment explaining the end result of the function call is a good idea especially with a single word like select is used to execute an action (i.e. select an open form, closed form, some magical form, some specific class form).
My boss recently asked me to extend functionality on an existing system and then said that I had to use a specific table despite the fact I started designin it using a new table. Over the weekend I went through the system to see the impact of using that table instead of creating another one specifically designed for the purpose. I then sent an email with a list of what was needed to do to get either option working (i.e. change this, do that, etc). When I went into the office he said to see him because he didn't understand the email and after spending a bit of time talking and drawing on a whiteboard he got the idea and went yeah I can see your point and create a new table for it for now. Had I given him a few screen shots and some pictures with a few explinations it he would have been able to understand what I was saying easier.
P.S. Also intellisense isn't everywhere. If you, oh I don't know, say paste the code on the web where is my intellisense ? I suppose it's a good think we install spell checking on our whiteboards to make sure we find typos when people write things down .
|
|
|
|
|
We have programmed with .NET WinForms for 7 years now, my boss too (and probably more than any of us). Documenting methods that are already documented just seems like such a waste of space.
Our code is full of such obvious comments...
Label1.Test = "Saved successfully"
customer.Save
Do you see the problem? Everyone can see that the TEXT of a label is set, even though comments say caption (all throughout the software, copy/paste mentality). Even worse for the product/customer. People copy and edit code, they don't edit comments.
If I had to comment each and every .NET Framework method like that the development time gets quite a bit longer...
I have learned to not read comments, because they do not currently add any value to our code, just clutter. Every comment needs to be maintained, just like any other piece of code. For some reason it never happens.
And everytime my boss asks me to comment the obvious once again I die a little inside.
I'm not sure what is worse, uncommented code or overcommented code. At least uncommented code says what it does (right there in the code), if comments do the same is always a question.
It's an OO world.
|
|
|
|