Instantiate an array of objects and class stuff
Author |
Message |
Justin_
|
Posted: Sat Apr 08, 2006 10:02 pm Post subject: (No subject) |
|
|
Granted, maybe I am expecting too much from your common sense. The reason I am bringing this up is because this is a consistent thing. You consistently harp on my typing errors. Maybe you do just lack common sense in which case I appologize. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
wtd
|
Posted: Sat Apr 08, 2006 10:10 pm Post subject: (No subject) |
|
|
Justin_ wrote: When i copy and paste it into the forum it jarbles it, but this is beyond my control.
You can't edit plain text in a browser's textarea widget?
If your code formatting is perfect when you're done, that means you must put a fair deal of time into rejiggering things. Why take the time to do it wrong, then take more time to fix it? Why not just do it right the first time? |
|
|
|
|
 |
Justin_
|
Posted: Sat Apr 08, 2006 10:28 pm Post subject: (No subject) |
|
|
Okay man, I'll tell you what, since you never admit your wrong, we'll do it this way... I'll give an in depth analysis of which parts common sense should already tell you that I know. If you dispute any of this, I will then cite posts where I displayed working knowledge of them, taking time to ensure you posted in the same thread and said enough in those posts to indicate that you had looked over the code thoroughly.
Line 10 concerns me. In this case, 25 is a magic number. Where does it come from? Oh, yes... it comes from the upper bound of the "memory" array. Well, how about we replace that with "memory.length"? If you go back and decide to change it in the future, you'll only have to change it once. ----this one is GOOD.
Line 11 I have already referred to. ----BAD
Line 16: "scan" is called. It's supposed to return an int, but looking at the method, it never returns anything. Even if it did, what is the significance of the int it is returning? The method name isn't expressive enough to tell us that, nor is any intermediate assignment of the return value of "scan" to a variable used to tell us that information. ----SO SO, YOU DIDN'T HAVE TO MENTION IT DIDIN'T RETURN ANYTHING, THAT WAS MERELY A TYPO I MADE.
The "proceed" method has control flow that fills me with horror. Since "waysOpen" is theoretically not modified by the methods called within the "proceed" method, there is no reason for separate conditional statements. They should be using "else", or perhaps even better... "switch". ----GOOD
Line 34: where does this "ways" come from? Is this simply a typo? Using a switch statement would have made this mistake avoidable. ---WAYS IS INDEED A TYPO, DAH; NICE TIP ABOUT THE SWITCH STATEMENT.
General statement: In some places you explicitly prefix variable accesses and method calls with "this", and in others you do not. I suggest picking one style and sticking with it. Consistency counts for a lot. ----I PREFIX 'THIS' WHEN THE METHOD BELONGS TO THE CLASS BUT IS NOT DECLARED EXPLICITLY. THIS MAY OR MAY NOT BE BAD CODING PRACTICE BUT IT IS SOMETHING I PERSONALLY ADHERE TO.
Line 57: the "scan" method. You have one piece of code repeated several times. This strikes me as redundant. You should probably factor it out into a separate method with an expressive name. ----THIS IS DUE TO THE FACT IT IS UNFINISHED. NOTE: THAT THIS IS ONE REASON YOU SHOULDN'T DEVIATE FROM WHAT THE TOPIC STARTER EXPLICITLY ASKS.
Line 101: Why the empty constructor? ----UNFINISHED
Lines 110 and 116: Is that an extraneous semi-colon or are you trying to do something that's beyond me? ----BAD BAD BAD BAD BAD BAD BAD
General statement: with the amount of manipulation you do with the "directions" array, are you sure you do not want some resizeable container, like an ArrayList? ----OKAY, WELL I DON'T KNOW WHAT AN ARRAY LIST IS, NO HARM IN POINTING IT OUT TO ME BUT THE WAY YOU POINT THINGS OUT ALWAYS SEEMS TO BE IN A CONDESCENDING MANNER. EXAMPLE OF A COOLER WAY TO PHRASE IT: "Your direction array would be more suited for an ArrayList."
Again, take it with a grain of salt, I still think you're a cool guy wtd, its just my pet peeve is guys who purposely try to make me look like an idiot... |
|
|
|
|
 |
wtd
|
Posted: Sat Apr 08, 2006 10:37 pm Post subject: (No subject) |
|
|
We're all idiots. There are many many people out there who terrify me with the level of knowledge and wisdom they possess with regards to programming.
I've learned one thing that's more important than anything else:
The first step in learning is humiliation.  |
|
|
|
|
 |
wtd
|
Posted: Sat Apr 08, 2006 10:40 pm Post subject: (No subject) |
|
|
Oh, and I cannot get inside your head (yet...), so it's very hard for me to figure out when a mistake is a typo and when it is not. Errors are errors, and that includes the stupid ones. Having them pointed out is the first step in fixing them. |
|
|
|
|
 |
Justin_
|
Posted: Sat Apr 08, 2006 10:46 pm Post subject: (No subject) |
|
|
I agree with your points, but you are missing out on a lesson here. I am teaching you how to help people more efficiently by being honest, not one of those "Oh thank you thank you" types. You help me, I tried to help you.
Anyway, enough about this, life goes on... I am eating pizza yum. |
|
|
|
|
 |
wtd
|
Posted: Sat Apr 08, 2006 10:49 pm Post subject: (No subject) |
|
|
Did I lie somewhere?
Should I help people by leting them make mistakes and think those mistakes are correct?
Should I just tell people the correct way to do things without ascertaining an underlying reason the mistake was made? Would I really be helping them if I didn't help them gain a more solid fundamental grasp of the subject? |
|
|
|
|
 |
[Gandalf]

|
Posted: Sat Apr 08, 2006 11:25 pm Post subject: (No subject) |
|
|
Who's making you look bad? I'm positive wtd had no purpose to originally replying to this topic other than helping you (and others who may read this topic later on) out.
Personally, I think it's you who:
Justin_ wrote: are convinced [we're] out to get you. You're entirely dillusional though.
Justin_ wrote: My code is flawlessly formatted when it is complete. When i copy and paste it into the forum it jarbles it, but this is beyond my control.
The reason this happens is because your tabs are too large. I suggest you go into your editor/IDE's options and change them to something reasonable like 3 or 4 spaces. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Justin_
|
Posted: Sat Apr 08, 2006 11:29 pm Post subject: (No subject) |
|
|
Gandolf wrote:
The reason this happens is because your tabs are too large. I suggest you go into your editor/IDE's options and change them to something reasonable like 3 or 4 spaces.
Thanks, I hate IDE's but they make me use them, that tip will come in useful in the future. |
|
|
|
|
 |
apomb

|
Posted: Sat Apr 08, 2006 11:54 pm Post subject: (No subject) |
|
|
please, do us all a favour justin_ and admit that that was the way you were taught to format code... i was also taught to format my code the way you have it there.
code: | with (everything)
{
like (this)
{
and now i can see that it is horrendous to look at rather than the way wtd has shown
}
} |
so, thank you wtd, i was unaware that this way was incorrect. i am going to change the way i format my code. yes, i did look at your sig now, wtd =D
oh and if youJustin_ wrote: When i copy and paste it into the forum it jarbles it, but this is beyond my control.
then, how, pray-tel, did wtd get his code to look so good?  |
|
|
|
|
 |
Dan

|
Posted: Sun Apr 09, 2006 12:10 am Post subject: (No subject) |
|
|
Justin_ have you ever hured the expesion begers can't be choisers? When you are asking for help on a comunity like this you should be thankfull that you get your question awsered. Personaly i whould thinking that geting extera coments on my code and the way i am going about things whould be a bounes and that it whould help me learn. Persoanly i have difreing options about formating code but it dose not mean i whould make a small rant about it when some one says it dose not compley with the standers. I find it easyer to understand code when it is formated slight difrently then the java standered and for my own uses i could debug faster with my style. How ever i agknoagle that my way is not the norm.
As for typos in code, when posting for help it realy is a good idea to at least run your code threw a complier once and get it to a point where there are as few syentx errors as posaible so the peoleop helping you will have an easyer time debuing and will not make a big post of all the small errors witch you seem to dislike.
You have to rember that no one here is geting payed or any compesation to help you or any one eltes and we are just trying to share the knogeal. As such we should respected the peoleop that give us help and if you do not like there advice simpley don't take it, no need to compain about them giving to much help. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
 |
Justin_
|
Posted: Sun Apr 09, 2006 11:44 am Post subject: (No subject) |
|
|
See Hacker Dan, this is where you are wrong. I don't need to test my program if my question is about how I should use my classes and how to instantiate the arrays.
I used my actual code rather than waste time making up an example.
On the other hand if my question was: "Debug my code, I can't get it working" or something along those lines then yes I would be completely out of line to suggest that pointing out all of these errors is a waste of a person's time.
But I see that all you compsci.ca chaps don't care about my argument. I have to be honest I'm not used to people disregarding what I have to say, so I thank you all for showing me what it's like to be the underdog.
Still though, no hard feelings or anything, but I'm right. |
|
|
|
|
 |
Justin_
|
Posted: Sun Apr 09, 2006 11:59 am Post subject: (No subject) |
|
|
And CompWiz, if you were taugh to format code like that, you should have a brain enough to rebel against such inconsistent, disorganized code. Whenever I see a formatting standard that I think serves no purpose, I rebel as Hacker Dan does. But my rebelling would never entail a retarded alternative like the code you presented CompWiz. |
|
|
|
|
 |
md

|
Posted: Sun Apr 09, 2006 12:10 pm Post subject: (No subject) |
|
|
Justin_ you post code for others to critique. If you don't like it then don't post. wtd gave you some good sugestions (as he almost always does) and you take issue with it without reason. Either learn to accept what people say without getting angry (especially since it seems your original question was answered) or go somewhere else.
As for compwiz's code that was an example of bad formatting. It was pretty obvious too... try reading before posting; it allowes you to actually get all of the things you want to say into one post.
Personally I prefer the following formatting convention:
c++: |
void foo(int &bar)
{
int i = 0;
for( int j = i; j < i + 10; (j += 2) && (i++) )
{
whee();
bar++;
}
}
|
Nice and easy to read; blocks are well defined, variables easy to pick out and operators and variables well seperated. Plus it translates among many different languages so my code is always readable. |
|
|
|
|
 |
Justin_
|
Posted: Sun Apr 09, 2006 12:44 pm Post subject: (No subject) |
|
|
That's my favourite too Cornflake. And if you notice, all I said was, thanks for the tips, and these are the tips that you didn't need to tell me (for future reference). I wasn't trying to be rude but was trying to tell wtd what he can ignore in the future. Also, I touched on how it almost seems condescending the way he picks on my typo's, this was used as a device as well. The device was used to the effect of dissuading wtd from pointing out my typos.
So I was saying: Not necessary + it pisses me off. Two reasons why he shouldn't do it in the future.
I've seen many people asking for help, giving code that doesn't work whatsoever, but used as a device to better convey the question they are asking. So, do not tell me that I am submitting my code to be published in the New York Times when all I want are straightforward answers, using my code as a device to convey the questions I'm asking. |
|
|
|
|
 |
|
|