Bomb-proofing your code with robust programming

May 21, 2018

Bugs are a fact of life in software. Sometimes they spring to life because of simple omissions or typos. Those are easy to fix. Sometime bugs arise from mysterious outliers, throwing errors that should never be called. These often come from fragile code.

The solution is what's known as robust programming. Also called defensive programming, robust code anticipates problems, abstracts any values returned to exposed functions, and makes debugging a simple process.

Here's the difference between robust and fragile code.  

Expects Stupid Inputs
Robust code doesn't assume that any caller has read the manual, understands how to produce correct data inputs, or knows how code is supposed to work. That means they may be passing the wrong data types, malformed data, or things that don't make sense. When it catches something like this, it produces understandable error messages and stops this bad data from propagating through the system.

Just because you're working on internal code that will never interact with external users or methods doesn't mean you shouldn't expect the caller to be an misinformed. We forget what we did a week later, neglect internal documentation, and assume function by method names. Everybody can be misinformed sometimes, so make sure every piece of code is ready for that.

Trusts No One
The flip side of this is that robust code does not trust any piece of information that it does not create. Always assume somebody has it out for you and is going to break your code. Always assume that any function that you call could fail or send back unexpected results. If someone throws a bomb at your methods, they should be able to handle it elegantly enough to not blow up the whole shebang.

This is the flip side of the stupid inputs protection. It's not that they don't know what they are doing, it's that they are looking for ways to break your program. A lot of malicious code uses a buffer overflow exploit, where data exceeding the boundaries of a memory buffer are written to nearby memory areas, sometimes executing arbitrary code. But you can prevent it by checking that a data structure is within the bounds that it claims to be. Essentially, you are asking all incoming data for their identification papers to make sure they are what they claim to be.

Hides Your Cards
Public methods and fields and global variables are two great ways to introduce secret bugs into your code. That's because any other method could have access to this data. So those variables could be changed at any time and in a way that doesn't make sense, especially with multi-threading and multiple cores.

Keeping the important stuff private helps you control what happens to any data in your software. Especially if you are relying on that data. If you are creating an API, you will probably need some sort of public get and set routines; that can't be avoided. But by having only one way in and one way out for data, you can control and track data changes and head bugs off.

Expects Things to Change
We all know code within any large project will change. What you may not expect is file structures or standard inputs or output to change. If you assume they stay the same, then you are asking for trouble. What if you or someone like you overrides it or modifies it? Cue explosions.

You should do this for data structures and objects that you create as well. As a secondary benefit, this makes your code easier to maintain and update. For methods where you return data, this means not passing data structures or pointers to objects if you can help. If the structure that you pass has to change, you might have just broken a lot of code.

Making your code robust -- that is, defensive -- ensures your software will have less bugs and less security holes. Trusting things to just work or for static operation will only lead to heartbreak.

