is it bad to copy out of other source code until I 'get it'?

closed account (2EwbqMoL)
I dont mean straight up steal the code completely, its just that even after reading books upon books of functions, examples, a lot is still 'not there' at least practically for me. So I've been giving this another shot as a hobby (and possibly later career, if I go back to school!) since I've quit drugs and am in rehab... Used to be a hobby, but I got frustrated with it.

so like, right now, Im working on a crappy text adventure, because I feel its a good start in making some concepts make sense on a basic level, then I was going to add SDL functionality to it after it was finished. not a bad plan for self-education I dont think...

but Im still missing a lot of knowledge, so I've been basically 'stealing' most essential parts of this system from an online tutorial with source code - I know it IS condoned by the author, but my real concern is -- Will I learn from this, or will I just be 'copying' it like other examples out of books and not really learning the essential concepts?

I *feel* like Im learning... so far I've begun to understand more Object oriented stuff like structs and using things like #define and also how to use a text file to store/receive essential data for the program...

I just dont want to have to copy forever. If I'm never able to sit and figure out a process that works on my own, it can't be considered real progress.

is this the right way to learn? or should I be reading up more? do I need a teacher to properly give me tasks I can handle in progression? sometimes I feel Im missing a lot of essential info and that this is the way to learn that, others, I feel like I should just know more first before attempting to jump in...
Last edited on
closed account (2EwbqMoL)
Like, one thing I dont always understand is a choice of variable name, or where exactly that is coming from. for example if I see a function

void function (ifstream &var)

I understand &var is pointing to the variable that would be use for the char ifstream requires, using a bitwise operator. I *believe* the bitwise operator in this case is sort of defining/creating that variable in reference to ifstream, similar to how it would work on a struct similar to how

struct tStruct(){
string rarara;
};

void stucture(tStruct &bla)

would work, since bla isnt defined directly after the structure (Im just making this up fast as I go, its not real code obviously)... But im not sure where the name var would come from for the ifstream... so if I ever want to execute similar code I cannot truly USE what Im copying because I lack understanding of the true nature of what this is. I KNOW what ifstream is, but would I just be using bitstream operators (like &newvariable, &newchar, &newint) every time I reach a function where the variable has not been defined this way?

are these things I will just figure out as I copy stuff, or that the books I have will eventually explain?
Last edited on
First off, congratulations on quitting. :)

Will I learn from this, or will I just be 'copying' it like other examples out of books and not really learning the essential concepts?

There's a great risk that you won't learn much from this. It definitely works for understanding the basics if you actually dissect the snippets, but IMO it's less likely to give you a really good feel for what portions of those snippets do and how things interact.

I'd generally recommend setting yourself some very small and basic projects, and working on them. Each time you hit an obstacle caused by a lack of knowledge, research how to get around it. If you need some inspiration, try looking up some programming problems. I recall there being an article with a short list of such problems on this site.

Good luck and happy programming!

-Albatross
I have a group project in school where we have chosen to make a drawing application using the J4K Kinect library. The first thing we wanted to do was to create a live stream of the video feed from the kinect and display that on a JFrame (Java gui window) to help the user orient themselves in front of the kinect. The problem with doing this (or anything) with this library is that there is no documentation or if there is, they have done a good job at making it as hard to find as possible. The other problem is that the internals of the library are written in JOGL (Java OpenGL) which I have no idea about. So what we had to do was to first decompile the .class files inside the jar which contains the library, then dig through the code until we found something that resembles a video feed, and after some modifications, we just made a class that inherits this videofeed class then we have ourselves a live feed.

Moral of the story, if it will sidetrack you to learn something that doesn't contribute as much to the overall project, it is not worth learning and you are better off copying code that accomplishes the same thing. In my case, we were not going to be writing our application with JOGL, we are using Javafx, so why bother learning JOGL?
Last edited on
closed account (2EwbqMoL)
Realize im not so much asking for the ANSWERS but more how to GET TO the answers myself. I'm just unsure if im approaching learning the wrong way.

I feel like while jumping in is the only way, that others who jump in tend to know more about what they are doing FIRST so they can get more out of the experience of jumping in, i.e. understand all these little things, and only be focusing on the programs being copied from a DESIGN PERSPECTIVE or problem soliving.

the fact that im held up on code kind of bothers me because it *should* be basic to me
Last edited on
Why should it be basic to you? Did you ever do more than loosely study it as a potential hobby once upon a time? Or are you holding yourself to a higher standard?

Every one learns in their own way. I learn by piecing things together, breaking it, and gluing it back together again.

You want to make a text adventure? Good on ya. Make a prompt with a couple choices. Flesh out the descriptions that print when selected, then expand.

If you learn by taking what was already made, duct taping it together, and going over it again until you understand, do it. If you learn by rote, do it. Do what helps you learn, then challenge yourself to make one thing. Then add something to it. Then add something else. Then add more.

Edit: Maybe look at switch statements. They might be best for this sort of thing.
Last edited on
Coding is basic, but if programming was all about writing code, we would all be genius at that. The real issue I feel you are facing is that the logic to power your application is not coming to you as quickly as you would like. This is normal, because as you mentioned, it has been a while since you programmed. But just remember that the brain is like a muscle and you need to train it back up to what it was before you stopped programming. Doing so will make you able to think of solutions quicker and get something done in less time.
http://qr.ae/dnhH0
http://qr.ae/dnhSE

Also your choice of programming language could drastically help with this. My language of choice in this matter is python and will continue to be until proven otherwise. Python lets you just write code, no need to worry about types or variables, just write the code the way it looks in your head. Of course I'm exaggerating a bit, but in comparison to C/C++, this is no exaggeration, python can actually help you program faster. My fav example

C/C++
1
2
3
4
#include <cstdio>
int main() {
    puts("Hello world");
}


Java:
1
2
3
4
5
public class Main {
    public static void main(String []args) {
        System.out.println("Hello world");
    }
}


Python
print "Hello world"

Topic archived. No new replies allowed.