Podbean logo
  • Discover
  • Podcast Features
    • Podcast Hosting

      Start your podcast with all the features you need.

    • Podbean AI Podbean AI

      AI-Enhanced Audio Quality and Content Generation.

    • Blog to Podcast

      Repurpose your blog into an engaging podcast.

    • Video to Podcast

      Convert YouTube playlists to podcasts, videos to audios.

  • Monetization
    • Ads Marketplace

      Join Ads Marketplace to earn through podcast sponsorships.

    • PodAds

      Manage your ads with dynamic ad insertion capability.

    • Apple Podcasts Subscriptions Integration

      Monetize with Apple Podcasts Subscriptions via Podbean.

    • Live Streaming

      Earn rewards and recurring income from Fan Club membership.

  • Podbean App
    • Podcast Studio

      Easy-to-use audio recorder app.

    • Podcast App

      The best podcast player & podcast app.

  • Help and Support
    • Help Center

      Get the answers and support you need.

    • Podbean Academy

      Resources and guides to launch, grow, and monetize podcast.

    • Podbean Blog

      Stay updated with the latest podcasting tips and trends.

    • What’s New

      Check out our newest and recently released features!

    • Podcasting Smarter

      Podcast interviews, best practices, and helpful tips.

  • Popular Topics
    • How to Start a Podcast

      The step-by-step guide to start your own podcast.

    • How to Start a Live Podcast

      Create the best live podcast and engage your audience.

    • How to Monetize a Podcast

      Tips on making the decision to monetize your podcast.

    • How to Promote Your Podcast

      The best ways to get more eyes and ears on your podcast.

    • Podcast Advertising 101

      Everything you need to know about podcast advertising.

    • Mobile Podcast Recording Guide

      The ultimate guide to recording a podcast on your phone.

    • How to Use Group Recording

      Steps to set up and use group recording in the Podbean app.

  • All Arts Business Comedy Education
  • Fiction Government Health & Fitness History Kids & Family
  • Leisure Music News Religion & Spirituality Science
  • Society & Culture Sports Technology True Crime TV & Film
  • Live
  • How to Start a Podcast
  • How to Start a Live Podcast
  • How to Monetize a podcast
  • How to Promote Your Podcast
  • How to Use Group Recording
  • Log in
  • Start your podcast for free
  • Podcasting
    • Podcast Features
      • Podcast Hosting

        Start your podcast with all the features you need.

      • Podbean AI Podbean AI

        AI-Enhanced Audio Quality and Content Generation.

      • Blog to Podcast

        Repurpose your blog into an engaging podcast.

      • Video to Podcast

        Convert YouTube playlists to podcasts, videos to audios.

    • Monetization
      • Ads Marketplace

        Join Ads Marketplace to earn through podcast sponsorships.

      • PodAds

        Manage your ads with dynamic ad insertion capability.

      • Apple Podcasts Subscriptions Integration

        Monetize with Apple Podcasts Subscriptions via Podbean.

      • Live Streaming

        Earn rewards and recurring income from Fan Club membership.

    • Podbean App
      • Podcast Studio

        Easy-to-use audio recorder app.

      • Podcast App

        The best podcast player & podcast app.

  • Advertisers
  • Enterprise
  • Pricing
  • Resources
    • Help and Support
      • Help Center

        Get the answers and support you need.

      • Podbean Academy

        Resources and guides to launch, grow, and monetize podcast.

      • Podbean Blog

        Stay updated with the latest podcasting tips and trends.

      • What’s New

        Check out our newest and recently released features!

      • Podcasting Smarter

        Podcast interviews, best practices, and helpful tips.

    • Popular Topics
      • How to Start a Podcast

        The step-by-step guide to start your own podcast.

      • How to Start a Live Podcast

        Create the best live podcast and engage your audience.

      • How to Monetize a Podcast

        Tips on making the decision to monetize your podcast.

      • How to Promote Your Podcast

        The best ways to get more eyes and ears on your podcast.

      • Podcast Advertising 101

        Everything you need to know about podcast advertising.

      • Mobile Podcast Recording Guide

        The ultimate guide to recording a podcast on your phone.

      • How to Use Group Recording

        Steps to set up and use group recording in the Podbean app.

  • Discover
  • Log in
    Sign up free
Coding Blocks

Coding Blocks

Technology

Code Confidence using NASA’s Ten Simple Rules

Code Confidence using NASA’s Ten Simple Rules

2023-10-02
Download Right click and do "save link as"

