News for hackers. Stuff that matters.
Re:UX clichés by AlexTWithBeard on Sunday May 05, 2019 @09:37AM (#19832734)
I'd love to see a similar list for software engineering.

- if your code isn't important enough to be tested, it's not important to be written

- every function must fit a single screen

Re:UX clichés by usea on Sunday May 05, 2019 @10:05AM (#19832856)
- if your code isn't important enough to be tested, it's not important to be written

Does this rule cover all code? Do your tests, which are code themselves, not need their own tests? If not, what is special about a test that you know it's correct, when there is no faith in in non-test code?

Is it possible to write your program entirely out of the special "test" code, so that it's always correct and doesn't need to be tested?

Re:UX clichés by Waterluvian on Sunday May 05, 2019 @10:13AM (#19832895)
This is the danger of dumb rules like this. Nothing's universally true. Part of what an engineer is paid for is knowing what should be tested to what extent.
Re:UX clichés by mikeash on Sunday May 05, 2019 @07:42PM (#19835788)
You don’t necessarily need automated tests, but you absolutely do need to test your tests. With any new test, I always verify that 1) it passes with the fix 2) it fails without the fix. Many programmers skip step 2 and it’s a good way to end up with tests that don’t test what you think they do.
Re:UX clichés by AlexTWithBeard on Sunday May 05, 2019 @10:43AM (#19833033)
Well, the cliche apparently tries to cover all the code, which, as you correctly said, is non-practical.

The problem is that, like all other cliches, it sounds very convincing and it may take quite some time for the young inexperienced mind to rebuff it.

Re:UX clichés by swiftcoder on Sunday May 05, 2019 @01:25PM (#19833830)
One finds a truly surprising number of bugs in tests and test frameworks. So yes, your tests need tests.
Re:UX clichés by gmueckl on Sunday May 05, 2019 @06:00PM (#19835358)
A classic case of this bug is "I don't think this test case is doing what you think it is doing". I've produced my share of test cases that were elaborate duds.
Re:UX clichés by megaremote on Sunday May 05, 2019 @08:20PM (#19835934)
> Do your tests, which are code themselves, not need their own tests?

The tests of the tests is your original code. They are testing each other.

Re:UX clichés by mLuby on Sunday May 05, 2019 @12:09PM (#19833466)
My tests run during tests, so they automatically have 100% test coverage. :D
Re:UX clichés by plorkyeran on Sunday May 05, 2019 @01:46PM (#19833953)
It's not all that uncommon to have test code which is never actually run. Usually just because of disabled tests or leftover helper functions that are no longer used, but sometimes due to bugs in the tests themselves. Turning on code coverage tracking for the test code itself can sometimes reveal some interesting things.
Re:UX clichés by DonHopkins on Sunday May 05, 2019 @06:21PM (#19835444)
Always write recursive code. It tests itself!
Re:UX clichés by cuddlecake on Sunday May 05, 2019 @10:18AM (#19832909)
Everytime my co-worker tries to mention the "Pareto-Principle" (a.k.a. "Please let's not waste time on this, because it's frontend and I don't care about frontend") and "Single Source of Truth" (a.k.a. "let's expose our DB as directly as possible"), my soul barfs.
Re:UX clichés by zachrose on Sunday May 05, 2019 @10:32AM (#19832981)
I’ve used “single source of truth” to explain what I like about Redux/the Elm Architecture. Yeah it shouldn’t mean anything about access or indirection but it’s still a decent idea, no?
Re:UX clichés by haggy on Sunday May 05, 2019 @11:12AM (#19833192)
Depends on what your designing. If you're working on highly distributed, microservice based backends then single sources of truth can quickly become a serious bottleneck. Check out Event Sourcing if you're not already familiar with it. This is essentially a pattern where each area of your domain maintains its own view of the data it needs through immutable "facts" (events). In this case you could say the source of truth is your persistent event log but that doesn't hold true if you're not using one (not a great idea but hey I'm not here to judge)
Re:UX clichés by cuddlecake on Sunday May 05, 2019 @12:17PM (#19833496)
Even worse in my case, we are using event sourcing, but the client reads the Eventstore streams indirectly. It's terribly uncomfortable being the only one on a team of 7 who thinks this is terrible.
Re:UX clichés by cuddlecake on Monday May 06, 2019 @02:35AM (#19837286)
We have an API that lets clients read streams from beginning to end. They do not read the streams directly, but the API is thin enough that one might go "eh, just give them the lib"
Re:UX clichés by pgwhalen on Sunday May 05, 2019 @04:03PM (#19834718)
Can you describe what you mean by indirectly?
Re:UX clichés by Nimelrian on Monday May 06, 2019 @03:30AM (#19837488)
Not the person you're responding to, but I was on a team which probably did the same thing.

Instead of listening directly to the event store for events you have another non-abstracting layer on top and listen to that.

A sensible architecture would have that layer be an abstraction layer for business use cases, so instead of listening to "user-created", "user-edited" and "user-deleted" events and rebuilding the user state in the consumer every time an event is fired, you'd have that layer expose a single user state stream. The rebuilding is handled entirely within the layer.

Many people skip that and just re-expose the "primitive" streams of the event store, because they read "don't expose your persistence layer" and skipped the important ", expose the business state layer instead" which usually comes right after that.

Re:UX clichés by cuddlecake on Tuesday May 07, 2019 @02:46AM (#19847145)
By indirectly I mean that we have a WebSocket API that does nothing more than expose the primitive streams.

Our frontend client basically reads any stream it needs. And the main problem is, if you have to handle 40+ streams (and that is not even 30% of what's to come), it gets more and more difficult to provide a good user experience.

Thankfully, after much discussion we agreed to do it better... Soon ish.

Re:UX clichés by all2 on Sunday May 05, 2019 @10:40AM (#19833018)
I always thought single source of truth applied to documentation. It doesn't make sense used in terms of UI or anything beyond "I need info, where do I look?"
Re:UX clichés by AlexTWithBeard on Sunday May 05, 2019 @10:50AM (#19833067)
It can be applied to pretty much anything. In most cases it's quite reasonable (there should be one and only one list of users of the system), but taken to the extreme (there should be only one list of messages your application may ever give to the user) can hinder the development a lot.
Re:UX clichés by gmueckl on Sunday May 05, 2019 @06:07PM (#19835383)
I think this appliesmostly to persistently stored data. Redundancy in your data model is dangerous because the copies of the data will eventually get out of sync, resulting in weird bugs. No matter how often and how many transformations you expose the data, make sure that it only exists once deep down in your model.

On one of my last jobs, I had to convince my teammates repeatedly that this is a good idea. I always showed them how this was simpler and more robust, yet a few weeks later, they were about to commit the same design errors.

Re:UX clichés by cwilkes on Sunday May 05, 2019 @12:02PM (#19833436)
I can see it applying to UI when there’s two screens that display parts of the same information but are different due to caching. That’s maddening to an end user and then they don’t know what one to trust. Sometimes the first one is correct, sometimes the second.
Re:UX clichés by DonHopkins on Sunday May 05, 2019 @06:08PM (#19835386)
How about fitting functions to the problems they solve, not the screens they're displayed on?

And do you mean a wide screen retina monitor with a tiny font? Or 24x40 Apple ][ screens of FORTH code, where you leave out comments and put everything on one line just to make it fit?

https://donhopkins.com/home/archive/forth/supdup.f

Trying to fit a function on one page is antithetical to so many other much more important goals, like readability and cohesiveness and documentation.

I prefer code that uses white space and blank lines liberally to group and align related things together, and break apart separate steps, with complex calculations broken apart using intermediate results stored in descriptively named variables, and as many comments as necessary, even if it doesn't all fit on one page.

https://donhopkins.com/home/archive/forth/alloc.f

Re:UX clichés by damontal on Sunday May 05, 2019 @12:50PM (#19833669)
Single screen eh? Is that why I see all the devs at the office with their screens turned sideways?
Re:UX clichés by flukus on Sunday May 05, 2019 @08:44PM (#19836039)
> if your code isn't important enough to be tested, it's not important to be written

The majority of code that delivers this page to you (web server, OS's, browser, networks, drivers) in a readable way has no unit tests and most of it has very little QA. Presumably you think you shouldn't be able to read this page?

> every function must fit a single screen

A policy by assholes that don't do maintenance. Diving through a million little functions is a lot harder than fewer bigger ones (up to a point). Parroting this show a complete lack of understanding of why long functions can be bad, it's the state not the scrolling.

Re:UX clichés by tome on Sunday May 05, 2019 @01:41PM (#19833924)
You can write bad code in any language

Imperative languages are the best match for the underlying hardware

Use the right tool for the job

A language is just another tool in your toolbox

Re:UX clichés by jasonhansel on Sunday May 05, 2019 @10:58AM (#19833108)
I could add an entire 10-page rant about people who insist on the Liskov substitution principle.
Re:UX clichés by mikeash on Sunday May 05, 2019 @07:48PM (#19835809)
I never heard of the LSP being at all questionable. Can you elaborate?
Re:UX clichés by jasonhansel on Monday May 06, 2019 @08:17AM (#19838686)
Not without writing that 10-page rant....
Re:UX clichés by AlexTWithBeard on Sunday May 05, 2019 @11:01AM (#19833138)
Whether square should inherit from rectangle?
Re:UX clichés by sys_64738 on Sunday May 05, 2019 @11:19AM (#19833216)
In other words, untested code is broken code.
Re:UX clichés by bdcravens on Sunday May 05, 2019 @01:32PM (#19833867)
Except almost no code is untested. It's just typically not tested via $approvedProcess
Re:UX clichés by mikeash on Sunday May 05, 2019 @07:45PM (#19835801)
In my experience, error handling code is often completely untested by any means.