PM & AI Chronicles

From Product Thinking to Prompt Engineering โ€“ One Tool at a Time

Organizing Code ๐Ÿ—ƒ๏ธ: Structuring Software One Piece at a Time ๐Ÿ› ๏ธ ๐Ÿ—๏ธ

In the previous article, we looked at how software makes decisions using programming logic โ€” the โ€œthinkingโ€ part of a program. ๐Ÿ‘‰Programming Logic.

When programmers write code, they donโ€™t think of the entire program all at onceโ€”because that would overwhelm anyone. Instead, they break the work into smaller, manageable tasks. This compartmentalization is one of the core principles of software development: divide a big problem into bite-sized pieces so each part is clear, focused, and easier to build.

Just like Windows is made up of countless smaller components working together, every software program becomes easier to create when itโ€™s organized into neat sections. But organizing code isnโ€™t only about what happens inside the program. Developers must also stay organized outside the codeโ€”mapping out how the software should work, planning the structure, and creating a blueprint so that one person (or an entire team) can confidently build each part.

This article explores how developers structure software, why organization matters, and how good planning makes even massive applications feel simple and achievable.

A flowchart is a visual representation of a program that uses boxes and arrows to show how the logic flows. Flowcharts are a vital part of the software development process, and they should be created before any code is writtenโ€”just like architects draw blueprints before building a house.

They help developers see the program before they build it, making it easier to understand the steps, decisions, and inputs required.

Flowcharts make it easy to visualize:

  • The order of operations โ€” what happens first, next, and last
  • Where user input is needed
  • Where decisions branch into different paths
  • How different parts of the program connect

Youโ€™re rightโ€”not every symbol needs to be listed. Here are just the essential ones beginners should know:

  • Oval โ†’ Start / End: Shows where the program begins or finishes
  • Rectangle โ†’ Process: A step where an action or calculation happens
  • Diamond โ†’ Decision: A true/false or yes/no choice
  • Parallelogram โ†’ Input / Output: Data coming in or information going out
  • Arrows โ†’ Flow Lines: Show the direction of the programโ€™s logic

These few symbols are more than enough for most simple programs.

Both a sequence and a flowchart describe logical steps a program should follow, but theyโ€™re used slightly differently:

SequenceFlowchart
Describes steps in plain text or a listDescribes steps visually using shapes and arrows
Often used to outline multiple steps needed to complete a larger actionUsually focuses on a single task or decision flow
Good for writing out logicGood for seeing the logic and branches

Easy way to remember:
๐Ÿ‘‰ Sequences are written like instructions.
๐Ÿ‘‰ Flowcharts are drawn like maps.

There are many options available, including:

  • Specialized apps like Lucidchart, Draw.io, or Visio
  • Simple tools like Microsoft Word, PowerPoint, or Google Docs
  • Even pen and paper works perfectly for beginners

Description: The program asks the user for a number, checks if it is greater than zero, and then shows whether itโ€™s positive or negative.

      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚   Start    โ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
            โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚  Input a number  โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Is the number > 0 ?      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ Yes        โ”‚ No
       โ–ผ            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Positive   โ”‚   โ”‚  Negative/Zero โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                 โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚    End     โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

True to its name, pseudocode is โ€œfake code.โ€ It looks a bit like real programming instructions, but it doesnโ€™t run, isnโ€™t read by the processor, and has no effect on how a program functions. Instead, its purpose is to help humans understand what the program is supposed to do.

Think of pseudocode as a rough draft that describes the logic of your program in plain, structured English.

  • Helps developers think through the logic before writing actual code
  • Makes it easier for others to understand your approach
  • Serves as a guide for teams working together on the same project
  • Prevents confusion when someone new needs to fix or extend the code

When multiple programmers collaborate, pseudocode becomes especially valuable. If a developer didnโ€™t write the original code, figuring out whatโ€™s wrong during debugging can be difficult. Clear pseudocode acts like โ€œstep-by-step instructionsโ€ for anyone who joins later.

  • Comments can be used as pseudocode by writing short, plain-English notes inside or around the code to explain why something is being done rather than how itโ€™s coded.
    • Example: // Check if user is old enough before allowing access
  • Another form of pseudocode is step-by-step natural language instructions, written like simple bullet points that outline the programโ€™s logic without using any coding symbols.
    • Example: โ€œAsk the user for their age โ†’ If age is 18 or above, allow entry โ†’ Otherwise, deny access.โ€

