PythonEditor icon indicating copy to clipboard operation
PythonEditor copied to clipboard

blocks: prevent download when a block is incomplete

Open jaustin opened this issue 8 years ago • 3 comments

In situations like the image below where a block that requires some other input doesn't have it: image

...it would be kind to the user to stop them from downloading a broken hex file. (Broken in the sense that because the block is missing a required input, we know that the parser will fail to interpret the script)

Can we detect that a block is missing a required docked other block?

jaustin avatar Mar 20 '17 20:03 jaustin

So you're asking us to determine, from the blocks for an arbitrary computer program, whether the program is "well formed"..?

With my devil's advocate hat on, what's wrong with letting them discover there's an error? It's an opportunity for them to learn from their mistake.

Having had a look around https://developers.google.com/blockly/guides/overview -- I can't see an obvious way for us to check for missing "arguments" (if you see what I mean) without having to do a huge amount of work ourselves to analyse the blocks and/or Python.

An alternative would be for me to modify the emitters so that if no argument is passed to the block, a "safe" default is used. However, I'm reticent to do this since we're generating code that the user hasn't actually specified.

Personally, I like people to make mistakes and learn from them. It's all part of being a software developer. ;-)

ntoll avatar Mar 20 '17 21:03 ntoll

An alternative would be for me to modify the emitters so that if no argument is passed to the block, a "safe" default is used. However, I'm reticent to do this since we're generating code that the user hasn't actually specified.

This is the approach most blockly generators follow, but I also have my reservations as it seems counterintuitive to generate default code out of missing inputs, specially when there isn't a clear candidate for a default value. I think cases like this is where the shadow blocks come in quite handy.

As a side note, we should have a block to generate the music DSL.

carlosperate avatar Mar 21 '17 00:03 carlosperate

I think the 'shadow block' version of events is the best workaround to the larger problem of "is this well formed". I think the "does this block have missing inputs" problem is a much simpler subset of the "is this arbitrary program well formed" one though!

As far as letting kids find an error - I'm very happy for them to find there's an error, but I'd like them to know sooner rather than later. What I saw last weekend was that people often tried a few things before downloading and then had many errors all to deal with one after another. This led to a bit of a trough of disillusionment, as they weren't just solving one problem, but a string of them before they actually saw their vision for the program realised.

So, allowing them to fail fast and ideally "not move on" if they have an error in a program should help that. Shadow blocks removes the failure, so is a slightly different solution.

More philosophically - at their best, I think block-based coding languages should help people develop computational thinking skills without simultaneously having to learn the attention to detail and precision that correct syntax requires. Perhaps "without" is too strong, but with less frustration from that side of things. Python+blockly is already doing this well, we had 7 year olds making good progress with minimal help from us :D

jaustin avatar Mar 23 '17 00:03 jaustin