Project-based learning to code: how?

Fixing and making things, what tools to get and what skills to learn, ...
Post Reply
ertyu
Posts: 2934
Joined: Sun Nov 13, 2016 2:31 am

Project-based learning to code: how?

Post by ertyu »

Bear with me.

I can't code despite trying to teach myself on multiple occasions. I pick up Cs-50, intro to Java, intro to Python, etc. I have done this at least 5-6 times in my life so far. When thinking back over how I failed, it seems like I always die a bit after loops/at the start of arrays, and I die there because that's where my capacity for "how many mechanical exercises I can stick with without getting the point" ends. In other words, the traditional approach to teaching people how to program appears to be to teach them how to solve modular single instances of problems they don't care about and they don't know why they should care about, and trust that after the student has learned to deal with enough of these, they will be able to take a Project, divide its execution into those simple blocks, execute each block, and baaaaaam, working app/program.

There are things I'd like to be able to do with coding which I assume are pretty basic to an experienced coder. For example, I'd like to be able to write myself a script that downloads all the pdfs on a page, names them something, and stores them in a folder. Or I'd like to write a thing that goes through someone's pracice novel that they wrote, goes down the list of contents hyperlinks, extract the text, concatenates it, and makes it a pdf. Or I'd like to write myself a fortunetelling app - or a problem-solving app if you will, whether any fortunetelling methods tell any fortune is debatable but I find it useful to be able to draw a random image, statement, question, or whathaver at random from a collection I import and use that as a prompt to bump my thinking out of whatever rut it's in -- a simple example being, let's say i ask, "what have i neglected to consider about this issue that i should" and what shows up is some symbol one associates with, say, luck, like a picture of a 4-leaf clover i took. then i can ask myself whether im assuming luck i might not necessarily have or whether i'm making the opposite error, assuming i will never get a lucky break ever --- I guess what matters from the pov of coding here is, having some sort of folder etc where a bunch of "assets" are stored, picking one at random, and displaying it. etcetera.

I feel like I would be motivated to learn about the components of programming if they were embedded in a project structure like this. It seems to me neither of the projects above is too hard necessarily. And there are videos on youtube by people who have solved these problems -- but then these people would assume that one has cs-50 under their belt and would just present their code without explaining down to basics (e.g. the download all pdfs from a page seems to be a fairly simple one).

It seems to me most people who have learned to code have toughed out through the beginning phase where nothing makes sense and you rote-memorize how to write a for loop or how to count through an array or whatever. But that approach doesn't necessarily work for me. It would probably work if I were to stick with it, but I never could.

Any ideas or suggestions of how you'd approach learning to code if you had this type of brain? I assume most who have CS careers have not encountered this because they probably breezed through the basics and then when the time came to think about how to execute actual projects it was a matter of going through their mental rolodeck of possible tools and code chunks. Or did you encounter it?

How about those who did not necessarily had CS as a specialisation and had to learn later, how did you do it?

Any help thinking through how to overcome this block in learning is welcome. Thanks for taking the time!
Last edited by ertyu on Fri Jul 14, 2023 2:19 am, edited 1 time in total.

zbigi
Posts: 1008
Joined: Fri Oct 30, 2020 2:04 pm

Re: Project-based learning to code: how?

Post by zbigi »

I learned on Commodore 64 computer, with BASIC and assembly. As an 8 year old, getting the computer to print my name in an infinite loop, blink whole screen in random colors, move some sprites around etc. were cool enough projects to motivate me to learn. I suppose it's the same with drawing, playing instruments and other kinds of creative hobbys - it's much easier to learn as a kid because your expectations are so much lower then. For example, the thought of me being able to write even a simple game (compared to the ones I was playing at the time) never even crossed my mind until I was 12 or so. Whereas grownup beginners are usually like "so how do I gamedev" in their second week of trying to learn to code.

ducknald_don
Posts: 333
Joined: Thu Dec 17, 2020 12:31 pm
Location: Oxford, UK

Re: Project-based learning to code: how?

Post by ducknald_don »

I think the problem with trying to teach CS like that is those 'simple' problems are anything but. There are so many ways that they could break and then your tutor is going to be mired in problems that aren't related to the subject at hand.

Perhaps you should start with some higher level tools. Automator on macOS is built for problems like those that you described. I'm sure you can find something for Windows as well.

