News for hackers. Stuff that matters.
Re:Tips for beginning systems and software engineers by gregdoesit on Thursday May 19, 2016 @06:07AM (#11729098)
I am glad you put automated tests as one of the first ones. To this date I find that many people - often mid level, and sometimes senior developers - are very uncomfortable with autmated tests. As a result they don't use this tool, and end up being less productive, and often write more complex than needed code - and of course code with more bugs that could have been avoided.

I'm no TDD or automation advocate - however I do see that this tool is essential to modern software development, and the only way to learn to use it, is by practice.

I would encourage every engineer who's covered the basics to go full-in on TDD with 100% test coverage for a few days or weeks. Not because it will make you more productive or less bugs (you will be less productive), but it will change your thinking of writing code (similar to how learning Lisp will have a massive impact on your thinking of structuring code). TDD + 100% coverage is an extreme, which is worth experiencing to take learnings from it.

Later down the road, when you've gotten into the habit of developing with no, or barely any automation, it will be much more difficult to learn to fit this tool into your coding routine.

Re:Tips for beginning systems and software engineers by yoodenvranx on Thursday May 19, 2016 @06:47AM (#11729229)
> however I do see that this tool is essential to modern software development

If we are talking about the later stages of the life of a software project then I completely agree with you.

But if you just started a new project and you are still in a constant state of change then a large test suite will slow you down because you have to adapt all your tests all the time. In the worst case you might even stop to improve your software just because updating your tests is too much work.

Re:Tips for beginning systems and software engineers by mooreds on Thursday May 19, 2016 @07:00AM (#11729274)
> But if you just started a new project and you are still in a constant state of change then a large test suite will slow you down because you have to adapt all your tests all the time.

I have been in a new project where progress was slowed by all the tests. But the issue I have with "I will write tests later, after things have stabilized" is that, in my experience, that day never comes.

There is always a feature that would add value, or some fire to be put out.

Of course, you could arbitrarily pick a date or time to start testing, but as some one who was responsible for a smallish code base (30k lines, maybe 2-3 man years) with no tests, I can tell you that it is hsrd to start that. You have to either start testing when building a new piece of software (which is easy, but you really want to have assurances about the working of your existing code), or try to apply tests to previously untested code, in which case you are unraveling quite a bit of complexity and possible untestable/difficult to test constructs.

Re:Tips for beginning systems and software engineers by parley on Thursday May 19, 2016 @10:31AM (#11730468)
I write high level automated tests immediately at the beginning of a project, which have several upsides:

They can be read almost like project requirements, so they double as validation for solving the problems in the reqs.

They only use the outermost APIs of your code, which will change much less than internal module APIs, and so won't inhibit changes and experimentation as much.

They enable you to automatically test your code in the "real" scenarios that your project reqs describe, instead of just module-level tests that may not catch bugs in API usage of those "real" scenarios.

Later on in the project, as larger internal modules crystallize, you isolate those modules with their own outer APIs and write automated tests for their APIs.

Yes, this has downsides. High level white box testing exclusively during early stages obviously won't catch all your internal error cases early. However, I have found them to have superb ROI, especially in projects where time constraints have required pragmatic approaches.

YMMV.

Re:Tips for beginning systems and software engineers by mbrock on Thursday May 19, 2016 @06:54AM (#11729249)
Unfortunately, it's difficult to pinpoint the time to abandon that initial flexibility and create a test suite.

Moreover, creating that test suite after the project has grown is likely to be tedious, too... and often requiring serious refactoring to accommodate testing practices.

The XP folks were always all about changing requirements and flexible code, and unless they're all deluded, it's not true that testing necessarily hampers a new project.

Re:Tips for beginning systems and software engineers by lowmagnet on Friday May 20, 2016 @07:48PM (#11742420)
When I start a new maven project, it comes with junit by default and with the test tree created. The first thing I do when starting a nontrivial class is to hit the shortcut for create new test. I should make it fail empty classes in the test tree. Automating the testing burden helps especially when interfacing with a tricky API; sometimes it's mocking, sometimes it's a real object in isolation.
Re:Tips for beginning systems and software engineers by jon-wood on Thursday May 19, 2016 @08:02AM (#11729507)
I find tests to be invaluable especially in times of high churn and lots of changes. First they force me to think of my design in terms of components I can compose together into higher level systems, and when I find one of those components or systems is no longer how I want it I can make changes with my test suite telling me what I've broken, and what I haven't broken.
Re:Tips for beginning systems and software engineers by UK-AL on Thursday May 19, 2016 @10:10AM (#11730299)
"But if you just started a new project and you are still in a constant state of change then a large test suite will slow you down because you have to adapt all your tests all the time. In the worst case you might even stop to improve your software just because updating your tests is too much work."

That's exactly when you need automated test suites, if your pushing multiple versions a day, then automated tests are really required.

Re:Tips for beginning systems and software engineers by joshuaduffy on Thursday May 19, 2016 @03:10PM (#11732857)
Depending on how fundamental the changes are, I agree. However, usually when someone says that to me, its a huge smell that the unit tests are bloated and cover too much.
Re:Tips for beginning systems and software engineers by superuser2 on Thursday May 19, 2016 @01:04PM (#11731685)
I'd argue the opposite - you should be very afraid of changing untested software because it is hard to keep it correct, and the more it changes the heavier the burden of manual testing (assuming you care to understand your code's behavior at all).

Then again, I skew towards integration rather than unit testing. So I am not locked into an internal design, but I know outward facing behavior is as I expect it to be.

Re:Tips for beginning systems and software engineers by jsymolon on Thursday May 19, 2016 @07:37AM (#11729406)
> But if you just started a new project and you are still in a constant state of change ...

I don't understand what the rush is all the time. Sit down with a pad/pen or whiteboard and think about the design. the last mobile project i started, I sat down and wireframed on paper. Tests came naturally and didn't fight the design.

Re:Tips for beginning systems and software engineers by yoodenvranx on Thursday May 19, 2016 @08:33AM (#11729612)
I think it depends on what type of software you are doing. If it is "just" a mobile project then you can pre-plan most of it. But I come from a more scientific background and most of the stuff I did back at university was pretty much impossible to plan because you did not actually know how you would solve your current problem. Usually you would try several approaches until you find the one that works. In such a situation tests are hard to use because they reduce your flexibility.
Re:Tips for beginning systems and software engineers by jsymolon on Thursday May 19, 2016 @12:41PM (#11731485)
> ... most of the stuff I did back at university ...

I would place that kind of programming in a different class. Small, "one-shot" problems probably don't need a lot of planning.

That's the experimental / exploratory class of problems where you're not interested in the correctness of the process but results. AKA risk reduction.

For the other classes where there is "The Process" of validation, testing and approvals, a little planning up front saves some churn on the back end.

I have the same concern about iterative development. Seems like a lot of teams jump right into a coding sprint/iteration/cycle w/o a plan.

Re:Tips for beginning systems and software engineers by blueprint on Thursday May 19, 2016 @10:21AM (#11730385)
How do you verify that the lack of understanding of the form of the solution was due to the problem domain (scientific) and not your lack of exactness of confirmation and ability to see what is in the problem due to not actually knowing?
Re:Tips for beginning systems and software engineers by mbrock on Thursday May 19, 2016 @09:14AM (#11729893)
You are completely allowed to throw out your tests if you are doing this kind of exploratory programming.

Then, tests are simply your hypotheses.

Re:Tips for beginning systems and software engineers by maxxxxx on Thursday May 19, 2016 @10:57AM (#11730706)
Yes, that's one thing people often forget. It's OK to delete tests that are obsolete.
Re:Tips for beginning systems and software engineers by maxxxxx on Thursday May 19, 2016 @10:53AM (#11730675)
I work in an enterprise environment and with all the stakeholders involved it's impossible to get a decent design upfront. But I still think you can test a lot of things even while change happens. Just avoid getting too detailed.
Re:Tips for beginning systems and software engineers by c2352466 on Thursday May 19, 2016 @08:04AM (#11729514)
Re:Tips for beginning systems and software engineers by pyrale on Friday May 20, 2016 @03:58AM (#11736172)
Designing tests that need to be changed often is a sign of high coupling between your tests and your solution, which in turn is often a sign of brittle design. You are testing an implementation and not a ndesired feature. Another potential problem is that your interfaces are changing too much, which means you are having trouble with thinking it out.

Possible solutions to this are TDD, or trying to write your tests in such a way that they would fit any implementation of your interface. For interface design, outside-in TDD is an interesting tool.

In any way, your problems with tests at early stages probably come from lack of practice. Doing less tests is certainly not going to help.

Re:Tips for beginning systems and software engineers by maxxxxx on Thursday May 19, 2016 @10:56AM (#11730691)
Automated testing is a learned skill. You need to develop your toolbox how certain things can be automated. It's a lot of work learning but once you have a decent system and know how to design things right for automation it's super valuable. In my current job we do a lot of automated testing and it took me several years to get my head around it and design things in way they can be automated.
Re:Tips for beginning systems and software engineers by kabdib on Thursday May 19, 2016 @09:29AM (#11730009)
Automated tests are great. Can't imagine not having them.

Automated test systems, in my experience, have sucked pretty hard. Often written by Q/A engineers frustrated at not being "real" engineers [yeah I know, toxic culture], and just not written well. Like the test systems I could never install on my workstation or even get running on my own, in order to reproduce problems and debug them. Or the systems that would assign "Priority 0 wake-up-in-the-middle-of-the-night" issues to failures in the test framework itself. Test frameworks are best kept as simple as possible; be wary of architecture astronautics.

I like the "TDD is nice, use it when it's useful" attitude. TDD as a tyranny works about as well as any other silver bullet we've seen in software development over the years (that is, not very well).

Re:Tips for beginning systems and software engineers by komali2 on Thursday May 19, 2016 @12:41PM (#11731486)
Off-topic, but I've always felt like "silver bullet" isn't a very good metaphor to use because we keep using it sarcastically, as above. Wasn't the silver bullet the only way to stop a werewolf? Or does the phrase come from somewhere else?

Anyway maybe something like magic bean or some other "looks useful but turned out not to be" metaphor would be better, not sure which one though.

Re:Tips for beginning systems and software engineers by kabdib on Thursday May 19, 2016 @01:18PM (#11731803)
"Silver bullet" was popularized (if not coined) by Fred Brooks in _The Mythical Man-Month_, and since that book is pretty widely read, the term is well understood. It's definitely sarcastic, but that doesn't mean it's not accurate.

[Depending on your mythology, you can kill a werewolf with a silver sword, and probably other silver objects. Poul Anderson has an interesting treatment of werewolf vulnerabilities in his collection _Operation Chaos_]

Re:Tips for beginning systems and software engineers by crottypeter on Thursday May 19, 2016 @06:55AM (#11729254)
Automated tests are very important but source control is an order of magnitude more important IMHO.

I hope its omission is because OP thinks it goes without saying. It doesn't though, just the other day I read on HN that people have colleagues who don't use any source control.

Re:Tips for beginning systems and software engineers by mooreds on Thursday May 19, 2016 @07:02AM (#11729277)
Absolutely. Using source control is like using an editor.
Re:Tips for beginning systems and software engineers by cm3 on Thursday May 19, 2016 @06:17AM (#11729133)
TDD can be tedious at times, but if you do it, you quickly reap the benefits. It makes testing easier, it reassures you that you didn't break everything completely with a random change, and it keeps your API in check. And it makes more of the process reproducable.
Re:Tips for beginning systems and software engineers by mbrock on Thursday May 19, 2016 @06:48AM (#11729233)
TDD is a kind of semi-formal specific process with a whole legacy of consultant workshops and all of that stuff.

So I think it's great to mostly ignore that, since it's contentious, and focus on that core question: how do I know that the system works correctly?

This also makes it obvious why type systems are a glorious ally, in addition to test suites and proofs.

And it's a core question because if I don't have grounded confidence in the system's correctness, then that's likely to be anxiety-inducing, irresponsible, and sometimes dangerous.

Re:Tips for beginning systems and software engineers by cm3 on Thursday May 19, 2016 @07:07AM (#11729300)
Right, and I didn't learn TDD formally. Sorry for using it freely. I write tests in tandem with the implementation and do not write tests and only then the implementation.
Re:Tips for beginning systems and software engineers by ahstilde on Thursday May 19, 2016 @08:36AM (#11729629)
When I knew exactly my code's requirements, I wrote the tests first. I was writing an interpreter. Tests-first was a smart move.
Re:Tips for beginning systems and software engineers by couchand on Thursday May 19, 2016 @09:37AM (#11730058)
I find writing tests first really helps me sort out the requirements if I'm unclear about them.
Re:Tips for beginning systems and software engineers by a_imho on Thursday May 19, 2016 @07:21AM (#11729342)
>Later down the road, when you've gotten into the habit of developing with no, or barely any automation, it will be much more difficult to learn to fit this tool into your coding routine.

Don't agree, imo a good automation service is abstract enough that it can be hooked into your cycle or at least appended to it. Automated tests and CI is a prime example.

I'm ready for the down votes, but the most important aspect of TDD is job interviews (or blog posts), telling others you do it even at home on your pet project is a big plus somehow. My guess it is the best way to communicate you care about quality, even if equating the two is obviously a half truth. Again Norvig vs. Jeffries tells me practices go a shorter way than actual practicing and ability.

Re:Tips for beginning systems and software engineers by hobolord on Thursday May 19, 2016 @04:57PM (#11733774)
where does one begin with automated testing? I realize it's importance after reading countless posts about it, but for the most part to me it seems like a lot of work is required to design the system that will perform the automated testing, depending on the complexity of your project