# Is learning programming by doing projects right way to learn programming

I tried learning by making projects, but found myself in a place where I would mug up things rather than learning anything.

So I am currently doing textbook styled programming learning. I am reading a chapter. Then solving all programming examples, maybe programming assignments, if I am interested, some mcqs as well. And find the output kind of exercises to familiarize myself with python.

Is this right approach? Till now I am actually learning stuffs as my base is very strong. But is this sustainable? If I go on doing this, I will have my own python documentation tbh. Is this right approach? I am sceptical. Please guide. Also why didn't I learn by making projects? After what point of time of learning programming should I stumble into making projects? And what types of projects should I start with. Don't say hangman etc because I can barely code leap year program in python or any other languages.

• Welcome to CSE! What are your goals in programming? "I tried learning by making projects, but found myself in a place where I would mug up things rather than learning anything." -- what makes you think mugging things up isn't educational? Can you provide more details about the projects you've tried and mugged up? Thanks. Nov 27, 2021 at 15:13
• my goal is to get a web developer job. so mugging up is right?? Nov 28, 2021 at 7:43
• Yes, the point of projects is to struggle and learn from the failures as well as the successes, right? (assuming I'm understanding "mugging" correctly). If your goal is to be a web developer, then you'll definitely need to write many project applications (since that's essentially the job). I wouldn't let a few failed attempts affect you. Keep coding and moving forward and you'll eventually build the portfolio you want. Nov 28, 2021 at 14:24

Yes, learning by doing projects is an excellent way to learn programming (and problem solving through programming). Unfortunately the skill to create a good project and the skill to write a program for solution of it are completely different problems. The former skill replies heavily on already having deep knowledge of the latter.

So, your problem is in coming up with problems and you don't have the skill to do that yet and probably won't for a long time if you are still having issues with the syntax and semantics of a programming language.

I don't have a good Python reference for you, but in Java there is a website called The Greenroom that describes lots of projects. Any of those could be adapted (conceptually) to Python, though with difficulty.

There is one other difficulty, however, and that is that when you make up your own projects and then build them, you may wander too much from the ideal when things get hard since there is not real standard to work towards. If you could find someone experienced in creating useful projects who would feed them to you it would help.

In my own case, I once found a book that described a few projects (in Fortran) that formed the early basis of my programming education: Computing Problems for Fortran Solution by Teague. I think it would be hard to get a copy of it, but the problems themselves can be solved in other languages.

Note that I've found that the best projects for beginners are those that come with a fair amount, maybe a lot) of already built code, providing a framework for the student in which to work. Starting with a blank page is very difficult when you are still learning.

• that book is not available currently neither in pdf nor anywhere in nepal(only popular books are available here in nepal that too if you have luck unless they get sold already). Can you guide me a short very short roadmap to learn python and get a web developer job? Nov 27, 2021 at 5:58
• I am currently learning from a textbook and an udemy course of python for absolute beginners plus lots of stackoverflow and articles as you know. I am learning sth and starting to feel confident about my basics, but I am not sure if this is right way. I am solving every programming exercises, mcqs, print the output types of programs. Is this correct way to master the basics? At the moment, my goal is to just master the basics. Nov 27, 2021 at 6:26

Strictly, there is no clear answer. It depends on both you as a student, and what you intend to achieve. If the goal is to learn how to develop software, and you are someone who can learn from practical experience, then yes.

So I am currently doing textbook styled programming learning. I am reading a chapter. Then solving all programming examples

This is perfectly fine too, and can definitely help you get started and find the lay of the land quicker. There are some things that you're only really going to learn the hard way and not from a book; but you'll eventually bump into those regardless of whether you used a book or not.

Generally speaking, development lends itself well to practical learning, because most (if not all) of development is something we created because we wanted to get to a certain goal. That is precisely what practical learning teaches you, and that's why it tends to work very well here.

Personally speaking, if you teach me the theory first, I tend not to really learn from it. I need to work at something, be stumped by it, and then look up the theory behind it. When my mind has an active question, it registers the answer so much better than when you try to explain something that I don't yet know if I need it. But that's for me personally.

my goal is to get a web developer job. so mugging up is right?

Most definitely. I may be biased here because I am much better at backends than frontends; but web development, specifically visual layouting, is something that you very much have to learn by trying over and over to get it to look the way you want it to.
Guidance and mentoring definitely helps you get there, but you will definitely also need to learn how to shuffle things around when they're not looking quite right, and that's something you learn from experience more than explanation.

And what types of projects should I start with. Don't say hangman etc because I can barely code leap year program in python or any other languages.

You're comparing apples and oranges here. Don't confuse difficult programming with having difficult rules.

Leap year calculation is difficult regardless of whether you're programming it or writing an explanation in English. It's just a really contrived rule set. Having a complex rule set is making things more difficult for you to also learn programming at the same time.

It would be much better to program something which you already innately understand. This means that your mental effort can be focused on how to express what you already know (in English) in code, which is what programming is.

The rules of Hangman are easy to explain in English. If that doesn't apply to you, pick something else that you know very well. The best example are games that young children can play, as these games inherently have a simple set of rules that is easy to remember. Tic Tac Toe, Hangman, even just something silly like "guess what number I'm thinking of" (and I'll tell you if it's higher or lower) would be perfectly fine.

As long as you understand the rules of the game (or application), and know precisely what it should do (when explaining it in spoken language), you can break down most things.

The core skill of a programmer is more in the breaking down of a complex problem into smaller and easier ones than it is in writing the code itself.

Of course you first need to learn the code basics to get started, but you can make myriad games and applications using a very limited set of programming basics under your belt. If you know:

• Write output to the console
• Using variables (integers, strings, booleans)
• Simple mathematical operations (+, -, *, /, %)
• Conditionals (if)
• Arrays (or any type of "list" in your language of choice)
• Iterations (while, for, foreach)

You can create pretty much any game for children.

• What a well-written Answer! I love it. Perhaps we could put it right out in front of potential students somehow. A little sanity at the beginning goes a long way. Jan 9 at 13:05

I am constantly having to learn new things in order to teach them, so I am in this situation regularly. If I were to teach myself from scratch, I would do a mix of essentially 4 things:

1. My own projects
3. Tutorials
4. Deeper dives into whatever aspect of the language interested me at that moment

All four of the activities work together in tandem. They expand your horizons in different ways, but also have different caveats:

1. My own projects: these push your ability to figure things out, research, and get things moving. This is where you will experience much of your long-term grown. As an aside, I agree with one of the commenters that a project that doesn't bear fruit is still very valuable. Many of the reasons for why languages are the way they are, and why we do things the way we do, is borne of the collective pain of projects that failed, and most of those practices won't (can't, really) make sense in your own mind until you've lived through some of the problems yourself. (Can't figure out why we care about clear variable names? Wait until you try to make sense of code that you yourself wrote just 7 months ago, and you will suddenly wish that you had left a clearer breadcrumb trail for yourself.)
2. Premade problems: these are, essentially, curated study, and if properly organized, will allow you to explore at least a few topics with assurance that you'll visit all is the most important parts of those topics. (In essence, you will learn at least some things well). (BTW, free or paid courses also fit into this category, and paid courses with instructor feedback are essentially this, but on crazy steroids.)
3. Tutorials can get you moving rapidly outside of your knowledge and comfort zone, which is wonderful. One caveat is that many tutorials on YouTube are, for whatever reason, given by self-learners. Ad a result, there is a lot of very messy code out there under the guise of "tutorials". So absolutely look to them to get you moving into new areas and pull you out of ruts, but treat the programming practices you see as somewhat suspect. You'll find higher-quality information in the textbooks and on stack overflow.
4. Deeper dives into whatever aspect of the language interested me at that moment: these are your "strike while the iron is hot" moments. You learn the most when your are highly motivated, so if something catches your fancy as especially fascinating, jump on it and see what you can grab from the internet's firehose of information. You may not understand everything you find, but even that is useful, since it sets you up knowing more areas to be explore later.

Once you get to the point where you can consistently make small-to-medium sized projects with a fair amount of success, more avenues of growth will open up to you as well. At some point, you will really need to start getting feedback in order to continue your growth, but you can get yourself up and running without it at the start.

I often introduce new constructs "in context" by asking a question akin to, "Wouldn't it be useful if....?" For example, I might introduce dictionaries in this way.

Suppose you are performing an experiment such as tossing a fair coin until a head appears and you are interested in running the experiment 1,000,000 times to see what the distribution looks like. You don't know right off what range of outcomes you might get, so wouldn't it be useful if, instead of using a list, you are able to index a tally on an arbitrary collection of integers.

A dictionary is handy: you can enroll an outcome in the dictionary by executing

tally[outcome] = 1


and you can increase its tally with

tally[outcome] += 1


In this way, you don't have to worry about creating a list in advance large enough to accommodate such a tally. This tally-making pattern is useful in a variety of contexts.