Input, logic, output
A program is a list of instructions a computer carries out exactly as written. The instructions are the source code, and writing them is programming. Every program has three parts. The input is what goes in. The logic is the set of rules applied. The output is what comes out.
Say you roast coffee in Ipoh and sell beans through your own online shop at RM40 a bag. Delivery is RM8. Orders of RM200 or more get 10% off and free delivery. The input is the number of bags. The output is the amount the customer pays. Everything between the two is logic.
Conditional logic
A computer decides by conditional logic. A condition is a question with a true or false answer, and the answer chooses the path: IF the condition is true, do one thing, ELSE do the other. A value that can only be true or false is a Boolean. Conditions are joined with the logical operators AND, OR and NOT.
A variable is a named box holding a value, such as bags or subtotal. Programmers sketch logic in pseudocode, plain words laid out like a program. Your rule in pseudocode:
subtotal = bags × 40
IF subtotal >= 200 THEN
discount = subtotal × 10%
delivery = 0
ELSE
discount = 0
delivery = 8
END IF
total = subtotal - discount + delivery
The symbol >= means "greater than or equal to". A computer applies the condition literally. At 5 bags the subtotal is exactly RM200, so the condition is true. Had the line said > the same customer would pay full price plus delivery. Most faults in software, which programmers call bugs, sit at a boundary like this one, where the rule in your head and the rule as written part ways.
Functions
A function is a block of logic with a name, written once and used wherever it is needed. Name the block above order_total. The value you hand a function is its argument, the value it hands back is its return value, and using it is calling it.
| Call | Subtotal | Discount | Delivery | Returns |
|---|---|---|---|---|
order_total(3) | 120 | 0 | 8 | 128 |
order_total(5) | 200 | 20 | 0 | 180 |
order_total(6) | 240 | 24 | 0 | 216 |
The checkout page, the invoice and the monthly sales report all call the same function, so a change to the rule is made in one place and all three agree. So a software is actually functions activating functions. A set of functions someone else wrote and published for reuse is a library, and most software is assembled from libraries far more than it is written fresh.
Where the software runs
Your shop is two programs. The client is the part running on the customer's phone, in a browser or an app. It shows the page and collects the input. The server is a computer that is always on and always connected, and it does the work the customer never sees: it runs order_total, records the order and takes the payment. Programmers call the two halves the front end and the back end.
Hosting is the renting of a server. The kinds differ in what you rent and in who looks after it.
| Kind of hosting | What you rent | Who looks after it |
|---|---|---|
| On-premises | Nothing. The server is a computer you own, in your shop | You |
| Shared hosting | A slice of a server that holds many other websites | The hosting company |
| Virtual private server (VPS) | A walled-off part of a server reserved for you | The hosting company keeps the machine. You keep the software on it |
| Cloud hosting | Computing power billed by use, which grows and shrinks with your traffic | The cloud provider keeps the machines. You or your developer keep the software |
| Software as a service (SaaS) | The finished software, by subscription | The vendor, for everything |
An online shop builder, an accounting app and a webmail account are all SaaS. Whichever kind you use, the servers stand in a building called a data centre, in a country you can ask the name of. "The cloud" is other companies' servers.
Databases
The server keeps what it must remember in a database, an organised store that software can search and change. The layout of a database is its schema, one entry is a record, and a request for data is a query.
| Type of database | How the data is held | Suited to |
|---|---|---|
| Relational | Tables of rows and columns, linked to each other by ID numbers called keys. Queried in a language called SQL | Orders, invoices, stock: records that must add up |
| Document | Each record is a self-contained document, and two documents may carry different fields | Product listings where each product has its own attributes |
| Key-value | One value fetched by one key | Things needed at speed for a short time, such as a shopping basket |
| Graph | Records and the connections between them | Who knows whom, what is bought with what |
Your orders fit a relational database. Mei Ling's name, phone number and address are held once, in the customers table.
| Customer ID | Name | Phone | Postcode |
|---|---|---|---|
| 17 | Mei Ling | 012-555 0142 | 31400 |
| Order | Customer ID | Bags | Total (RM) |
|---|---|---|---|
| 1042 | 17 | 5 | 180 |
| 1077 | 17 | 3 | 128 |
Each order carries only her customer ID. When she moves house, one row changes and every order of hers follows. A spreadsheet that repeats her address on every order line has to be corrected line by line, and one line is always missed.
How software talks to software
Programs talk to each other through an API, an application programming interface: a published list of the requests a program will accept from another program and the answers it gives. One exchange is a request and a response. The address a request is sent to is an endpoint, and the password that proves which program is asking is an API key.
When Mei Ling's order 1042 is paid, your shop's server books a courier without you touching anything. The message is short and exact:
Request to the courier's API:
{ "name": "Mei Ling", "phone": "012-555 0142", "postcode": "31400", "parcels": 1 }
Response:
{ "tracking_number": "MY48201937", "status": "booked" }
The format, with its labels and curly brackets, is called JSON. A webhook is the same conversation started from the other side: when the parcel is delivered, the courier's server calls yours, and your shop marks the order complete. Connecting two programs this way is an integration. To ask whether two tools can be connected is to ask whether each has an API, and whether the API carries the data you want.
Look again at the request. It carried Mei Ling's name, phone number and postcode onto another company's server.
Data controller and data processor
Follow that one order and count the copies. Mei Ling's details are in your shop builder's database. The shop builder rents its servers from a cloud provider. The courier holds them, and so does the tool that emails her receipt.
Malaysia's Personal Data Protection Act 2010 gives each party a role. The person the data is about is the data subject. A data controller is the person or organisation that processes personal data, has control over the processing, or authorises it. A data processor processes personal data on behalf of a data controller.
| Party | What it does with Mei Ling's details | Role |
|---|---|---|
| Mei Ling | They are hers | Data subject |
| You | Decided to collect them, and what for | Data controller |
| Your shop builder | Stores them because you subscribed | Data processor |
| The cloud provider under the shop builder | Stores them because the shop builder rented its servers | A processor's processor, often called a sub-processor |
You are the controller although you have never seen the server. The decision to collect was yours, so the duties to Mei Ling are yours, and a vendor's failure is something you answer to her for. A processor's own duty under the Act is to keep the data secure. Both sets of duties are covered under Contract, intellectual property and data protection.
Once you know how the software is put together, you can ask a vendor four questions and understand the answers. Where is the server? What type of database holds my records, and can I take a copy out? Which other software does yours send my customers' details to, through which API? Are you my processor, and who are yours? A business rule in your head becomes a condition you can write down exactly, and a list of customers becomes a thing with a location, a keeper and a name in law.
Here in 27Gems, we are the data controller and the data processor of your data. This is not where we like to be, we want you to be the data controller, and we become your data processor. However, that can only happen when you keep your own data, in a database that you control. We look forward to you the day when you can own and control your own data, and we will pass all your data back to you.
Sources
- A data controller is an individual or organisation that processes personal data, has control over the processing, or authorises it; the party that processes on a controller's behalf is the data processor; individuals whose data is processed are data subjects: Personal Data Protection Commissioner's office, FAQ. https://www.pdp.gov.my/en/faq/
- A data processor that processes on behalf of a data controller shall comply with the Security Principle: Personal Data Protection (Amendment) Act 2024 (Act A1727). https://www.pdp.gov.my/ppdpv1/wp-content/uploads/2024/11/Act-A1727.pdf