By Thomas Burt August 4, 2025
How to stand out, or step in, to a growing field.
By Thomas Burt June 30, 2025
Australia’s tech sector continues to face crucial skill shortages, particularly in areas such as software development, cybersecurity, and cloud infrastructure. For organisations trying to scale quickly, launch new products or undergo digital transformation the talent gap can feel like a bottleneck (or at least a very frustrating aspect of business operations). While none of us can change market realities, it is possible to grow effectively without overextending or overworking your existing staff. With a forward thinking 3-phase approach to scale your tech team, you can create a far more sustainable internal talent pool, even in a talent-tight market. 1. Prioritise Critical Roles Begin by clearly identifying the roles that are essential to progress now — not every hire needs to happen at once. This phase should focus on: High-impact positions (e.g., Lead Developer, Cloud Engineer, Product Owner) Contractors or consultants for immediate delivery Partnering with a specialist recruiter to fast-track access to talent It can also be helpful to use workforce planning tools to map existing capability against business demand, identifying real skill gaps vs. nice-to-haves in real-time. 2. Supplement with Flexible Talent Once the foundation is stable, look at short-term or contingent hires to expand capacity without permanent headcount pressure. Contracting is especially useful for: Agile product teams Time-sensitive projects Specialist skills (e.g., penetration testing, DevOps automation) Contract-to-permanent is also a great way to trial cultural fit and minimise long-term risk. Building a team that mesh well together avoids interpersonal issues impacting retention, a key point for all teams, but especially when addressing crucial and finite talent pools. 3. Building a Sustainable Talent Pipeline With your core needs covered you can shift focus to building a sustainable team through: Junior hires who receive structured pathways to professional growth and skill development Diversity recruitment to reach new talent pools Uplift employer branding and employee benefits to passively attract candidates over time While there is a shortage of many tech skills businesses need now, there is a deluge of talented people willing to learn, with forward thinking and the right support many gaps can be filled. Skills shortages will continue but with the right plan, your team doesn’t have to stall (or burnout trying to fill gaps). If you need help finding the right talent for whatever phase of recruitment you are in, get in contact with one of our highly skilled Account Managers here.
By Thomas Burt June 3, 2025
Taking the Chance to Reset and Carve a Clear Way Forward
By Mimi Petrakis May 1, 2025
Hiring IT Web Developers on Contract is a Smart Move for Your Transformation and Security Projects
A man is sitting at a desk in an office holding an ipad.
By Mimi Petrakis March 31, 2025
In the fast-evolving IT and digital industry, organisations must constantly adapt to new technologies, processes, and strategies to remain competitive. A Change Manager plays a critical role in ensuring these transitions are smooth, effective, and embraced by all stakeholders.
By Mimi Petrakis February 28, 2025
As the IT & digital industry continues to evolve, staying informed on salary trends and employment dynamics is crucial for both professionals and businesses. Last month, Peoplebank’s highly anticipated February 2025 Salary Guide was released, offering comprehensive salary insights, job market analysis , and hiring trends to help you navigate the ever-changing landscape of IT & digital employment in Australia. Key Insights from the Peoplebank Salary Guide 2025 Our latest salary guide delivered state-by-state salary benchmarks for various IT & digital roles, providing clarity for job seekers, hiring managers, and industry leaders. It also includes expert insights from Peoplebank specialists, highlighting the latest employment trends shaping the industry. “Our Salary Guide reflects the major challenges and opportunities within the dynamic IT & digital industry. The guide serves as a critical resource for stakeholders, providing insights into commercial realities as the year begins and empowering both talent managers and IT & digital professionals to make informed strategic decisions aligned with the current market.” Tim Moran, Executive General Manager, Peoplebank and Leaders IT What’s Trending in the IT & Digital Job Market? Job Market Stability : The number of professionals changing jobs has continued to decline since 2024, with a rise in job tenure. This suggests a growing emphasis on job security and long-term career planning in the IT sector. Contractor Rates & Permanent Roles : A softening of contractor rates indicates a shift in preference towards permanent employment, reflecting a changing job market dynamic. Talent Development Focus : Companies are prioritising in-house talent development , tailoring skills to meet their specific organisational needs rather than solely relying on external hires. Most In-Demand Roles : Software Engineers are in high demand as businesses invest in AI, automation, and cloud-based solutions to accelerate digital transformation. Solutions Architects are increasingly sought after to design scalable, efficient, and secure IT infrastructures that support evolving business needs. Download the Full Salary Guide Understanding salary trends, hiring patterns, and emerging job market shifts can give you a competitive edge—whether you’re an IT professional planning your next career move or a business seeking top digital talent. Download the full Peoplebank Salary Guide now to access the latest insights and ensure you're staying ahead in the IT & digital industry.
An older woman working in tech faces the camera in the boardroom men are working on tablets in the background
February 2, 2025
As we wrap up the first month of 2025 what have our experts learned? Peoplebank Account Manager Elizabeth Fairweather shares her thoughts and predicts the trends to come
By Mimi Petrakis December 31, 2024
What's ahead for 2025?
By Mimi Petrakis November 7, 2024
Your resume is the first thing a potential employer will see from you. Make sure you take time planning and thinking about your resume.
Blue tile with white text that shows the new Leaders IT and Peoplebank logos and title 'a new look'
By Mimi Petrakis November 1, 2024
Peoplebank and Leaders IT: A fresh look for a new era in recruitment