In real life, containers hold things. In programming, containers do the sameโ€”they hold pieces of data.

A variable can store only one value at a time, and that value can change during the programโ€”based on different inputs, calculations, or conditions the program encounters. But when developers need to work with multiple values of a similar kind, they use containers to group them and access them efficiently.

Two beginner-friendly container types are arrays and vectors.

An array is simply a list of values arranged in a sequence. The Key points are:

  • All elements must be the same data type
  • The size is fixed โ€” you must decide how many items it will hold ahead of time

Real-life analogy: Like an egg carton โ€” it holds the same type of item (all eggs) and always has a fixed number of slots.

A vector also holds a list of values, but with more flexibility. The Key points are:

  • The values donโ€™t necessarily have to be the same type
  • The size is dynamic โ€” it can grow or shrink as the program runs

Because of this flexibility, vectors are often the preferred container type

Real-life analogy: Like a stretchable shopping bag โ€” you can keep adding or removing items, and the bag adjusts to fit.

Developers often need to perform the same task multiple times in a program. Instead of writing the same instructions again and again, they create a function โ€” a reusable block of code that does one specific job. A function usually:

  • takes input
  • does some processing
  • gives output

Functions are linear, meaning they start at the top, run their instructions in order, and finish at the end before the program moves on

Think of a function like a coffee machine:

  • You give it an input โ†’ water + coffee powder
  • It performs a process โ†’ heats water, brews coffee
  • You receive an output โ†’ a cup of coffee

The machine always does the job the same way, no matter how many times you use it. Thatโ€™s precisely how functions behave in programming.

Imagine you are building a small program that needs to greet different users. Instead of writing “Welcome!” again and again, you make one function:

  • Create a function called โ€œGreet Userโ€
    • It takes the userโ€™s name
    • It prints a friendly greeting
  • Whenever you need to greet someone
    • Call the โ€œGreet Userโ€ function and pass the name
  • Input: โ€œXYZโ€
  • Function does its job: make a greeting using the name
  • Output: โ€œWelcome, XYZ!โ€
# Function definition (reusable block of code)
def greet_user(name):
    print("Welcome,", name)

# Main program
def main():
    greet_user("John")     # function used here
    greet_user("Mira")    # reused again
    greet_user("Nick")     # reused again

# Calling the main program
main()

Modern computers no longer rely on a single command prompt where you type one instruction at a time. Instead, you interact with dozens of things on the screen โ€” icons, buttons, menus, widgets, folders, taskbar items, and more. Each of these is an object.

On your desktop:

  • Clicking the Recycle Bin opens it
  • Clicking the Start Menu launches options
  • Right-clicking the desktop gives you a menu
  • You can open multiple apps at once

You can start interacting with any of these at any time โ€” there is no single entry or exit point. This is exactly how objects work in programming:

  • ๐Ÿ‘‰ Each object exists independently
  • ๐Ÿ‘‰ Each object has things it โ€œknowsโ€ (properties)
  • ๐Ÿ‘‰ Each object has things it โ€œcan doโ€ (methods)
  • ๐Ÿ‘‰ You can interact with any object at any time

An object is a collection of:

  • Properties / Attributes โ†’ what it is
  • Methods โ†’ what it can do

You can think of an object as a mini โ€œthingโ€ inside a program โ€” like a small machine that knows how to handle itself.

These two words confuse everyone, even experienced programmers โ€” so keep it simple.

These describe the characteristics of an object. Examples:

  • A carโ€™s color
  • A personโ€™s height
  • A buttonโ€™s text label
  • A windowโ€™s width

Properties can be changed in code. Example:

  • Changing a window width from 800px to 1000px
  • Changing a carโ€™s color from โ€œredโ€ to โ€œblueโ€

