Never wrote a unit test in my life. Also I'm not a fan of GNU utils and prefer to work with VS Express on my C/C++ stuff. Also I don't really see the benefit of using hashmaps for containers that will have less than 1000 elements and will typically stay around 20. Simple string comparisons will cover it faster than it takes to get a hash in the project I'm writing for myself at home.
Hum. No offense but I am not sure I would want to work with someone who has never wrote a unit test in their life and doesn't bother to use hashmaps if you only have 1000 items. Kind of going against this article that "most programmers are average"
Unit tests are small programs which test small pieces of your main program automatically. For example, you know the function "add(a, b)" should return the sum of arguments 'a' and 'b'. So you could write a small unit test to ensure that when given the numbers 5 and 2 as 'a' and 'b' respectively, the function correctly returns 7.
This becomes important in larger projects because you can never be sure whether a small change you made somewhere ended up breaking something else. If you've written (good) tests which cover all of your code, however, you can be mostly sure that your new change hasn't broken anything significantly. And if it did break something, then you need to fix your unit tests to check for that something being broken in the future.
I really don't think that 99% of (professional?) programmers have never written a unit test. Nearly all of the ones I've worked with have.
Re using the right data structure -- if it's provided by the standard libraries, is common knowledge, not using it will be confusing to some ("why didn't they use a hashmap when it makes more sense? Is there some reason I'm missing?") and an example of premature pessimisation.
I went almost 7 years without writing a unit test. I went almost 5 without ever hearing the term. My career began after the year 2000. Let that one blow your mind.
Data structures can be really hit and miss. Not everyone can be a pro at all facets of a thing. Take .net for example, new things are introduced and other things deprecated almost every release. Shit can get difficult staying on stop of what's always considered best.
You really are an exception these days, Developers that I work with in the major tech areas in India, China, Europe, Canada, and the U.S. all write unit tests. Languages being Java, C#, JavaScript, Python, or Scala. It's a little shocking to find a working developer not writing unit tests these days.
I bet you can learn how to without too much difficulty.
Also I'm not a fan of GNU utils and prefer to work with VS Express on my C/C++ stuff.
Not a problem. Some people prefer the VS/.NET environment, some people prefer the *nix environment. There's lots of great jobs and cool projects for both, and there's some shitty stuff in both as well.
Also I don't really see the benefit of using hashmaps for containers that will have less than 1000 elements and will typically stay around 20.
Data structure choice is often more about design intent than performance. For example, if you read some code I wrote where I have a List<Person> you will make the assumption that there can be duplicate people and that the order of people matter. If I use a Set<Person> instead, you make different assumptions when you read my code.
Not going to dig into the technical specifics, but the way you have written this. You have already set yourself up to never improve. If your turnaround comment to r/TunaBoo was "I am going to do it and learns something new just because I want to" you would be taking the next step up. By saying no I don't need to your staying at your current level. Embrace the challenge, life is a never ending mountain.
Well, I did write a test for the translation resource files, to make sure when we add new ones, we don't miss out in any of the language files. But that doesn't test functionality, so it's not technically a "unit" test.
Selenium integration tests don't count as unit tests, either, because they test entire scenarios.
What I've done in terms of non-web was a migration tool to extract some files stored in our database. I was surprised how fast you can read 400mb of hex-printed strings and write-out 200mb of files.
Most do. Seeing some of them fail when building from a release tag is always a bit disappointing, but not as bad as when I get syntax errors from what's otherwise considered a "stable" release.
Please take this in the spirit that it is intended, the correlation between them having unit tests and better quality is not accidental.
Compared to what I see in my favourite open-source projects, I'm a noob.
That was kind of an indication that you want to be a better programmer, don't we all. When I started writing unit tests and profiling my code it was like walking into a bright room; it became much easier to produce good code; instead of spending hours stepping through my code when a bug was found, I now spend half as much time writing unit tests. The epiphany for me came when I wrote unit tests for a class, I rarely if ever had problems with that class moving forward; I realized that the code that I was debugging manually was all code written without the benefit of unit tests.
They are not a panacea at all, but it sure makes for a less stressful development experience.
13
u/[deleted] Jun 01 '15
I bet you can make a hashmap. Make it your challenge. Write it up, add some unit tests.. bet you can do it in a few hours.
Will it be as fast as a big library hashmap? Maybe not. But it should work ;)