- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
About the unit testing: It's absolutely fine to have lots of quite trivial unit tests. For example, if you just use a setter to store a 1 and the getter to verify that it is one, that wouldn't catch if the setter sets the wrong variable and by coincidence the variable is already set to the expected value. You can have lots of test for trivial cases, which will then find really stupid bugs that would otherwise go undetected until the software is in the hands of a customer.
Admin
M.C. as in "Escher", right?
Admin
Most folks might agree that you don't need unit tests for one line functions but most folks would be wrong.
The tests are there to prevent your code from regressing. What if someone changes the set not to set the value? What if someone changes the get to return a constant value?
The getters and setters like this generally violate Tell Don't Ask.
Admin
TRWTF about the RSA fob inventory is that they appear to have 13k+ people editing the same spreadsheet in the space of 1 week. If everyone works the same 40 hour week, then they have about 11 seconds each to lock the spreadsheet, make the change and unlock it again. I'm guessing there were a lot of people without access the next week.
Admin
The real WTF is starting with Sunday?
Admin
http://www.timeanddate.com/calendar/days/ Ask no more.
P.S. http://en.wikipedia.org/wiki/Sunday
Admin
That was the reason I left my position as an Architect after being promoted from a development position. My new boss (Senior Architect or something) didn't want us to get dirty with "coding", debugging, etc.
Admin
Can't agree with that; returning or assigning the wrong field from a get/set is a pretty common mistake, especially when there's a bunch of getters/setters in a class and they've been coded by copy-and-pasting from some template. It's always a good idea to test (a) your getters/setters are consistent, and (b) they don't corrupt the values of other properties on the object.
That said, by-line code coverage statistics are a definate WTF, as they tell you almost nothing beyond giving you a nice number to feel warm & fuzzy about. As the article says, behavioural coverage is what actually matters.
Admin
Tl;DR
CAPTCHA: walls of text give a paratus sensation.
Admin
The real WTF is not using Google Docs for keeping RSA keys amirite?
Admin
Sadly they often don't work. Instead use commen sense and code reviews. Parts of my company have recently started developing software for government. The work method there is that we discuss software wishes with hundreds of government employees but develop software ourselves with their considerations in mind. In the end the governments will hopefully buy our software.
Admin
"We can all agree that unit tests, implemented properly and kept up to date, can provide a safety net against mistakes. Most folks will agree that one-line functions such as get/set methods don't need unit tests as you'd only be testing the language's ability to set/retrieve the value of a variable."
No, unit tests are not a "safety net against mistakes." They're there to make refactoring reliable: you make a structural change, see what tests break, and fix all breakage, then refactoring is complete.
Since getters and setters are obvious targets for refactoring, they should have unit tests. The fact that the unit tests are easy to write doesn't make them less important.
Admin
At least they keep those guidelines safe from the rest of us.
Admin
And regarding the example, the reason they're called "unit" tests is because they test a specific unit of functionality. In this case, unless the setter is supposed to do something special for 0 or -1 or INT_MAX, there's no need to test any particular value. Testing whether different values cause anomalous behavior is fuzz testing, which is a different kind of test, and usually performed on IO, or process parameters.
Admin
I learned by painful experience that storing constants in a single common place ("island of data") is better than having them defined in each of many different classes in many programs. If you exchange data and one class has defined {Sunday, monday,...}, another {monday, tuesday, ..} then when transmitting the corresponding integer values (0,1 etc.) between services, a Sunday suddenly becomes a Monday. If you submit strings, then there may be no match (lowercase and uppercase in the case above) because two things mean the same or spelling mistakes. E.G "Christmas" and "Xmas", "grey" and "gray", "seperate" and "separate" etc. Also storing these values in the database makes correction of them (or translation in a different language) easy and can be done immediately with a single SQL statement; no need to change any code and deploy it everywhere and having downtime etc. You are just more flexible. Imagine you sell paint and you run out of yellow. Then you just delete the corresponding record from the table of available colors instead of changing hundreds of classes!
Admin
Sorry, but I've got a quick note from the PC police.
"SheMale" is a word that exists mostly in pornography. There are people who either transition from male to female or vice versa, and referring to them by what porn refers to them as would be like referring to an Asian woman colleague as... well... you don't need me to expand on that. For the most part, the people others might call "SheMale" or "Tranny" find those words dismissive and offensive. The people themselves will generally refer to themselves as a trans person, as in trans woman, trans man or transgendered.
I get that you were trying to make a joke, and that thedailywtf is a comedy site, but that word in particular is better suited towards Howard Stern than DailyWTF. Besides, in these days we're coming to understand that gender is often not as simple as "baby blue boy" or "princess pink girl", and joking that gender is as inflexible as the days of the week is pretty stuck in the mud. On that same note, getting corporate types to even include an "other" field for gender is often a struggle in and of itself, so every little bit of support helps.
Could you update the story to at least not include the word SheMale?
Admin
Admin
Arithmetic WTF: If 13,000 users (the minimum specified in the story) were to line up in perfectly orderly queue to access the spreadsheet at the end of the story, and required only 60 seconds to download, open, update the spreadsheet (including finding their own row and saving the file), and upload the spreadsheet... it would take 780,000 seconds, or more than nine days... assuming the process continued throughout every available second of every 24-hour day, rather than just the work day. And they only had "one week" to do it.
Apparently, security-mindedness includes the willingness to claw your way to the mandatory shared resource over the broken corpses of your rivals (once referred to as "co-workers") in order to finish this vital administrative task.
Darwinian reduction-of-force: anyone too weak to complete the task in the alloted seven days deserves to die. Or at least be fired for being unable to do their jobs.
CAPTCHA: "ratis". It's a ratis race. And only the ratises are winning.
Admin
With the correct setup, it might be possible to collaboratively edit a spreadsheet. Might.
And about the getters, you are clearly doing it wrong if your code does nothing but setting and getting a property. Just expose the real property already. Good languages allow you to access getters and setters as if they were properties in case you change your mind later.
Admin
Government will have twelve levels of security to allow an employee access to an unprivileged workstation, but run untested code full of exploits on a web site that millions of people are required by law to access.
Admin
I don't feel like I was being aggressive here, and I tried to be as little demanding as possible.
Regardless, the word shemale does have meaning outside the article. The article might not have meant it badly, but that means that the article shouldn't have included the word, not that the word is okay just because the author didn't mean it to be harmful.
Admin
Admin
P.S. americans and their measurement units as well as formats are dumb.
Admin
Admin
Right. And biologists know that physical gender is set as a function of how much testosterone a fetus receives in the early stages of pregnancy. That testosterone can be distributed unevenly - an XY fetus can have unusually little, an XX fetus can have unusually much, the hormone can come early or late, and that's not to mention fetuses with unusual chromosomes, XXY, XXX, etc. Since the process is highly fluid, a minority of people aren't simply male or female.
Admin
Architects generally know pretty much everything there is to know about how a given system works, what makes it tick, it's capabilities, limits, and the data and messages that it passes around.
A big exception to the rule is when the architect has been brought in to work on an existing system and hasn't had time to learn its ins and outs, or possibly that much about it. I tend to do a lot of secondment work with different teams in different companies owned by the Big Umbrella Company, so except in situations where I am there from the start of the project I get into this situation quite a bit. Of 6 recent projects, I've been there from the start of two.
Admin
Admin
Oh right, more gender discussion from people who don't know what they're talking about and don't see the difference between sex and gender.
And for those who think that gender is a fixed data type that never ever changes, look at the latest Facebook updates. ;)
Admin
It sounds like the architect was pretty reasonable. You want to specify data flows, interconnects and key relationships. You don't want to do the implementers' jobs for them. Let them develop it they way they need to and review it to make sure that they didn't do something that undermines the architecture.
TRWTF is M.C.:
Waterfall! Awesome! That never fails to produce a quality product!(A lot of the other stuff was pretty much BS)
Admin
Hey... my cousin works at ██████.gov/corpname, say hi to him for me!
Admin
To Srsly, This is not my area of expertise, but the only uses I've seen of shemale have been people (usually men) who have had themselves surgically and hormonally altered to have both sets of 'tools' - i.e. not transgenders. Not that there's anything wrong with that, etc. ...
Of course this doesn't detract from your point, just adds that little bit of weirdness we need on the interwebs.
Admin
Let me tell you of government story in India. There is a big corporation run totally by Government. one day they invite bid to build a pylon towers. 15 contractors bid for the job. 3 are called into private mtg room. They are told there is no tower that is actually going to be built. We will pass tenders and we can split the fortune (tax payer money) among some officers of the corporation and the contractors. 3 months later there is another invite for a bid to demolish the tower. These kind of inefficacies exist because of human nature. Human nature has no solution in the long run. In the short run, humans can be trained, but in longer period they will revert to their basic nature.
Admin
Admin
Reasonable request. Changed to Octember.
Admin
Admin
Octember is a perfectly cromulent word.
Admin
Admin
What you're talking about is true for string constants, but it's about enums, they only exist in the source code like variable names.
Admin
Great article btw.
I really enjoyed it.
Admin
Everything else is behavior.
Admin
Admin
For a moment, forget that people write functions with side affects.
The expression is side effects.
Admin
Sorry, have to send out the PC Police again.
"Octember" is a word that exists mostly in pornography; namely the hentai variety featuring men or other creatures with eight male members. There are people self-identify as multi-phallused and who may have surgery to give themselves multiple penises. Referring to them by what porn refers to them as would be like referring to an Australian male colleague as... well... you don't need me to expand on that.
Admin
Admin
Admin
Please show some sensitivity.
I had a son who suffered from octember, and let me assure you it was no laughing matter.
(Had to do it...could not resist... please forgive me)
Admin
So basically M.C. is faulting this company because
Hopefully he's found a job at a stealth startup, where his randomness won't cause as much trouble.
Admin
One could write a generic unit test using reflection to grab a setter method, check the name-matching member variable and also the getter method. One could also extend this generic unit test to be fed by a list of object classes to go through and check test all automatically. Without Writing Stupid Unit Test Coverage Code Over And Over Again.
Or.. some stupid could waste hours writing stupid unit tests
Admin
Better solution: Use a language that doesn't require you to write getters and setters. Python lets you happily "reach in" and manipulate members with direct assignment, and if you ever need to change things around (that's the whole point of getX() and setX(), after all - you can change them to not simply be direct getter and setter), you can create a @property that lets you write, effectively, the getter and setter. Of course, that's WAY too smart for bureaucracy.
Admin
TRWTF are getters/setters. If outside class need to access internal variable of another class, just make it public. If you don't want field to be modified outside, just mark it as readonly. Most sane languages have methods for that. Getters/Setters were worst design choice made when creating Java.
As big pain it causes me, C# being M$ product, it fixed most of Java's issues. .NET runtime (be it Mono or .NET from M$) is just faster and C# uses saner language constructs than Java does.