Single Source of truth and applying it software development

Single Source of truth and applying it software development

What is Single Source of Truth?

In simple terms, Single Source of Truth is a guideline, which ensures that a team of people or a piece of software would rely on one single source of correct information, which is where the name stems from. In programming, SSOT ensures that the software we design is reliant on the correct and up-to-date information.

SSOT and reference in software development

Each time you send a message to your friend over Messenger, your conversation gets stored somewhere on Facebook’s server and if you try to access the chat history, your computer sends a request to the server to access that one SSOT which is your conversation so you are both seeing the same conversation. Your browser refers you to the conversation history.

Example of an object relationship

Imagine yourself being a client in bank. You can be one of thousands of a bank’s clients and you can be dealing with one of hundreds of the bank’s workers. You walk to one of the tills where you are greeted by one of the workers and you see a small display of your financial status (for the sake of this explanation let’s ignore the security flaws behind such a model). The screen shows you your bank status and the worker’s name. The clerk can see your bank info and your name. Let’s define that in Ruby:

Classes of Client his BankAccount and the Clerk defined in Ruby

Jessica is assisting Steve with his business account

Calling on the assigned variables displays all the info associated with the Class instances

Additional convenience

If Steve ever decides to change his name, legally he will have to inform the bank. Similarly Jessica finds herself unsatisfied with her name she will need to inform her employer (the bank) once she changes it and the bank account instance would be updated “automatically”:

Before proceeding we set the attr_accessor so our test subjects can change their names. We also adjust the String for Ste- I mean, Justin’s account.

Closing remarks

As convenient as it seems to store all the information in one place, sometimes it doesn’t have to be gathered in the join class. For instance, even after changing names, our friends should be aware of the updated info without making all the way to the bank: