d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Make Me A Better Programmer - From Step 1
Prev1789101156Next
Add Reply New Topic New Poll
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 28 2012 11:41pm
Quote (carteblanche @ Jul 28 2012 12:21pm)
Learn how to do unit testing or test driven development, then you can ensure each function works correctly by itself.


is that something you need a special compiler etc for?

Quote (Xanaxiel @ Jul 28 2012 09:15am)
Ohhh man, data structures. They make you do the hard parts, but iRL you get to use the methods inside libraries for sorting and others (like Collections.sort(array)) in Java.


ho man that would be so useful

This post was edited by Eep on Jul 28 2012 11:42pm
Member
Posts: 30,717
Joined: Sep 19 2007
Gold: 254.00
Jul 29 2012 11:43am
Quote (carteblanche @ 28 Jul 2012 11:21)
Learn how to do unit testing or test driven development, then you can ensure each function works correctly by itself.


tdd is a useless buzzword and adds no value to the development process
unit tests could be handy, provided this guy knows enough to identify edge cases
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 29 2012 01:22pm
Quote (J_B @ Jul 29 2012 12:43pm)
tdd is a useless buzzword and adds no value to the development process
unit tests could be handy, provided this guy knows enough to identify edge cases


not yet :[
Member
Posts: 30,717
Joined: Sep 19 2007
Gold: 254.00
Jul 29 2012 01:51pm
Quote (Eep @ 29 Jul 2012 13:22)
not yet :[


it's worth using them now so you can get practice identifying those edge cases

for a sorting algorithm, your test cases could include:

empty list
one element list
list that's almost sorted except for one element
list containing duplicates
list entirely backwards
list with all negative numbers
list with some negative numbers

I'm probably missing a few, I'm not QA lol
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 29 2012 04:17pm
Quote (J_B @ Jul 29 2012 02:51pm)
it's worth using them now so you can get practice identifying those edge cases

for a sorting algorithm, your test cases could include:

empty list
one element list
list that's almost sorted except for one element
list containing duplicates
list entirely backwards
list with all negative numbers
list with some negative numbers

I'm probably missing a few, I'm not QA lol


I did all of these manually and they worked afaik.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 31 2012 01:15am
Can someone explain this better to me?


So if you paid any attention at all to my last project (for whatever reason) you would have seen that my solution to the selection function was adding an IF before the swap


According to my professor, this was the wrong way to go about it.

According to him, I was simply 'bandaging' a problem and not fixing it.

What HE did is change the values in either findmax or selection. Something became -1 or to that extent.

He never told us NOT to use an IF statement. I tested many cases that seemed like they could be problematic. It worked everytime.

So I have to ask -

If you do something, like add an 'if' and the program works as you expect, is that bad practice? If so, what other things do you do to figure out problems? I for the life of me tried to wrap my head around the problem this weekend but because he didn't properly explain selection sorting etc I just didn't know....

I obviously don't want to be in the wrong.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jul 31 2012 10:57am
i myself dont even know this. if it works it works, but i can see where hes coming from. you are not actually fixing the logical errors with the other functions, just simply adding another piece of logic overtop of the errors to fix it. should paste bin your current code so i can take a look at it.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 31 2012 01:46pm
Quote (AbDuCt @ Jul 31 2012 11:57am)
i myself dont even know this. if it works it works, but i can see where hes coming from. you are not actually fixing the logical errors with the other functions, just simply adding another piece of logic overtop of the errors to fix it. should paste bin your current code so i can take a look at it.


http://pastebin.com/d7zciZkf


that was the final project I turned in.

void selection() is where I made the change.

In class, he suggested changing the way swap works in it or to change something in findMax() to like *something -1* instead of just *something*

edit: again anything that seems silly was the professors orders. He made us use numTween twice to make sure that everyone in the class was doing it right (some people were trying to make the values local to the function)

This post was edited by Eep on Jul 31 2012 01:47pm
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Jul 31 2012 01:49pm
Quote (J_B @ Jul 29 2012 12:51pm)
I'm probably missing a few, I'm not QA lol


surefire sign of a terrible programmer: they think that automated testing and considering edge cases is QA's job.

This post was edited by irimi on Jul 31 2012 01:50pm
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jul 31 2012 03:58pm
when does one learn about edge cases
Go Back To Programming & Development Topic List
Prev1789101156Next
Add Reply New Topic New Poll