Why Libraries Exist – From Repetition to Reuse
Heya! 👋 I love helping people, and one of the best ways I do this is by sharing my knowledge and experiences. My journey reflects the power of growth and transformation, and I’m here to document and share it with you.
I started as a pharmacist, practicing at a tertiary hospital in the Northern Region of Ghana. There, I saw firsthand the challenges in healthcare delivery and became fascinated by how technology could offer solutions. This sparked my interest in digital health, a field I believe holds the key to revolutionizing healthcare.
Determined to contribute, I taught myself programming, mastering tools like HTML, CSS, JavaScript, React, PHP, and more. But I craved deeper knowledge and practical experience. That’s when I joined the ALX Software Engineering program, which became a turning point. Spending over 70 hours a week learning, coding, and collaborating, I transitioned fully into tech.
Today, I am a Software Engineer and Digital Health Solutions Architect, building and contributing to innovative digital health solutions. I combine my healthcare expertise with technical skills to create impactful tools that solve real-world problems in health delivery.
Imposter syndrome has been part of my journey, but I’ve learned to embrace it as a sign of growth. Livestreaming my learning process, receiving feedback, and building in public have been crucial in overcoming self-doubt. Each experience has strengthened my belief in showing up, staying consistent, and growing through challenges.
Through this platform, I document my lessons, challenges, and successes to inspire and guide others—whether you’re transitioning careers, exploring digital health, or diving into software development.
I believe in accountability and the value of shared growth. Your feedback keeps me grounded and motivated to continue this journey. Let’s connect, learn, and grow together! 🚀
So far in your C journey, you’ve been writing functions like:
printing characters
working with strings
performing calculations
Each time you need a function, you write it inside your program.
That works… until it doesn’t.
As your programs grow, a problem starts to appear.
1. The Problem: Rewriting Code Again and Again
Imagine you have written a useful function.
Maybe something like:
printing a string
checking if a character is uppercase
calculating the length of a string
Now you start a new program.
What do you do?
You copy and paste the same function again.
Then again.
Then again.
This creates problems:
❌ Code duplication
❌ Hard to maintain
❌ Easy to introduce bugs
❌ Wastes time
If you fix a bug in one copy, you must fix it everywhere else.
That’s not efficient.
2. The Idea: Reuse Instead of Rewrite
Instead of rewriting the same functions, we want to:
Write once, and reuse everywhere.
This is where libraries come in.
3. What is a Library?
A library is:
A collection of pre-written functions that you can reuse in your programs.
Instead of writing everything from scratch, you simply use functions from the library.
Think of it like this:
You don’t build a calculator every time you need to add numbers.
You just use one.
A library works the same way for code.
4. A Simple Analogy
Imagine you are cooking.
Instead of making everything from raw ingredients every time, you have:
pre-made spice mixes
pre-cut ingredients
ready-made sauces
These save you time and effort.
In programming, a library is like your prepared ingredients.
You focus on building your program, not rewriting basic functions.
5. Libraries in C
C already comes with built-in libraries.
For example:
#include <stdio.h> # prototype of the various functions
This gives you access to functions like:
printf()
You didn’t write printf() yourself.
It already exists in a library.
You simply use it.
6. Creating Your Own Libraries
Now here’s the key idea for this week:
You can create your own libraries.
Instead of copying functions between programs, you can:
group them together
store them in one place
reuse them whenever needed
This is what professional programmers do.
7. Types of Libraries (High-Level)
There are two main types of libraries in C:
1. Static Libraries
Included in your program during compilation
Become part of the final executable
2. Dynamic Libraries
Loaded when the program runs
Shared across multiple programs
This week, we focus on:
Static libraries
8. Why Static Libraries Matter
Static libraries help you:
Avoid repeating code
Keep programs organized
Build reusable tools
Improve efficiency
Create cleaner projects
They allow you to move from:
writing code
to:
building systems
9. What You Will Learn This Week
By the end of this module, you will be able to:
Create your own static library
Organize your code into reusable components
Understand how compiled code is packaged
Use tools that manage libraries
Link your library to another program
You will also complete a project where you:
bundle multiple functions into a single library
follow professional file structure
test your work properly
10. A Shift in Thinking
Up to now, your mindset has been:
“How do I write this function?”
Now it becomes:
“How do I organize and reuse my functions effectively?”
This is a big step.
You are moving from writing small programs to thinking like a software engineer.
11. Practice Thinking (Before Coding)
Before we move into building libraries, think about this:
If you have 10 useful functions, how would you avoid copying them into every program?
How would you organize your code so that other programs can use it easily?
What happens if you update one function, how do you ensure all programs use the updated version?
You don’t need to answer with code yet.
The goal is to start thinking about code reuse and organization.
Key Ideas to Remember
Writing the same code repeatedly is inefficient
Libraries allow you to reuse code
C provides libraries, and you can create your own
Static libraries bundle functions into one reusable unit
What’s Next
In the next lesson, we will answer an important question:
What exactly is a static library, and how does it work internally?
You’ll start seeing how your .c files turn into reusable building blocks.
And that’s where things get interesting.