Question

Does usually Safety Critical systems make use of Encapsulation? Let say an embedded system implemented in Ada or C for a satellite, jet fighter, submarine or an airliner.

I got the question since to me the concept of encapsulation is there to help the Software Development and Maintenance process, not the software itself. As it adds up a little bit overhead to access the data via Accessors instead of direct in-memory access, I'm wondering if it is acceptable for such a safety-critical application to implement an abstraction layer like encapsulation.

Also I assume there are tons of code powering up an airliner for example, so if they don't want to have those concepts on-board, then the software development might get out of hand at some point.

P.S. if the question seems off-topic please fill free to comment or edit, as it's a real question to me and I hope to get some answers from the people who has already worked on similar applications.

P.P.S. Just to prevent some confusions, modern versions of Ada has OOP features and encapsulation could be simply achieved in C as well.

Was it helpful?

Solution

In a Safety Critical systems, one of the most important aspect is certification and maintainability. Obviously, the second part will be easier with encapsulation, and in fact the first on too because it is easier to track issues or to prove something when you have encapsulation (for example you can check with a few line of debug the value assigned to an attribute during the execution).

Concerning the overhead, you can avoid most of it using inline C function or Ada pragma Inline();, so you still have encapsulation (you cannot access attributes using the . or -> accessor) but using a getter will be inlined and so no (or few) overhead will be added.

I don't know if it is used in the real industry, but I don't see why it should be avoided. In fact, the real problem may be that industrials do not use, as you said, modern version of Ada with OOP or modern C version with inline functions (comes with C99).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top