ertyu
Posts: 2934
Joined: Sun Nov 13, 2016 2:31 am

Re: Project-based learning to code: how?

Post by ertyu »

Scale down expectations, check.

Thinking about it, I think my main issue is that if I pick up a standard intro textbook, I lose motivation when I don't know whether and how what I'm learning will help me do what I want to do. Conversely, I don't know how to go the other way - from an idea to "what do I need to teach myself to make this a reality?" No other solution than "tough it out and deal with it", huh?

bostonimproper
Posts: 581
Joined: Sun Jul 01, 2018 11:45 am

Re: Project-based learning to code: how?

Post by bostonimproper »

I agree with the suggestion of using higher level tools to start with. Other than Automator, if you’re on a *nix machine (Linux, MacOS), these are pretty good projects to learn basic Linux commands if you want to feel “l33t”. It looks intimidating but the barrier to entry is a lot less than you think— I’ve worked at companies where administrative assistants were expected to know the basics and it was fine. You’ll probably want:
- file system navigation: cd, mkdir, ls, rm
- web scraping & text manipulation: curl, sed, grep
- Input/output: <, >,>>, | (“pipe”), cat, echo
- Random number generation: echo $RANDOM

Once you see the utility first-hand, I think it’ll help motivate you to learn the basics.
Last edited by bostonimproper on Fri Jul 14, 2023 6:50 am, edited 1 time in total.

Scott 2
Posts: 2870
Joined: Sun Feb 12, 2012 10:34 pm

Re: Project-based learning to code: how?

Post by Scott 2 »

There are gamified tutorials. The coding is a controller, your means to the end. You could see if any of those stick.

I learned in three ways:

1. Changing existing programs. Computers used to ship with games written in basic. You could edit them.

2. I had a fancy calculator for math class. You could program it. Math class was boring, so I did. Equations. Simple games.

3. This thing called the Internet came out. I wanted to put stuff on it. But how???

I earned a CS degree between 2 and 3. Frankly, it didn't help that much. Programming always involves trial and error. How do I do X? With experience, you pick better X, you use better tools, but the core loop never changes.


I don't code anymore. I find someone else who's already solved the problem. Outside of not wanting to write software, I want the benefit of their time immersed in the problem domain. The code is a vehicle to access expertise.

mathiverse
Posts: 802
Joined: Fri Feb 01, 2019 8:40 pm

Re: Project-based learning to code: how?

Post by mathiverse »

I used this curriculum to learn to program: https://compsci.sites.tjhsst.edu/CSweb/index.html. It starts to teach you via more graphical exercises. For example, the first chapter is about controlling a robot in small maps. The second is about GUIs, etc. It was less tedious than other books I went through later in my career. (Also, you'll be fully prepared to make the fortune telling app after going through the above, imo. That is a fairly simple program for beginners who just learned to code from a typical textbook.)

On the other hand, if you Google the right keywords, you can find tutorials on how to do the things you are interested in. First, go through the tutorial following the directions exactly. Then make small changes.

I'll walk you through an example of what I mean since I don't know if a beginner programmer can split up a task like that very well or if they know what I mean by make small changes.

Here are a few web scraping examples in Python: https://www.geeksforgeeks.org/python-we ... -tutorial/.

Here is a specific one.

Code: Select all

import requests
 
# Making a GET request
r = requests.get('https://www.geeksforgeeks.org/python-programming-language/')
 
# print request object
print(r.url)
You could take these steps.
1. Get the example working exactly. This may be easy or annoyingly complicated. This may require set up of Python on your computer. It may require Googling for weird things you see. The hard part is the set up and then learning to run your program given what you set up. The other thing is look up concepts/words you see that you don't understand in the tutorial to try to get a feel for things.
2. Try to scrape a different website than the one in the example. (In this case, change the URL to the website you care about.)
3. Try to print the data to a file instead of to the console. https://stackoverflow.com/questions/521 ... -text-file
4. Try to take the data you got and filter only the parts you care about, for example, only print the urls on the webpage: https://stackoverflow.com/questions/839 ... -in-python
5. Come up with your own idea, Google until you find an example of someone doing it, then try to add it to your code.