We’ve mentioned in the past that the code we write isn’t maintaining heartbeats or being used in life-critical settings, but what if your code is? NASA happens to be a company who has code that is life and mission critical and it’s very possible it won’t even be accessible once it leaves earth. In this episode, we explore what has been deemed “The Power of 10” for writing safety-critical code.

If you’re listening on a podcast player and would like to see all the show notes, head to:
https://www.codingblocks.net/episode219

NASA’s Power of Ten

Their rules to ease the use of static analysis

Rule #1 Simple Control Flow
  • You’re not allowed to use:
    • goto
    • setjmp
    • longjmp
    • recursion
Rule #2 Limit all loops to a fixed upper bound
  • For example, linked list traversals include checking against some maximum iteration boundary, and the boundary is always an integer.
  • “If a tool cannot prove the loop bound statically, the rule is considered violated.”
Rule #3 Do not use the heap
  • So no need for malloc and free.
  • Rely soly on the use of stack memory instead.
  • This is because quite a few memory bugs are due to the use of the heap and garbage collectors. Things like:
    • memory leaks
    • use-after-free
    • heap overflows
    • heap exhaustion
  • Applications that make use of the heap cannot be proven by a static analyzer.
  • By only using stack memory, including upper boundaries where necessary, you can commute exactly the most amount of memory your application will need.
  • And bonus, by only using the stack, you the eliminate the possibility of the previously mentioned memory bugs.
Rule #4 Function sizes are limited
  • Functions should only do one thing but might require multiple steps.
    • Very consistent with Uncle Bob’s series and other best practice principles.
  • NASA recommends that functions be limited to 60 lines or what can fit on a single printed page.
  • This makes it easier for someone reviewing your code to read and understand that function in it’s entirety.
  • This limitation also helps to make sure that your function is testable, i.e. it’s not just some meandering 2,000 line long function with 18 levels of nesting.
Rule #5 Hide your data
  • "Data hiding is a technique of hiding internal object details. Data hiding restricts the data access to class members. It maintains data integrity."
  • The idea here is to declare variables as close as possible to where they are used at the lowest possible scope.
    • Meaning, rather than declare some variable that you only need inside of a loop at the function level, instead, declare that same variable inside the loop.
  • Doing this accomplishes two things:
    • First, it reduces the amount of code that can access those variables, and more importantly, you …
    • Second, reduce the number of touch points that might change a variable’s value which aides debugging efforts when you want to understand why it got some unexpected value.
Rule #6 Check the $#*!#**#@ return values
  • How many times have you been bitten by code that made some call, even shell scripts/commands, where the call failed, but the return value that would have saved you wasn’t checked?
  • Check the return values of everything that returns something.
    • Always check them
    • All of them
  • If you explicitly want to ignore a return value, such as when printing to the screen, you are to explicitly cast the return to void so that a reviewer knows that you do not care about that particular return value.
  • Failure to check a return value or cast it to void will be brought up in a code review.
Rule #7 Use of the Preprocessor is very limited
  • NASA limits the use of the C preprocessor to only file inclusions and very simple macros.
  • “The C preprocessor is a powerful obfuscation tool that can destroy code clarity and befuddle many text-based checkers.”
  • Specifically, conditionals that can change the code at compile time are called out by the Power of 10
  • For example, if you have 10 different flags that can be changed at compile time, you have 2^10 build targets that need to be tested.
    • In other words, preprocessor conditionals can exponentially increase your testing requirements.
Rule #8 Pointer use is restricted
  • “No more than one level of dereferencing should be used. Dereference operations may not be hidden in macro definitions or inside typedef declarations.”
    • https://www.tutorialspoint.com/what-does-dereferencing-a-pointer-mean-in-c-cplusplus
  • This is because pointers, albeit powerful, are easy to misuse.
  • Doing this limits you to structures that more properly track your pointers.
  • Pointer restrictions also include not using function pointers.
    • This is because function pointers obfuscate the control flow of your application.
    • They also make it more difficult to statically analysis your code.
Rule #9 Compile in Pedantic mode
  • Meaning, compile with all warnings enabled.
  • This will allow the compiler to alert you to every issue it sees.
  • Treat your warnings as errors and address them before release.
Rule #10 Analyze and test
  • Use multiple static code analyzers to evaluate your code
    • They don’t all work the same and sometimes use different rules.
  • Test, test, and test again. Preferably with some form of automated testing, i.e. unit tests vs integration tests, etc.
Resources We Like
  • https://youtu.be/GWYhtksrmhE
  • https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code
