News for hackers. Stuff that matters.
Re:Uncle Bob and Silver Bullets by bad_user on Friday October 06, 2017 @10:00AM (#15416817)
My problem with Uncle Bob's opinions is that they are pretty common within the industry, even if "discipline" really isn't the issue and all those negative feelings people allude to are warranted. In general, people are made to feel guilty for not being able to use the shitty tools and techniques we are given.

Lets take for example ORMs and Hibernate in particular. I can't tell you how many times I've seen horrors related to ORMs / Hibernate, because of an actual mismatch between relational data and object graphs, but then developers are made to feel guilty because they "aren't using it right", made to think that only if they switch this setting on, use this and that annotation, read a book or two, everything will be alright going forward.

Most such projects fail from a technical perspective of course, because the developers having invested so much time in those shitty techniques, exploration of alternatives becomes unfathomable to them, because all of that effort which can span years ends up being unjustified. And I suspect that Uncle Bob is guilty as well.

Lets take TDD as another example. I remember a time when TDD was religious dogma, which was unbelievable, because I couldn't see actual TDD in projects of companies advertising TDD in job descriptions. Much like Agile, Scrum and all that crap, it usually doesn't work because, as the masters will quickly tell you, you're "not doing it right". I've seen a single project where TDD was implemented by the book, but the developers where wasting so much time on testing stuff, including endless discussions, that they were forgetting TDD wasn't the actual artifact they had to deliver.

Now Uncle Bob tells me that we don't have the discipline required. That's not surprising. I’ve been hearing this argument in some form or another for years.

The surprise is the attention that we are paying to what Uncle Bob has to say.

Re:Uncle Bob and Silver Bullets by _wc0m on Friday October 06, 2017 @10:47AM (#15417166)
Completely agree with this. The post where Martin derides modern, type-safe languages (Kotlin and Swift) [0] was just unbelievable to me.

"Ask yourself why we are trying to plug defects with language features. The answer ought to be obvious. We are trying to plug these defects because these defects happen too often.

Now, ask yourself why these defects happen too often. If your answer is that our languages don’t prevent them, then I strongly suggest that you quit your job and never think about being a programmer again; because defects are never the fault of our languages. Defects are the fault of programmers. It is programmers who create defects – not languages."

Arrgh! Until we get out of this ridiculous, macho, victim-blaming mindset, software development will be stuck in the relative dark ages. More, better, safer languages, please!

[0] http://blog.cleancoder.com/uncle-bob/2017/01/11/TheDarkPath....

Re:Uncle Bob and Silver Bullets by oblio on Friday October 06, 2017 @10:58AM (#15417269)
Somebody should show Uncle Bob this: https://youtu.be/fPF4fBGNK0U

My point being: yes, if we'd be perfect drivers at all times and in all weather conditions there would be no more accidents. Luckily for us auto designers haven't adopted this perspective :)

Re:Uncle Bob and Silver Bullets by GuiA on Friday October 06, 2017 @02:01PM (#15418853)
The top comment on that video, in light of the points being made in this thread, is quite ironic:

"And because of this 'improved safety' we have millions of drivers out there who drive even faster and take even more risks, because they think the new cars are so much safer. "

(of course this comment is silly, the number of motor vehicle deaths per capita is about a third of what it was 50 years ago: https://en.wikipedia.org/wiki/List_of_motor_vehicle_deaths_i...)

Re:Uncle Bob and Silver Bullets by blktiger on Friday October 06, 2017 @01:41PM (#15418685)
This is a video of a crash _test_. Personally, I'm not sure TDD is necessarily the answer but even with typed code you should still have tests. You just don't need tests for things covered by the type system.

Of course, it also depends on what the software is being used for. If I create a script for automating something just for me, I don't see any reason to add repeatable tests.

Re:Uncle Bob and Silver Bullets by msla on Friday October 06, 2017 @12:38PM (#15418142)
You just reminded me of my old driving instructor.

"All accidents are your fault. Got rear-ended? Shouldn't have been driving so slowly, or shouldn't have stopped. Got t-boned? Should have looked more closely at the intersection. Skidded on ice? Shouldn't have been driving so quickly, or turned so sharply. Yes, you avoided the pedestrian, but that isn't an excuse. In extremis, you shouldn't have been driving that day at all, and you do always have that option, so it's your fault regardless."

The line between empowerment and victim blaming is surprisingly thin. ;)

Re:Uncle Bob and Silver Bullets by unclebobmartin on Friday October 06, 2017 @05:26PM (#15420594)
That was cool!
Re:Uncle Bob and Silver Bullets by s73ver_ on Friday October 06, 2017 @02:21PM (#15419053)
I agree with both, really. Those defects are our fault, and they are there because we aren't careful enough with the code we write. We know about these things, and yet, we don't work to prevent them. We either handwave them away, or we give into management pressures to just get the thing out the door.

Now, that said, one of the ways you can work to prevent these things is to use better tools. Like languages that don't let you make those kinds of mistakes as easily.

Re:Uncle Bob and Silver Bullets by jwdunne on Friday October 06, 2017 @05:32PM (#15420638)
I can see how that would be popular but it's wrong.

You can take that same reasoning and say we should build web projects in C or assembly because any defects are our own fault.

Let's be honest. That's bollocks. It's just the same old "real programmers use X" line. I'm sure there's an XKCD that parodies it.

Sure we need more discipline. Who doesn't? Yet that discipline is far better spent on doing what the compiler can't. It makes no sense doing what a computer can do unless it's really necessary. That's why we're programmers after all, right?

Re:Uncle Bob and Silver Bullets by ncds42 on Friday October 06, 2017 @07:42PM (#15421285)
Using C as an example is a straw man. There's been A LOT of progress since C. Can you say the same for Java or Python? Not as much.
Re:Uncle Bob and Silver Bullets by jwdunne on Saturday October 07, 2017 @02:32AM (#15422560)
No it's not. It's the same argument we've had about any kind of progress in programming languages since we started using higher level languages (I.e Fortran and up).
Re:Uncle Bob and Silver Bullets by ncds42 on Friday October 06, 2017 @07:36PM (#15421261)
He didn't condemn Kotlin and swift. He is saying that they aren't necessary and don't solve the original problem. That the constant search for a new framework or of language that will fix everything is a futile attempt to avoid learning how to more effectively code with the tools you already have.
Re:Uncle Bob and Silver Bullets by piaste on Saturday October 07, 2017 @11:34AM (#15424149)
In one of the linked posts he says that 100% test coverage might not be truly achievable, but it's nonetheless a valid asymptote to aspire to.

I think that exact argument applies to designing ever-safer, ever-better languages. You might never have the perfect tools that ensure 100% program correctness, but it's sure as hell what a tool-maker should aspire to.

Re:Uncle Bob and Silver Bullets by AlexCoventry on Friday October 06, 2017 @06:41PM (#15420987)
His argument mostly makes sense up to the point where he says tests are the only solution... Why not default to overriding the safeties, then use them where your reasoning says they ought to hold? Cheaper than writing a bunch of tests just to guard against null pointers.
Re:Uncle Bob and Silver Bullets by eradicatethots on Friday October 06, 2017 @11:46AM (#15417698)
Personally I’d prefer my language to let me fuck up.
Re:Uncle Bob and Silver Bullets by jhayward on Friday October 06, 2017 @03:13PM (#15419546)
> Personally I’d prefer my language to let me fuck up.

And as a (completely hypothetical) competitor of yours, I would support you using a language that encourages you to fuck up frequently.

Re:Uncle Bob and Silver Bullets by collyw on Saturday October 07, 2017 @09:22AM (#15423665)
There is a difference between letting you and encouraging you to fuck up. I have given Rust a go, but its tricky to understand, and that seems like a language designed not to let you fuck up.
Re:Uncle Bob and Silver Bullets by Devagamster on Friday October 06, 2017 @12:10PM (#15417911)
y tho. you can have safety and expressivity...
Re:Uncle Bob and Silver Bullets by milesvp on Friday October 06, 2017 @12:44PM (#15418194)
it's often not about expressivity, it's about conciseness. It's much easier to say a correct statement than it is to prove the statement correct. This seems to be the main cost to stongly typed static languages, all the time spent proving to the compiler that this thing is actually compatible with that thing.
Re:Uncle Bob and Silver Bullets by bad_user on Friday October 06, 2017 @01:17PM (#15418460)
What strongly typed static languages are you talking about?

> proving to the compiler that this thing is actually compatible with that thing

I used to have this opinion, but nowadays I think that time is actually spent proving to myself that I'm right, which is always a good thing.

Having a compiler to do the hand holding is not such a bad thing, because the alternative is println-development.

What happens in a dynamic language is that you have to load in your head the shape of the data your working with, the API and everything really. Your head can't hold that much for anything that is bigger than a simple script, so you have to constantly execute and verify (in the REPL, in the browser, with a unit test, etc) each line of code that you write, before writing the next line of code.

This is why people complain about compilation speed in Scala, Haskell, etc, even if they miss they point, because even a slow, static compiler will improve efficiency, since you no longer have to compile and execute each line of code before you write the next one.

And yes, in my experience this is exactly what happens in big code bases built in dynamic languages, short of being really sloppy and introducing lots of bugs.

Re:Uncle Bob and Silver Bullets by kibwen on Friday October 06, 2017 @01:18PM (#15418473)
As opposed to the main cost to dynamically-typed languages, all the time spent proving to the test suite and proving to your teammates that this thing is actually compatible with that thing. And I say this as someone who adores Python! Dynamic typing does not magically make problems go away, it just makes them easier to ignore (whether deliberately or accidentally).
Re:Uncle Bob and Silver Bullets by mpweiher on Friday October 06, 2017 @01:51PM (#15418779)
> proving to the test suite and proving to your teammates that this thing is actually compatible with that thing.

I really don't know where that canard comes from. My test suites rarely if ever explicitly test compatibility.

They test for specific values: if I do this and that, do I get the value that I expect. The type "test" gets covered implicitly, because if it's not the correct type, it will also not be the correct value.

Re:Uncle Bob and Silver Bullets by lkitching on Friday October 06, 2017 @02:14PM (#15418971)
The problem is that without knowing the type in question you don't know the values you're testing with cover all of the possible cases. When interfacing with an external dynamically-typed function this requires attempting to reverse-engineer the types from the definition (and recursively for all the functions it calls).
Re:Uncle Bob and Silver Bullets by thomascgalvin on Friday October 06, 2017 @10:39AM (#15417104)
> Lets take for example ORMs and Hibernate in particular. I can't tell you how many times I've seen horrors related to ORMs / Hibernate ...

My teams don't use ORMs anymore. I've found that all of the time we "save" by not hand-writing SQL is instead lost fighting with the ORM, and problems with SQL are a lot easier to Google.

I've also found that the ability to swap databases quickly is almost totally unimportant. 100% of the time we're targeting SQLite and PostgreSQL. I don't need a few extra thousand lines of code so I can theoretically support SQL Server running on a toaster in some kid's dorm somewhere.

Re:Uncle Bob and Silver Bullets by jdmichal on Friday October 06, 2017 @03:24PM (#15419645)
I'm actually a big fan of myBatis [0] for this very reason. You still write all the SQL, including stored procedures. All it does is map objects to input parameters, and map result sets to objects. Which is awesome, because that's the part of database processing that is actually tedious and sucks. Writing SQL is not.

I think StackExchange's Dapper [1] works similarly in the .NET world.

[0] https://github.com/mybatis/mybatis-3

[1] https://github.com/StackExchange/Dapper

Re:Uncle Bob and Silver Bullets by benmmurphy on Friday October 06, 2017 @03:46PM (#15419812)
this is pretty close to the sweet spot for me. being able to map rows to object easily + being able to easily compose queries are what i want from my 'ORM'. if your SQL layer doesn't support chaining conditions you end up writing it anyway so being able to do .and(condition).and(condition).and(condition), etc is pretty useful. ActiveRecord in rails comes close to this but it also manages relationships as well which makes things a bit more complicated but not as complicated as what hibernate or other ORMs do.
Re:Uncle Bob and Silver Bullets by jsight on Friday October 06, 2017 @12:35PM (#15418110)
Having worked on many systems like this, I generally don't really consider it to be better. Most of them just introduced different edge case behavior than Hibernate.

Though, I generally prefer a non-religious approach to ORM mapping anyway. Use Hibernate for the stuff that it is good at. If you find it awkward for some particular service, don't be afraid to grab a DB connection and do a bit of SQL (maybe even using Hibernate's powerful rowmapper functionality) when it is easier.

Any ORM is going to be a little rough in some cases (even ones you write yourself) and none fit all problems perfectly.

Re:Uncle Bob and Silver Bullets by humanrebar on Friday October 06, 2017 @12:42PM (#15418180)
> Use Hibernate for the stuff that it is good at.

Sure, but that's a bit circular. I find that a sensible default is to write the code to match the data, not abstract the data to fit the code. Because, if nothing else, you'll want to understand that data with another language or framework. If it's a one-off Java project that will get thrown away in a few months, whatever is fine, but most Java applications (especially enterprise Java) aren't throwaway projects.

Do you know what works in pretty much every language? Do you know what will be supported in 30 years? SQL queries.

Hibernate is good at some things, but if we think in terms of product lifetimes and not sprints, I think SQL is a much lighter dependency.

Re:Uncle Bob and Silver Bullets by jsight on Monday October 09, 2017 @11:08AM (#15434402)
I would actually argue that raw SQL in Java has worked pretty poorly overall ever since it was introduced. The APIs have gotten better, and will probably continue to.

But you know what has consistently provided a nice abstraction that works really well for 90% of cases (even if you start with DML, as you should)? Hibernate :)

I've used plenty of homegrown frameworks, and they just never are quite what their originators crack them up to be.

Re:Uncle Bob and Silver Bullets by mannykannot on Friday October 06, 2017 @10:53AM (#15417221)
I think every commercial system that I have worked on has had a database abstraction layer of some form, ignoring the fact that an RDBMS with SQL was a better abstraction layer than what they came up with.
Re:Uncle Bob and Silver Bullets by stephengillie on Friday October 06, 2017 @12:49PM (#15418229)
It doesn't help that the common advice to securing a database application is "don't, it's too hard to secure databases, just write another application to talk to the database application, and secure that."

A database is just another application. SQL is just another Turing-complete programming language.

Re:Uncle Bob and Silver Bullets by gyani95 on Friday October 06, 2017 @10:51AM (#15417213)
How do you make sure that what you are writing is secure?
Re:Uncle Bob and Silver Bullets by efdee on Friday October 06, 2017 @11:25AM (#15417512)
What difference does an ORM make?
Re:Uncle Bob and Silver Bullets by zaphar on Friday October 06, 2017 @11:33AM (#15417575)
ORM's by and large do protect your from SQL injection attacks.
Re:Uncle Bob and Silver Bullets by Sacho on Friday October 06, 2017 @11:38AM (#15417624)
By using prepared statements, which you can use as well.
Re:Uncle Bob and Silver Bullets by nnq on Friday October 06, 2017 @12:30PM (#15418072)
They don't. All decent ORMs have a layers architecture, and it's usually some "query builder/processor" or "DAL" or whatever that sits under/above the ORM your app uses (and can usually also be used directly, but has a horrible API since it's not optimized for this use case) that does the simple but tricky tasks of parameter sanitization and all...

The ORM is just an big fat thing that sits on top, and from which you only use 10% of the functionality it provides, but in theory each app uses a different 10% so it justifies itself...

ORMs can be ok... as long as you don't build business logic on top of and inseparable from it!

(As an example of horrible use of ORMs: some frameworks have ORM systems with an events system on top... god have mercy on your soul if you make the mistake of using this system to implement business logic, and end up with it accidentally depending on db connection and caching details, and not having time to refactor when you realize this! ...but if you avoid the trap, you can reap the benefits of the functionality that the ORM provides, while moving your logic at at a whole different layer of the app - hint: just invent a new "XBizLogicServices layer" or whatever and not import framework stuff into it if you can't find a better design, it will at least be easily testable.)

Re:Uncle Bob and Silver Bullets by zaphar on Friday October 06, 2017 @12:39PM (#15418148)
I wasn't defending ORM's.

I was just pointing out that if you use one you do receive protection from injection attacks. Just because only part of the ORM is actually performing the protection doesn't change the fact that you have it as a consequence of using the ORM.

You can also get the same protection by using a SQL library that supports prepared statements. But ORM's still provide that benefit.

Re:Uncle Bob and Silver Bullets by mannykannot on Friday October 06, 2017 @10:48AM (#15417180)
Martin has built up a large following of acolytes, some of whom are very active wherever software development is discussed, in a very dogmatic way (such as the guys for whom TDD is the one true solution to every problem.) He has encouraged this through his didactic style of writing, which focuses on a few of the most basic faults in current development practice, and elevates them to being the roots of all evil, without any regard to the problems that you will run into once you have these surmounted.
Re:Uncle Bob and Silver Bullets by atulatul on Friday October 06, 2017 @12:07PM (#15417894)
Agree with this. I like some of his ideas. But a problem I have(possibly of my perception) with uncle Bob is that he gets too aggressive. If you don't have X percent (100%) code coverage, then you are doing it wrong, you are not a craftsman, etc. Well, Dan North put things in perspective a bit- https://dannorth.net/2011/01/11/programming-is-not-a-craft/ The problem is dogma. And it keeps repeating. But probably this aggression helps them in their careers.

(Not a frequent contributor to comments/ here on HN. Mostly like to read.)

Re:Uncle Bob and Silver Bullets by unclebobmartin on Friday October 06, 2017 @05:28PM (#15420609)
I have never told people that they must have 100% test coverage. Indeed, I tell them that 100% test coverage is impossible.

What you are referring to is a statement I frequently make -- 100% coverage is the goal. It's an asymptotic goal, but it's still the goal. No lesser goal makes any sense.

Re:Uncle Bob and Silver Bullets by mannykannot on Saturday October 07, 2017 @08:03AM (#15423434)
But then you can find people saying that type checking has no value because all errors will be caught by the testing you should be doing - I came across someone saying that just a few days ago.

I am not sure that 100% can be called an asymptotic goal, given that you cannot even get close, for real systems. Once you recognize this, you can start having a realistic discussion about what you actually will be able to test for, how best to allocate your limited resources, and what other steps you might take to mitigate the consequences of this unfortunate fact. It means that methodologies bassed on extensive testing must justify this use. An additional benefit is that we might be able to discuss what we can do to improve software development without the sort of dogmatic non-sequitur that I mentioned in my first paragraph.

Re:Uncle Bob and Silver Bullets by Chris2048 on Monday October 09, 2017 @10:00AM (#15433817)
> 100% coverage is the goal. It's an asymptotic goal, but it's still the goal

What is a goal then? A maximum? A desirable attribute?

I'd argue a fixed percentage target of any kind doesn't make sense, much like measuring productivity by lines of code.

Re:Uncle Bob and Silver Bullets by martincmartin on Friday October 06, 2017 @10:02AM (#15416839)
I assume you've seen "Object-Relational Mapping is the Vietnam of Computer Science"?

http://blogs.tedneward.com/post/the-vietnam-of-computer-scie...

Re:Uncle Bob and Silver Bullets by bitexploder on Friday October 06, 2017 @11:40AM (#15417635)
ORM is like C++. SQLAlchemy is the best ORM I know of. You can use it lightly and map tables, migrations, and never go deep into the ORM "problem". Saves you a lot of effort doing SQL push-ups. Many projects doing OO end up building a worse ORM from scratch eventually.
Re:Uncle Bob and Silver Bullets by humanrebar on Friday October 06, 2017 @12:44PM (#15418189)
> Many projects doing OO end up building a worse ORM from scratch eventually.

Sure, and lots of people end up implementing a lisp in C++. Doesn't necessarily mean they should just use a lisp instead. Usually it just means they should learn how to use their tools idiomatically.

Re:Uncle Bob and Silver Bullets by arwhatever on Friday October 06, 2017 @01:23PM (#15418502)
Someone help me with the origin of this (paraphrased) quote, which I have not been able to re-find on my own:

"The sooner you admit that you can't fit the whole program's source code in your head, the sooner you can begin incorporating that into your design."

Re:Uncle Bob and Silver Bullets by Jtsummers on Friday October 06, 2017 @02:03PM (#15418879)
Notes on Structured Programming: http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD249.PDF

Page 3:

  Summarizing: as a slow-witted human being I have a very
  small head and I had better learn to live with it and to
  respect my limitations and give them full credit, rather
  than to try to ignore them, for the latter vain effort
  will be punished by failure.
The Humble Programmer: http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD340.PDF

Page 11:

  The competent programmer is fully aware of the strictly
  limited size of his own skull; therefore he approaches
  the programming task in full humility, and among other
  things he avoids clever tricks like the plague.
He expressed similar thoughts on other occasions. And there are others who express the same idea.
Re:Uncle Bob and Silver Bullets by dorian-graph on Friday October 06, 2017 @05:06PM (#15420490)
Thank you for this! It's nice to have a large repository of EWD's writings.
Re:Uncle Bob and Silver Bullets by Chris2048 on Friday October 06, 2017 @11:13AM (#15417399)
The most common tactic for pushing TTD is confusing "no TDD" with "no testing". So many "benefits of TDD" begin with sabotaged examples of a team that doesn't test at all, before trying TDD - classic stone-soup.
Re:Uncle Bob and Silver Bullets by vkuruthers on Friday October 06, 2017 @10:38AM (#15417097)
I agree with this comment. OTOH it's very hard to have and enforce discipline in commercial SW development in the US anyway. Managers just want solutions hacked out as quick as possible, so no real time for properly crafting solutions in most cases. Scrum etc. also drives this type of mindset.
Re:Uncle Bob and Silver Bullets by walshemj on Friday October 06, 2017 @12:43PM (#15418188)
Agreed Scrum RAD DSDM are not suitable for all software projects.
Re:Uncle Bob and Silver Bullets by unclebobmartin on Friday October 06, 2017 @05:25PM (#15420592)
There's nothing wrong with tools. I like tools. I use them all the time. I want better ones.

I also want programmers to be able to use those tools well.

Finally, I look at a lot of crap code written by programmers who throw all their disciplines away because of schedule pressure or other factors. For the sake of going fast they throw away everything that might allow them go actually go fast.

Re:Uncle Bob and Silver Bullets by vkhorikov on Friday October 06, 2017 @04:48PM (#15420361)
Re:Uncle Bob and Silver Bullets by 201709User on Friday October 06, 2017 @10:32AM (#15417050)
Bob makes money selling TDD to chumps.
Re:Uncle Bob and Silver Bullets by s73ver_ on Friday October 06, 2017 @02:07PM (#15418913)
I think you don't see much TDD in companies because, when a snag is hit, the first thing out the window is testing.