|
TheresaJayne posted:But as a 100% must do thing - I disagree. FFS why test the setters and getters? We know they work they have always worked and if the developer is suitably obtuse they can have some devastating effects on code You shouldn't test getters/setters, in my opinion, unless they happen to have side effects (which they probably shouldn't). This is why code coverage % numbers are dumb. You only want tests around code where they add value. quote:
But...that's not even testing a real object. That's literally making sure your mocking framework works
|
# ? Jan 1, 2015 17:14 |
|
|
# ? Jun 8, 2024 05:27 |
|
Axiem posted:You shouldn't test getters/setters, in my opinion, unless they happen to have side effects (which they probably shouldn't). This is why code coverage % numbers are dumb. You only want tests around code where they add value. I know and at work over 50% of the tests are like that
|
# ? Jan 1, 2015 18:09 |
|
Axiem posted:But...that's not even testing a real object. That's literally making sure your mocking framework works I've seen a lot of that in the real world. When some people get into TDD they get into the mindset of "everything must have tests" they look at code that doesn't really need tests and shoehorn a test in anyway. It usually ends up like that, or it ends up brittle. I knew a developer that loved side effects in code and when they had a method A that called method B, and method B had a side effect that was hard to test they'd just write a test verifying that A called B. You could totally change how B worked and the test would still pass because it wasn't checking for behavior, it was checking that the code was hooked up a certain way.
|
# ? Jan 1, 2015 19:22 |
|
That sort of thing is why I cringe at tests that use mocks when they don't really need to. I've seen far too many tests that look like they're testing something interesting, but in trying to test only one unit rather than two actually end up testing zero.
|
# ? Jan 1, 2015 20:06 |
|
My favourite kind of worthless tests are the ones that mock out all of the dependencies, call some method on the ClassToBeTested, and make sure that results in the mocked dependencies having all the expected method calls made on them. It tests nothing other than that you can write the same code twice (in an awkward roundabout way the second time). You may as well write a test that verifies the checksum of your source files against known good values
|
# ? Jan 1, 2015 20:17 |
|
seiken posted:My favourite kind of worthless tests are the ones that mock out all of the dependencies, call some method on the ClassToBeTested, and make sure that results in the mocked dependencies having all the expected method calls made on them.
|
# ? Jan 1, 2015 21:28 |
|
Forgall posted:Isn't it testing that MethodToBeTested makes calls it's supposed to make? Or am I misreading you? MethodToBeTested shouldn't be making calls, it should be doing something. The test is just enforcing coupling (which is a bad thing).
|
# ? Jan 1, 2015 21:42 |
|
Yeah, exactly. I mean, I suppose if you had some helper class whose sole purpose was to call methods on some other object - say you have a method callFooThenBarHelper whose spec is actually to just call dependency.foo() and then dependency.bar() - then it could make sense to mock out dependency and write a test that makes sure the dependencies are called correctly. If it wasn't such a simple example. Because you're actually testing the spec of the function. But that's an extremely contrived example and that sort of thing doesn't really happen all that often. Much more likely is that the calls to dependencies are implementation details, and if you write a test that just verifies the exact dependency call fanout from doSomeLogic(), all you're doing is testing that the implementation hasn't changed since you wrote the test. You've literally just copied out the implementation of doSomeLogic a second time, except wrapped up in all the mocking framework gibberish. It's providing negative value, because it doesn't do anything useful and means you have twice as much code to change
|
# ? Jan 1, 2015 23:37 |
|
I wrote a Javascript function once called lookupFoo(callback) that would XHR out to some backend to lookup the foo and then execute the callback with the value. I wanted to make sure it would only XHR once no matter how many times I called lookupFoo (the result is cacheable), so I mocked out XHR, called lookupFoo() twice, made the mock XHR 'return', called it twice, and then verified all my callbacks executed and only one XHR was constructed.
|
# ? Jan 2, 2015 00:33 |
|
vOv posted:I wrote a Javascript function once called lookupFoo(callback) that would XHR out to some backend to lookup the foo and then execute the callback with the value. I wanted to make sure it would only XHR once no matter how many times I called lookupFoo (the result is cacheable), so I mocked out XHR, called lookupFoo() twice, made the mock XHR 'return', called it twice, and then verified all my callbacks executed and only one XHR was constructed. That's fine because you're testing that the function is properly memoized. It'd also make sense to have tests that verify that when you call it twice with different functions it ends up executing the right function the second time. That all tests the actual functionality of the function. My point is that if you have this: code:
|
# ? Jan 2, 2015 06:25 |
|
Generally speaking, I have found mocking most useful for:
I can also think of some cases where I wanted to be able to test "was pow called" in a test. For example, sometimes I wanted to make sure my unit tests overflows some memory buffer that causes stuff to need to get pushed to disk. So I wanted to be able to have the test see that such an overflow really happened, otherwise the disk-touching code isn't going to get tested. Edit: Really I just found myself wanting the regular code to spit out a log of everything it does, and then have the unit test inspect it after the fact. sarehu fucked around with this message at 11:32 on Jan 2, 2015 |
# ? Jan 2, 2015 11:28 |
|
sarehu posted:
I think for these what you really want is a "fake" implementation (i.e., an implementation of the dependency that uses dummy data / doesn't connect to a real database / doesn't actually do anything concurrently / whatever, but is otherwise a reasonable facsimile of the actual implementation) rather than mocks that you have to specifically set up for each test and keep in sync with the actual code. I'm fairly convinced that unless you're testing something whose behaviour is defined in terms of method calls out to dependencies then all mock tests are negative value tests and worse than no tests.
|
# ? Jan 2, 2015 14:20 |
|
Ithaqua posted:As you build up your test suite, the tests give you a safety net you can use to refactor. This kind of blew my mind when I read about it. The "formal" definition of refactoring requires you to have unit tests in place, while I've always thought that refactoring meant just "improving the code by doing whatever." I'm still probably going to use the word refactoring when doing whatever, but at least now I know.
|
# ? Jan 2, 2015 16:02 |
|
Basically at my education. Also now that I'm back at the university doing my master's a decade after getting my bachelor's degree, at the education in general. I haven't really learned much of value on those lectures I have been sitting on. All the exercises done in software courses are dumb and trivial that don't need any discipline, so there is no need to learn any, so you just hack away at poo poo on the last day before the deadline. There is very little need to use version control (i guess git/github is good for group projects), no need for testing, or at least no enforcement for having tests. We are introduced the ideas behind agile methods, but beyond some simple classroom games, they are never put into practice. I'm not saying that agile methods are what make good software, I'm just saying that there should be any structure/process in place. But then again, every exercise/project is so trivial that there is no need for any and you can pass them by winging it. Then again, a more realistic software project that would illustrate the need for discipline would be a loving nightmare to arrange. Then idiots like me who have been through the education process go work at companies with other similar idiots and nobody has any experience in doing anything except hacking lovely code together which then gets posted ITT.
|
# ? Jan 2, 2015 16:38 |
|
Wheany posted:Basically at my education. The reason why new grads make 6 figures at the big companies fresh out of (grad)school is the fact that most graduates gain zero applicable engineering/process skills from coursework at most universities. Hence, the only ones that are actually semi-competent are the ones who had the personal drive to learn things on their own and go past the assignment descriptions...
|
# ? Jan 2, 2015 16:45 |
|
That's the case with nearly any field and most schools, by the way. Yeah, there's some schools that have good programs for some stuff, but most of it is about networking and access to resources for self-practice. What happens at a lot of schools is they try to lower the attrition rate by never telling students what's actually required to become decent at the thing they're studying. They know that if students were told how hard they're going to have to work then most will just quit, and that's bad for business. So they have made these ramps-ups so slow to keep the students in the program, but then it ends up failing them in the end. You get a bunch of graduates with some knowledge of whatever field, but without any skills at a good level because they haven't spent enough time practicing. You also get people graduating thinking they like the field they've chosen, but end up hating it when they get a job actually doing it every day. The only fields and schools where this is not true are ones that have kept a reasonable attrition rate.
|
# ? Jan 2, 2015 17:25 |
|
ErIog posted:What happens at a lot of schools is they try to lower the attrition rate by never telling students what's actually required to become decent at the thing they're studying. They know that if students were told how hard they're going to have to work then most will just quit, and that's bad for business. So they have made these ramps-ups so slow to keep the students in the program, but then it ends up failing them in the end. You get a bunch of graduates with some knowledge of whatever field, but without any skills at a good level because they haven't spent enough time practicing. You also get people graduating thinking they like the field they've chosen, but end up hating it when they get a job actually doing it every day. That's so true. Also most rankings (at least for undergraduate programs) are contingent partly on rapid graduation rates. Since most universities also have a substantial liberal arts requirement that needs to be fulfilled, engineering students end up with roughly 4-5 semesters worth of degree-related courses. Failing even one course causes the student to slip past the graduation target, bringing down the school's rankings. quote:The only fields and schools where this is not true are ones that have kept a reasonable attrition rate. Which, at the BSc/MSc level (aka the point at which the school gets paid by the student, not the other way around) involves roughly the top 10-20 programs in the country based on my interactions.
|
# ? Jan 2, 2015 17:37 |
|
ErIog posted:That's the case with nearly any field and most schools, by the way. Yeah, there's some schools that have good programs for some stuff, but most of it is about networking and access to resources for self-practice. Someone once said to me that university is not about learning your subject, but LEARNING HOW TO LEARN... its about understanding how to research and documenting what you discover, This is of course Undergrad courses i am talking about.
|
# ? Jan 2, 2015 17:39 |
|
Wheany posted:Basically at my education. This is a general problem with the software engineering type courses. Those group projects serve only to teach that one person can do the work of four in a finite amount of time. I know people who ask about that class as a screening question in interviews: If the candidate doesn't express overwhelming disdain for the course and the other members of his/her team then you don't have the one of the four you want to hire. What they should do is have the whole class build one project with the professor as CTO like it's a web startup. Of course, it's doubtful whether the professor has any experience managing a 35 person engineering team, so there's that.
|
# ? Jan 2, 2015 17:42 |
|
Wheany posted:Basically at my education. When I finished community college with an AA in "Web development" there was literally a girl in my class who's final presentation site didn't work because she didn't understand that she needed an index.html. She brought in her flash drive, copied her site to the XAMPP directory we were using for presentations and then couldn't figure out why going to locahost wasn't opening it. Eventually the instructor showed her and she went on to present. Like maybe in some crazy fantasy world she altered her config to look at another file as the default and just got screwed by the config on the presentation computer, but I can assure you this was not the case! You leave the school and start looking for a job and these people are applying to the same places as you. If they interviewed her first they might see my resume and not give a poo poo. Now that it's years later and I am running my own department, I have actually done some interviews with applicants from there. Overall they are junk. But at least I understand that there are some decent people that went there that could be good, or could learn to be good, so I'll at least do a first round with some of them. But I imagine a lot of people aren't so lucky. Employers might not give them a glance just because they have seen the quality of the candidates from there. Getting a bit off track, but basically: Yes. School is 100% what you put into it. Coasting through the minimum to pass, or working get a nice GPA might not mean poo poo if you don't learn the material. edit: Here is someone's solution to a modified fizzbuzz test in PHP: code:
edit2: Of course I actually failed the test based solely on the fact that there weren't any unit tests outputting the results as a manually typed string before he started this function. itskage fucked around with this message at 19:12 on Jan 2, 2015 |
# ? Jan 2, 2015 18:50 |
|
KernelSlanders posted:What they should do is have the whole class build one project with the professor as CTO like it's a web startup. Of course, it's doubtful whether the professor has any experience managing a 35 person engineering team, so there's that. The entire degree program should be this. If you can't hack it in a fast paced, high skill environment, you don't get the degree. Can't pivot on a moment's notice? Fail. Can't put in 12 hour days 7 days a week like a team player? Fail. We need to be much better and finding and promoting rockstar programmers and getting rid of everyone else.
|
# ? Jan 2, 2015 19:23 |
|
KernelSlanders posted:What they should do is have the whole class build one project with the professor as CTO like it's a web startup. Of course, it's doubtful whether the professor has any experience managing a 35 person engineering team, so there's that. Do it in conjunction with the business school as a senior project for management majors.
|
# ? Jan 2, 2015 19:27 |
|
I once interviewed a recent computer science graduate who couldn't create a java class with a main method using eclipse. For a junior java developer position. I even let them cheat off of a flash drive that had all their 100-level java class homework on it and they still couldn't do it
|
# ? Jan 2, 2015 19:29 |
|
Zorro KingOfEngland posted:I once interviewed a recent computer science graduate who couldn't create a java class with a main method using eclipse. For a junior java developer position. Ha ha, what the hell? Eclipse literally has a button to push to generate a main method stub in the class you're creating. I can't imagine this level of incompetence.
|
# ? Jan 2, 2015 19:46 |
|
There was a student who was tasked to take a .NET library that did gesture recognition (from accelerometers iirc) and test how robust it was to noise (this was the scaled down version of his project, having gone through a bunch of scope-narrowing steps to better fit his "competencies"). The input data was literally just a list of 3-component vectors. The student's solution to "make the data noisy" was to add "random noise" to the data which is generated by transforming the vector's components in some arbitrary way then adding the result back to the vector. This took the better part of a semester to implement. Right now, this person is writing code that's handling your financial data at one of the biggest banks in the world...
|
# ? Jan 2, 2015 19:59 |
|
carry on then posted:The entire degree program should be this. If you can't hack it in a fast paced, high skill environment, you don't get the degree. Can't pivot on a moment's notice? Fail. Can't put in 12 hour days 7 days a week like a team player? Fail. We need to be much better and finding and promoting rockstar programmers and getting rid of everyone else. Please source your quotes.
|
# ? Jan 2, 2015 20:04 |
|
fritz posted:Do it in conjunction with the business school as a senior project for management majors. That seems even worse than the status quo. Now one person can do the work of four, and their boss.
|
# ? Jan 2, 2015 20:28 |
|
KernelSlanders posted:That seems even worse than the status quo. Sounds like an accurate simulation of the real world to me?
|
# ? Jan 2, 2015 20:42 |
|
Y'all never had a group project that was anything but one person doing all the heavy lifting? And, by some stunning coincidence, everyone posting here was the downtrodden ubermench who singlehandedly did every line of code, worked on the presentation, and held a stiff upper lip while the whole team got credit?
|
# ? Jan 2, 2015 20:59 |
|
Visual Basic .NET code:
e2 : changed some char values Knyteguy fucked around with this message at 21:10 on Jan 2, 2015 |
# ? Jan 2, 2015 21:04 |
|
Knyteguy posted:O0O000OO0O(O00OO000000O00 ) Dear god why!? Job security
|
# ? Jan 2, 2015 21:07 |
This looks like coding equivalent of tongue twister.
|
|
# ? Jan 2, 2015 21:08 |
|
Clearly some automated obfuscation.
|
# ? Jan 2, 2015 21:09 |
|
The previous programmer is haunting the code base.
|
# ? Jan 2, 2015 21:10 |
|
carry on then posted:The entire degree program should be this. If you can't hack it in a fast paced, high skill environment, you don't get the degree. Can't pivot on a moment's notice? Fail. Can't put in 12 hour days 7 days a week like a team player? Fail. We need to be much better and finding and promoting rockstar programmers and getting rid of everyone else.
|
# ? Jan 2, 2015 21:15 |
|
JawnV6 posted:Y'all never had a group project that was anything but one person doing all the heavy lifting? And, by some stunning coincidence, everyone posting here was the downtrodden ubermench who singlehandedly did every line of code, worked on the presentation, and held a stiff upper lip while the whole team got credit? Jokes and self-selection, dude.
|
# ? Jan 2, 2015 21:17 |
|
Munkeymon posted:Jokes and self-selection, dude. I dunno, the "screening question at interviews" stuff wasn't all that funny.
|
# ? Jan 2, 2015 21:22 |
|
JawnV6 posted:Y'all never had a group project that was anything but one person doing all the heavy lifting? And, by some stunning coincidence, everyone posting here was the downtrodden ubermench who singlehandedly did every line of code, worked on the presentation, and held a stiff upper lip while the whole team got credit? For our software engineering course, my group got hosed over by someone dropping the class in the first week. Where 4 other teams had 4 or 5 members, we had just 3. The project was a web-based test analysis system targeted for our school's ABET test. One guy did gently caress all, barely showed up to group meetings - always late, with little communication at all. The other one was actually employed doing QA with some code fixes; between him and me we wrote up the design docs. We didn't have much leadership (silent guy was supposed to be leader). My teammates kind of gave up a week before the project was due. I hadn't taken a class over databases or web stuff, and really didn't know much about either. These other two supposedly did, as that's how the professor had distributed people - based on classes taken. So, I learned some PHP and SQL in a few days, coded a visually-ugly but functional loving system, and hosted it on XAMPP on my home computer and presented the drat thing essentially alone while the other two stood behind me. You know what the scary thing was? Only one other group had built a system that even loving worked at all. Same poo poo happened in my capstone - and the same loving silent guy was assigned to my group. We had 3 groups of 5 (and again, another guy dropped from my group a few weeks in). The project was to build a web and mobile-accessible system to upload files. Again the docs got done fine, again the team hosed up poo poo. We divided responsibility so that I would do the server poo poo with silent guy and the other two would do Android interfacing with the server. One guy wanted to talk to the database directly from the Android app, but I persuaded them to instead talk to the PHP. I had the server code up and done for the web weeks before it was due. No progress was made by the mobile guys; having some Android experience, I built a class for them to use that would handle server communication. Silent guy was supposed to make the PHP handle the Android via JSON. He didn't know how and I gave up waiting for him to ask, so I did most of it while getting that class built. Unsurprisingly, they couldn't loving figure out how to do poo poo, still. After asking for help, silent guy copied & pasted the bulk of the PHP code and tagged that as mobile (we used a flag to differentiate) for a single PHP file, and that was his contribution to the code. It was also broken, so I had to fix it. One of the guys just pasted in someone else's code for a single part of the Android app, and that was his contribution. I'm not sure that the fourth guy did that much. So, I coded up the entire Android app (aside from the class I'd previously wrote and the other guy's class, which handled only a portion of one page) in a couple of days and again presented it while the others stood 'round. Evil_Greven fucked around with this message at 21:39 on Jan 2, 2015 |
# ? Jan 2, 2015 21:35 |
|
So you go to the professor and show them that the guy didn't contribute? Surely you had some form of that in record. An email count from the two of you being orders of magnitude over his would be a fine start. That you let him slip by and had to deal with the same person in a later class is somewhat on you. I had a variety of good team projects. Mostly pairs, a couple that required larger teams. On the larger teams we were using real version tracking and sussing out noncontributors was trivial. In pairs, the professors would assume everything was 50/50 and encouraged people with less than ideal mixes to speak to him. I know one team that totally earned their A/D grades and it took one conversation with the professor to get it there from A/A. Yeah, it still really seems silly to think that's how it Must Be. Especially when you're not speaking up about it and presumably letting the slackers get away scot-free?
|
# ? Jan 2, 2015 21:45 |
|
|
# ? Jun 8, 2024 05:27 |
|
Yeah just narc on your classmates, you dummies. How could that possibly backfire?
|
# ? Jan 2, 2015 21:52 |