These give extra information, usually read-only. In many languages, attributes:

  • Are always strings
  • Cannot be edited at runtime
  • Return a default value if changed incorrectly

Real-life example:
A passport has your name and nationality โ€” these are attributes. You canโ€™t change them by writing on the passport; the official system controls them.

Methods are simply functions that belong to an object. Examples:

  • A remote has a method called increaseVolume()
  • A car object may have startEngine()
  • A file object may have open() or delete()

To better understand objects, we can look at the four main principles of OOP (Object-Oriented Programming), each illustrated with easy, real-life examples.

Encapsulation means bundling an objectโ€™s data (its properties) and the functions that act on that data (its methods) together, while controlling who can access or modify that data.

Itโ€™s like putting essential things inside a protective box where only specific actions are allowed. The outside world can interact with the object only through the โ€œapproved doorsโ€ (methods), not by directly touching its internal parts.

Real-life analogy:

  • Think of a car:
  • You can steer, accelerate, or brake using simple controls.
  • But you cannot directly manipulate the engine or fuel injection systemโ€”the car protects that complexity so you donโ€™t break anything.
  • The car exposes only the controls youโ€™re meant to use.

Encapsulation keeps objects reliable, safe from misuse, and easier to maintain.

In code:

  • An object hides its internal data so it canโ€™t be changed incorrectly
  • You interact with that data only through the controlled methods the object provides

Inheritance means one object can borrow or extend the traits of another object.

Real-life analogy:

  • Start with a general Phone object that can make calls.
  • Create a Smartphone object that inherits all the functionality of a Phone.
  • Because of inheritance, the Smartphone already knows how to make calls without you having to teach it again.
  • You can then add extra abilities to the Smartphone, like taking photos or browsing the internet

In code:

  • A child object automatically receives the parent object’s properties and methods
  • You can extend the child object by adding new abilities without rewriting the parentโ€™s logic

Polymorphism means different objects can respond to the same instruction in their own unique way.

Real-life analogy: Think of the action โ€œMakeSound.โ€

  • A dog makes a bark
  • A cat makes a meow
  • A cow makes a moo

The instruction is the same, but each animal performs it differently. Polymorphism allows programs to use one common command and let each object decide its own behavior.

In code:

  • Different objects share a common method name
  • Each object provides its own version of how that method works
  • The program can treat all objects the same way and still get different results depending on the object calling it

Abstraction means hiding the complicated inner workings of something and showing only the parts the user actually needs.

Real-life analogy: Think about using a microwave. You press simple buttons like โ€œStartโ€ or โ€œ30 seconds,โ€ but you never see:

  • the electrical circuits,
  • the heating coils,
  • the power transformation,
  • or the timing mechanisms inside.

All the complexity is hidden so you can focus only on the simple controlsโ€”this is abstraction. Abstraction makes programs easier to use and helps developers avoid unnecessary details.

In code:

  • Complex logic is hidden behind simple, easy-to-use methods
  • The user interacts only with essential functions, not internal processes
  • Objects expose what you can do, not how itโ€™s done

Object: Car

  • Properties: color, speed, model
  • Attributes: VIN number (cannot change)
  • Methods: start(), stop(), accelerate()

OOP Concepts:

  • Encapsulation: You press โ€œaccelerate,โ€ you donโ€™t modify the engine manually
  • Inheritance: ElectricCar inherits features from Car
  • Polymorphism: accelerate() behaves differently for a sports car vs a truck
  • Abstraction: You only see the dashboard, not the wiring

Understanding flowcharts, pseudocode, containers, functions, and objects gives you a strong foundation for how real software is planned and built. These tools help developers break big problems into smaller parts, reuse work instead of repeating it, and create programs that are easier to understand, maintain, and improve.

Modern software might seem huge and complicated, but underneath it all, itโ€™s built from simple, well-organized pieces working together. As you continue learning, these concepts will make programming feel more manageable and far less overwhelming.

This article is part of the Software Development Series โ€” where we break down how software works, how programmers communicate with computers, and what happens behind the scenes when code runs. ๐Ÿ‘‰ โ€” Software Development: Modern Software Basics.