Tips of the Week
  • A couple years ago I mentioned an Instrumental album from a band called Night Verses that I was really excited about. It was great working music that kept things moving, and now they’ve gone and released a new album. The bass player from Tool (Justin Chancellor) guest stars on one of the tracks too.
    • https://open.spotify.com/album/6JVvP0fi6y3Jz2mE0fUYPq
  • View Pull Requests INSIDE IntelliJ
    • https://www.jetbrains.com/help/idea/work-with-github-pull-requests.html
  • Or inside Visual Studio Code
    • https://code.visualstudio.com/blogs/2018/09/10/introducing-github-pullrequests
  • Do AI locally using Llama 2 from Meta
    • https://ai.meta.com/llama/
  • Get started with ML and AI without having to find all the tools yourself using Anaconda
    • https://www.anaconda.com/download
    • They have installers for Linux, Mac and Windows
    • They also have a version that runs completely in the cloud so you could use a Chromebook if you wanted
      • https://www.anaconda.com/code-in-the-cloud/
    • You also get access to data science courses
  • Maven build cache extension to improve local build times
    • https://maven.apache.org/extensions/maven-build-cache-extension/
view more

More Episodes

When to Log Out
2024-10-07
Things to Know when Considering Multi-Tenant or Multi-Threaded Applications
2024-09-02
Two Water Coolers Walk Into a Bar…
2024-08-18
How did We Even Arrive Here?
2024-08-04
AI, Blank Pages, and Client Libraries…oh my!
2024-07-07
Alternatives to Administering and Running Apache Kafka
2024-06-23
Nuts and Bolts of Apache Kafka
2024-06-09
Intro to Apache Kafka
2024-05-26
StackOverflow AI Disagreements, Kotlin Coroutines and More
2024-05-13
Llama 3 is Here, Spending Time on Environmental Setup and More
2024-04-28
Ktor, Logging Ideas, and Plugin Safety
2024-04-14
Importance of Data Structures, Bad Documentation and Comments and More
2024-04-01
Decorating your Home Office
2024-03-18
Multi-Value, Spatial, and Event Store Databases
2024-03-04
Overview of Object Oriented, Wide Column, and Vector Databases
2024-02-19
Picking the Right Database Type – Tougher than You Think
2024-02-05
There is still cool stuff on the internet
2024-01-21
Reflecting on 2023 and Looking Forward to 2024
2024-01-08
Gartner Top Strategic Technology Trends 2024
2023-12-18
2023 Holiday Season Developer Shopping List
2023-11-25
  • ←
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • →
012345678910111213141516171819

Get this podcast on your
phone, FREE

Download Podbean app on App Store Download Podbean app on Google Play

Create your
podcast in
minutes

  • Full-featured podcast site
  • Unlimited storage and bandwidth
  • Comprehensive podcast stats
  • Distribute to Apple Podcasts, Spotify, and more
  • Make money with your podcast
Get started

It is Free

  • Podcast Services

    • Podcast Features
    • Pricing
    • Enterprise Solution
    • Private Podcast
    • The Podcast App
    • Live Stream
    • Audio Recorder
    • Remote Recording
    • Podbean AI
  •  
    • Create a Podcast
    • Video Podcast
    • Start Podcasting
    • Start Radio Talk Show
    • Create a Podcast for Spotify
    • Education Podcast
    • Church Podcast
    • Get Sermons Online
    • Free Audiobooks
  • MONETIZATION & MORE

    • Podcast Advertising
    • Dynamic Ads Insertion
    • Apple Podcasts Subscriptions
    • AI Podcast Creator
    • Blog to Podcast
    • YouTube to Podcast
    • Submit Your Podcast
    • Switch to Podbean
    • Podbean Plugins
  • KNOWLEDGE BASE

    • How to Start a Podcast
    • How to Start a Live Podcast
    • How to Monetize a Podcast
    • How to Promote Your Podcast
    • Mobile Podcast Recording Guide
    • How to Use Group Recording
    • Podcast Advertising 101
  • Support

    • Support Center
    • What’s New
    • Free Webinars
    • Podcast Events
    • Podbean Academy
    • Podbean Amplified Podcast
    • Badges
    • Resources
    • Developers
  • Podbean

    • About Us
    • Podbean Blog
    • Careers
    • Press and Media
    • Green Initiative
    • Affiliate Program
    • Contact Us
  • Privacy Policy
  • Cookie Policy
  • Terms of Use
  • Consent Preferences
  • Copyright © 2015-2026 Podbean.com