This requires you to make more inferences and leaps into how things work. That can be a lot more engaging than the textbooks you mentioned. It would help to have someone you can ask questions like: "What should I look at to figure out how to do XYZ?" when you get stuck. That person can also tell you what that "thing" is when you want to look up something weird you see in the code. That person can also give you small tasks at your level like I tried to do above. But given the fact you already have things you want to do, I'd focus on making the changes to the tutorial that lead in that direction. Look up concepts as you see them in the code. That is, Google "programming_language name_of_weird_thing", for example: "python re" or "python requests" or whatever. Stack Overflow is your friend, too. For asking questions and for getting answers since many people have asked similar questions before.

ETA: I could meet with you for two hours over a video chat to help with set up and also trying out the idea above for you to walk through a tutorial and try to make changes. I would be there to help you debug, suggest changes if we get far enough, answer questions, explain concepts, etc. I'm not an amazing teacher (or programmer for that matter, though I was a software dev :) ) and I admit that I'm not 100% certain how feasible it is for a beginner to learn like the above, so I'm also offering because I want to learn if this is viable advice for someone who is learning to program on their own and who is interested in a path other than going through a textbook.

jacob
Site Admin
Posts: 16026
Joined: Fri Jun 28, 2013 8:38 pm
Location: USA, Zone 5b, Koppen Dfa, Elev. 620ft, Walkscore 77
Contact:

Re: Project-based learning to code: how?

Post by jacob »

ertyu wrote:
Fri Jul 14, 2023 2:08 am
Or I'd like to write myself a fortunetelling app - or a problem-solving app if you will, whether any fortunetelling methods tell any fortune is debatable but I find it useful to be able to draw a random image, statement, question, or whathaver at random from a collection I import and use that as a prompt to bump my thinking out of whatever rut it's in -- a simple example being, let's say i ask, "what have i neglected to consider about this issue that i should" and what shows up is some symbol one associates with, say, luck, like a picture of a 4-leaf clover i took. then i can ask myself whether im assuming luck i might not necessarily have or whether i'm making the opposite error, assuming i will never get a lucky break ever ---
This is your simplest project, because you could keep everything in the source code. You're basically asking for a magic eight-ball ala

number=random(8)
case(number)
1: Print "It's your lucky day"
2: Print "Look behind you!"
...
8: Print "No soap, radio!"
end case

Get something like that running in your language of preference.
ertyu wrote:
Fri Jul 14, 2023 2:08 am
I guess what matters from the pov of coding here is, having some sort of folder etc where a bunch of "assets" are stored, picking one at random, and displaying it. etcetera.
But now you're talking about reading and navigating directory, opening and closing files, and importing data. Data in the form of random strings rather than fixed format numbers. This is substantially harder than the 8-ball above although some languages make it easier than others. However, as you learn how to read files (start with a well-formatted one) into a data structure, you can take the 8-ball project above, and modify it to output a random entry from your data structure. Indeed, the next step would be to hardcode a data structure and delay the snafu of the file-system until the very end.

In short, start from the simple and very specific kind of program and then move on to the general/flexible kind. A parallel example would be to make something that can play a little tune. You can go from

begin
play(440, 1) % 440Hz for 1 second
play(220, 2)
etc.
end

to a program that loads the notes (number pairs) and goes
for n=1 to 100
play(frequency(n),duration(n))
end for

and so on ...

Treat it like learning a language. Start with Donde Esta la Biblioteca? Then Donde Esta other places ... and so on.

macg
Posts: 178
Joined: Tue Mar 31, 2020 1:48 pm
Location: USA-FL

Re: Project-based learning to code: how?

Post by macg »

Google is your friend.

One way to learn is to find online some project that you're interested in, or Google some snippet of code that you think would be useful, and copy it. So in Jacob's example, you could Google "Python 8-ball program", and see what's out there.

Then you could spend the time reviewing it, modifying it, and looking up pieces of it that you don't understand. In the end, you will understand what it does. This is what Scott 2 refers to as well, back in the day before the internet was widespread, there used to be gaming magazines that had programs in there that you would manually copy into your computer and all of a sudden you have a game.

There's always times that going out and using other people's code is useful. That's basically the whole concept of AI, at least right now lol.

ertyu
Posts: 2934
Joined: Sun Nov 13, 2016 2:31 am

Re: Project-based learning to code: how?

Post by ertyu »

