News for hackers. Stuff that matters.
Re:Who builds a house without drawing blueprints? (2015) by WJW on Thursday June 11, 2020 @06:18AM (#23487185)
I wonder how architects would go about their jobs differently if they could build a new house in a few seconds, run a few thousand unit tests on it and then tear it down again at almost zero cost.
Re:Who builds a house without drawing blueprints? (2015) by goalieca on Thursday June 11, 2020 @07:37AM (#23487720)
They can in modelling tools.
Re:Who builds a house without drawing blueprints? (2015) by WJW on Thursday June 11, 2020 @08:16AM (#23487998)
Do they actually run unit tests over those? I've seen the VR modelers where you can "walk" through the builidng but those didn't really verify whether there was enough room in the walls for piping, light fall, floor strength limits, fire requirements etc.

I know at least one department in the Dutch navy was using constraint solvers to design a new submarine class but I haven't heard about a lot about house design. Not a home architect though, so maybe I just haven't kept up to the state of the art there.

Re:Who builds a house without drawing blueprints? (2015) by tonyarkles on Thursday June 11, 2020 @08:48AM (#23488223)
> do they run unit tests on those

My initial glib answer is “no, the engineers are stuck to deal with the bad design afterwards” :)

My less glib answer would be that most disciplines of engineering do do modelling and “virtual testing”. I’ve been working on largish drones for about 18 months. Electronics get specced out, circuits get drawn and simulated, currents are estimated and components are specced based on those estimates, etc. On the mechanical side, parts are drawn in CAD, analyzed for proper fit and assemble-ability, FEA is used to determine whether a part is likely to be strong enough for the static and dynamic loads that will be placed on the aircraft, etc. All of this happens, generally, before circuit boards or modules get ordered or before the first chunk of aluminum goes into the CNC.

As far as building software goes, I’ve recently had to start digging into DO-178C, and I’m pretty impressed so far. Despite having been through engineering school (EE), I haven’t ever really had to put this level of rigour into practice for software before.

It feels slow and somewhat time consuming, but I’m feeling more and more confident that the module I’m working on is going to be pretty damned robust. It’s not a “certification required” unit, but it would be a huge pain in the ass if it failed and couldn’t recover without human intervention; as a result I’m doing more of a “DO-178C lite” with detailed low-level requirements stated explicitly, system architecture drawn out first, sequence diagrams for the complicated event-driven parts, state charts for the different parallel systems, etc.

Re:Who builds a house without drawing blueprints? (2015) by hwayne on Thursday June 11, 2020 @12:23PM (#23490441)
Re:Who builds a house without drawing blueprints? (2015) by RealityVoid on Thursday June 11, 2020 @08:17AM (#23488006)
And that's the thing, the code _is_ the blueprint. What is code if not a sufficiently detailed specification?
Re:Who builds a house without drawing blueprints? (2015) by tonyarkles on Thursday June 11, 2020 @09:59AM (#23488949)
That has, until recently, been my philosophy for a long time. See my sibling comment for context.

Another example of where modelling both saved time and helped make a system more reliable: about 6 months ago, I took on a project that involved integrating a Bluetooth-Iridium gateway into an existing app, so that the app could work in areas with no wifi or cell connectivity. There’s a lot of things going on here: the Iridium modem has a limited queue size, transmissions are not instant, connectivity to the constellation fades in and out, Bluetooth randomly disconnects, etc.

My gut reaction is to slowly build it out. Start with the low-level BLE stuff and build layers on top. Which I did do to shake out the functionality. But before I went and built the whole thing, I stopped and tried to build a TLA+ model of the system. That modelling was only somewhat successful; based on the constraints applied by each part, I discovered that it would be impossible to make the entire system reliable. What the model did, though, was highlight specific failure cases that would need to be detected and reported to the user.

I agree that, in the end, the source code ends up being a detailed and precise specification of what the system does. What I’m realizing more and more though is that putting together more abstract models of the system ahead of time can save a ton of time by forcing you to think through cases that would (in my experience) end up with dirty hacks when they’re discovered after 90% of the code has been written.

It’s not the approach required for every project. I still love firing up a Python or Lisp REPL and hacking away. It’s way more fun! But for certain types of software, it’s very much not the appropriate way to work.

Re:Who builds a house without drawing blueprints? (2015) by hwayne on Thursday June 11, 2020 @12:33PM (#23490560)
> That modelling was only somewhat successful; based on the constraints applied by each part, I discovered that it would be impossible to make the entire system reliable.

"I discovered I can't satisfy all my requirements at once and need to plan my tradeoffs in advance" sounds like a pretty successful modeling result to me!

Re:Who builds a house without drawing blueprints? (2015) by tonyarkles on Thursday June 11, 2020 @08:43PM (#23494799)
You're right :). I sometimes look at that modelling exercise with disappointment; not because I didn't get any value out of it (I got a ton), but because I'm not yet good enough at TLA+ to have been able to successfully write a model that handled all the edge cases.
Re:Who builds a house without drawing blueprints? (2015) by RealityVoid on Thursday June 11, 2020 @03:51PM (#23492689)
I like this reply, but my instinct is to ask, would you not have found out the same thing by doing the implementation? This is the first time I hear about TLA+ and I don't know how difficult it is to work with. Was it easier than doing the thing? It does sound interesting though. But I assume that there is quite a curve to learning something like it.

And, my nitpicky self also says "but that's modeling! Surely, architecture and modelling is not the same thing!". But again, my lack of insight might lead me astray.

I do agree, a little bit of thought beforehand is very useful. Usually, I do this by doing a sketch on paper beforehand, if the mental map is not clear enough, maybe do some simple flow chart that describes the core functionality, just to make sure I understand it well enough.

Re:Who builds a house without drawing blueprints? (2015) by hwayne on Thursday June 11, 2020 @07:45PM (#23494412)
I wrote this case study on using TLA+ for a business project: https://medium.com/espark-engineering-blog/formal-methods-in.... This was a system we'd already spent a lot of time working on and consistently saw a direct correlation between making changes and new production fires. TLA+ caught issues with the planned changes before we actually implemented them.
Re:Who builds a house without drawing blueprints? (2015) by tonyarkles on Thursday June 11, 2020 @08:41PM (#23494791)
And I would like to thank you for the material you've written. You, personally, played a huge role in my choice to look into and eventually standardize on TLA+ as my "distributed systems modelling" tool as well as getting me going on it. You rock, thank you!
Re:Who builds a house without drawing blueprints? (2015) by tonyarkles on Thursday June 11, 2020 @08:40PM (#23494781)
> "would you not have found out the same thing by doing the implementation?"

Yes, although there's a couple of important points to that:

- A lot of it wouldn't have been discovered until late into the implementation. The project itself looked straightforward, and my estimates would have been brutally off if I hadn't done the modelling exercise ahead of time.

- Some of it would likely not have been discovered until after the app shipped. Rare edge cases. To give you context, it's an Android app that talks to an Iridium (satellite) modem over BLE. I basically modelled an abstract Android Activity lifecycle with extra events for user actions, a BLE stack (both sides of the connection), the Iridium connection, and the server on the other side of it. Each of these state machines were relatively straightforward to model. The insight came from letting TLA+ find paths through the five parallel state machines that got me into a weird state. (For an easy example, we make a request that successfully makes it out the Iridium modem to the server, the server replies, the response is delivered to the modem, and there's a corrupt BLE packet that terminates the connection.)

- You're right, architecture and modelling are different things. My flow is basically: 1) high-level requirements, 2) model of the system based on the HLRs, 3) low-level requirements derived from the HLRs and the insight gained from modelling, 4) architecture derived from 1,2,3.

- The amount of thought I'm going to put into a project ahead of time depends drastically on the project. The Iridium/BLE project? On the safety spectrum of 1 (mobile game) to 10 (flight critical software for a commercial jet), that project was about a 6-7. The software didn't have the ability to kill someone, but if it failed in the wrong way, they might believe someone was coming to rescue them when no one was coming.

Re:Who builds a house without drawing blueprints? (2015) by hwayne on Thursday June 11, 2020 @12:24PM (#23490456)
Which blueprint? Engineers I talked to often mentioned that they'd make several different blueprints and different layers of detail. Is code the "high level" or the "low level" blueprints?