Thank you all, the suggestion to reduce my project to its simplest possible form and progressively iterate on that + see how others have solved similar problems makes sense. I will take it from there.

Thank you for the offer to help, @mathiverse, I will try not to be obnoxious about it and solve my own problems first to the best of my ability, but if i find myself completely out of my depth, I will dm you.

tdurtsch
Posts: 17
Joined: Wed Jun 03, 2015 2:03 pm

Re: Project-based learning to code: how?

Post by tdurtsch »

If you are interested in an iterative coding puzzle game, check out Elevator Saga https://play.elevatorsaga.com/.

I discovered this game long after learning to code, but I imagine it would be good practice for a beginner as you slowly need to develop more complicated solutions as the levels progress in difficulty. A large part of this game involves studying the API documentation, which, as a software engineer, you'd end up doing a lot.

User avatar
Viktor K
Posts: 364
Joined: Sat Jul 30, 2016 9:45 pm

Re: Project-based learning to code: how?

Post by Viktor K »

Most of these courses are project-based and 100% free for HTML/CSS: https://www.freecodecamp.org/learn/2022 ... eb-design/

Front-end (React, CSS libraries) also has 5 projects on the end, free: https://www.freecodecamp.org/learn/fron ... libraries/

I used those in 2017/2018 to move from teaching English to coding.

Fish
Posts: 570
Joined: Sun Jun 12, 2016 9:09 am

Re: Project-based learning to code: how?

Post by Fish »

The key insight for me is that programming involves decomposing high-level objectives into small tasks that are individually solvable. In addition to learning what is possible, it is important to be creative as there is almost always more than one way to solve a problem. For that matter, it is also possible to reframe problems in a way that makes them much easier to solve.

This makes progress on coding projects more consistent since individual problems are solved using known or easily googleable building blocks, provided that the problem is appropriately defined, decomposed, and/or simplified. Also as you get better your universe of possibilities also expands accordingly.

jacob
Site Admin
Posts: 16026
Joined: Fri Jun 28, 2013 8:38 pm
Location: USA, Zone 5b, Koppen Dfa, Elev. 620ft, Walkscore 77
Contact:

Re: Project-based learning to code: how?

Post by jacob »

The DIY flight controller I made might make for a practical example of how self-education often goes when done as part of a project. It started with the simple goal possible. Build a throttle. Actually a simpler goal would be to build a button box(*). Immediately, there are a bunch of proposals, some of which are "too clever" and some of which I (not knowing enough) don't recognize. Once the sandbox is established, progress is incremental. I did not describe it much in the thread, but it roughly went like this.

1) Figure out where to get the Arduino IDE and install it.
2) Compile and run print "hello world!". (This is the first thing to do in any language)
3) Figure out how to read an analog input.
4) Figure out how to read a digital input.
5) Figure out how to download and install the joystick library and get windows to recognize the Arduino as a HID controller.
(I know have all the parts working and verified. All I need to do is put them together.)
6) Program a three-axis joystick. (This is three parts (3) and one part (5)). Get it recognized by windows. I know have a working prototype!
7) Take it for a test-flight in the actual game.
8) Add three more parts (3), three parts (4), and a final part (4) with some extra code to change its functionality for the finished controller.

I was more or less building the hardware part concurrently.

Another issue that hasn't been mentioned(?) but which is also more of a problem when it comes to hardware than software is what components to get and how to get them. I always thought of github as something that probably required a degree in CS to use. After all, this is how software repositories used to work if you wanted weird snippets of code or install your own libraries. Not so anymore. This was really easy---practically drag and drop.

(*) I do have the hardware for this. I just never got around to building it. This speaks to an equally important issue which is where I think the textbook exercise approach may fail to engage some students. I didn't have anything in mind to use that button box for ... so not really motivated to build it. (Those who enjoy the process of building rather than the result of building shouldn't have an issue here though.) As such a better definition of simple is the simplest possible worthwhile project.

User avatar
Lemur
Posts: 1626
Joined: Sun Jun 12, 2016 1:40 am
Location: USA

Re: Project-based learning to code: how?

Post by Lemur »

Python for Everybody is a free course on Coursera sponsored through University of Michigan. Covers chapters 1-5 of the textbook which is also free for download: https://www.py4e.com/book

Post Reply