Copy code vs thinking like a programmer

I am trying to learn C#, and I know a bit. However, searching Bing hours on hours to tape bits together to get a whole picture of how things hang together is tiresome.
Many examples show how something is used, not why it is used that way instead of other approaches etc, or other workarounds the same problem etc.

All I am saying is that I feel many tutorials are too specific on how to do something instead of why do this.

Thoughts?

Wait. Hold up a second. Someone actually uses that search engine? Wow.

Anyway, my Unity principles YouTube series was supposed to close the gap you mention. I’ve only made a few videos. But they have been nowhere near as popular as the super specific UI ones. Ultimately content creators like myself will make the type of content that sells.

4 Likes

I know right. I treat it as malware, I had no idea anyone would actually use it.

From what I can tell, you’re trying to get told about all the ways that something should and shouldn’t be used before you’ve even really tried it. IMO this is a way of teaching that is very inefficient, and it’s very easy to misinterpret things and categorise different approaches as universally good or bad when it depends on a lot of different things.

The best way to do things, IMO, is to first understand very clearly what you want to do. Then find something that works. Now, if sometime later it turns out that this thing you implemented doesn’t fit anymore, you will have learned first-hand one of the cases in which it is not suitable, and in which some other thing might be better. But the thing is, if you had not run into the problem, it may very well be that the first approach was perfectly suitable for the task at hand!

That’s why I don’t advocate ‘learning programming’ in some kind of abstract or theoretical way. People who do that are the ones who then go around saying that everything is a code smell unless it conforms to some divine design pattern that takes care of all of the possibilities that you will never run into.

I think the best way to learn, is to decide what you want to do (your game or whatever), and hack it together, always being fully aware of what goes on in the code so that when something falls apart, you know exactly why and what you have to do about it.

The one thing you should have, is a good programming textbook so that when something is going wrong in your code and you don’t know why, you can look up the relevant information to get a better understanding of what is going on.

I believe it could be the single most important advice you can give to anyone that one should try to learn ‘why’ before ‘how’, when it comes to learning programming, or any subject with vast extent, for that matter.

If you’re only concerned with how to do something in Unity without actually understanding why, you won’t get very far because you can’t possibly find a video tutorial for every single topic you need to know in order to make a video game.

Every game differs in some way to others in some degree, otherwise people wouldn’t care to play it. And even if there was a step-by-step guide for making every kinds of games you can ever imagine, you won’t be able to watch them all because it would take infinite amount of time to do that.

But if you concentrate on understanding the fundamentals first, you’ll be able to improvise on what you already know, which opens up infinite possibilities for inventing something entirely new.

And in many cases, those basic principles tend to be related with or dependent on each other, so understanding a new topic could strengthen and enhance your existing knowledges also.

Those step by step how-to guides can be very helpful sometimes though, not because they let you do something without actually understanding it, but because sometimes, it’s much easier to understand some concept when there’s a concrete example in front of you, so you can experiment with it.

So, I’d suggest to start with the most basic things first, use whatever materials - manuals, examples, video tutorials, and etc - to understand it completely before move on to the next topic. It might feel like you are wasting your time by doing so, but it will actually save a lot of time in the end.

1 Like

[QUOT=“Billy4184, post: 3069203, member: 653158”]I know right. I treat it as malware, I had no idea anyone would actually use it.

From what I can tell, you’re trying to get told about all the ways that something should and shouldn’t be used before you’ve even really tried it. IMO this is a way of teaching that is very inefficient, and it’s very easy to misinterpret things and categorise different approaches as universally good or bad when it depends on a lot of different things.

The best way to do things, IMO, is to first understand very clearly what you want to do. Then find something that works. Now, if sometime later it turns out that this thing you implemented doesn’t fit anymore, you will have learned first-hand one of the cases in which it is not suitable, and in which some other thing might be better. But the thing is, if you had not run into the problem, it may very well be that the first approach was perfectly suitable for the task at hand!

That’s why I don’t advocate ‘learning programming’ in some kind of abstract or theoretical way. People who do that are the ones who then go around saying that everything is a code smell unless it conforms to some divine design pattern that takes care of all of the possibilities that you will never run into.

I think the best way to learn, is to decide what you want to do (your game or whatever), and hack it together, always being fully aware of what goes on in the code so that when something falls apart, you know exactly why and what you have to do about it.

The one thing you should have, is a good programming textbook so that when something is going wrong in your code and you don’t know why, you can look up the relevant information to get a better understanding of what is going on.[/QUOTE]

I am not really talking about the abstract, but when I see a tutorial for example arrays, I see them typing :
int[ ] numbers = {4,3,5,6,8}; This is how you make an array etc. I understand one have to actually know the syntax to program, but I lack some connection between what is written and why I write it to solve the problem at hand.

Then I am on to Altavista searching for how to create a two dimensional array, and then search again to try to figure out why the hell I need to use a two dimensional array to solve a problem etc.

Then I watch a tutorial of someone making a game, and he writes :

int[ ] board = new int[5];

What? What is this? That is no how the other tutorial said you made an array.

Just to end up on another tutorial where someone wrights :

int[ ] stuff;

Wait, what? What is happening here?

When I first started learning Unity, I like to use introductory books. They tend to give you a better overview of things compared to specific tutorials. I read books on Unity, C# and Blender. A basic C# book will teach you the basics of arrays vs lists and why you would use each.

OK well, this is why you need to have a textbook on hand. Because the issue here is that, in the example you gave, the two ‘ways’ of writing it are not even doing the same thing. They are not different approaches to the same problem, they do different things altogether.

See, the first one…

int[] numbers = {4,3,5,6,8};

creates an array with 5 members and specifies what those members are, namely 4,3,5,6 and 8.

Whereas…

int[] board = new int[5];

Simply specifies an array of 5 members, but does not specify those members (they will probably default to 0).

So it would only do the same thing as the first one if you then specified the members, e.g.

int[0] = 4;        // Specify the value 4 as a member at position 0 in the array
int[1] = 3;        ...
etc ...

Don’t get me wrong, it’s necessary to have a good reference, my favourite being hardcopy textbooks, but when it comes to implementing things, if you know some way that works its more important to get that implemented than to worry about whether it would have been better to do it some other way.

Also, I’ve found that looking up the type (in this case an array) on MSDN is a very good source of information on how it is initialized, how to set the values etc and to understand why something works the way it does. But I don’t think it’s a great idea to try to memorize a ton of stuff before just using it in a way that works and even perhaps onto something else that’s more important at the time.

1 Like

For starters, stop using Bing. I was forced to use it for a period of time due to a problem with my ISP and from my very brief exposure to it it simply didn’t find the right resources. A quick search for “C# Book” for example doesn’t show one of the best beginner books on the first page - the C# Yellow Book - which happens to be completely free.

http://www.robmiles.com/c-yellow-book/

2 Likes

Me too yesterday! Didn’t find it so bad, but I didn’t use it much and have not made any direct comparisons.

Bing is only good if you are looking for generic video, the preview is priceless

Well… that’s what a “tutorial” is. Traditionally speaking, a tutorial is a short learning segment designed to teach you how to apply something. They’re generally strongly guided, light on theory and heavy on practical. They’re supposed to be a part of an overall learning experience, not the whole thing.

Unfortunately Internet culture uses the term extremely broadly, making its meaning somewhat less clear.

My suggestion is to get yourself some more well-rounded learning materials. For C# in particular, I hear great things about Rob Miles’ The Yellow Book, so start there.

2 Likes

I learned a little programming in Elementary school, and then taught myself after that. Now I’m lead developer at my company.

I learned by having a problem and solving it, then solving any issues with that solution that I found. Over and over and over. You’ll pick up techniques along the way that’ll help, and you’ll learn to “think like a programmer”. But it’s slow going.

Another option, one that I had limited experience with but it helped a lot, is to have a mentor. I was already pretty far along before I met a guy who taught me a lot about clean coding, but it was still very useful. Unfortunately, actually finding that mentor and getting help from them isn’t easy unless it’s at a job. Some local groups try to do this, but my experience with them (even with that same guy being there!) wasn’t very good.

In the end, I recommend practice, practice, practice, just like any other skill you’re trying to learn. It’s nice to read up on clean code and new techniques, but don’t do that instead of actually coding. Only do it in addition to actually coding.

3 Likes

I feel like I’m the only person that spotted the Easter egg. Nicely done, if you’re just trolling us. If you’re not messing with us, I have to assume you’re a person with a personal vendetta against Google if you’re going to such lengths to avoid it. :stuck_out_tongue:

Back to your question/statement, though, I think you’re in that trap of wanting to know and understand it all before wasting your time doing it “the wrong way.” I was once like you. I thought I could skip over the Baby Steps phase by front-loading a lot of knowledge early on.

Unfortunately, I think programming is one of those things that works best when you go through all the motions. Get comfortable with an explicit, simple int array. Then look at declaring an array without contents and dynamically supplying them. Then think about a 2D array. Then look at Lists, and HashSets, and Dictionaries. Experiment and play around. See what works and what doesn’t, and how you can make the compiler not yell at you.

If you really want a proper structured environment for learning how to code properly, consider taking a class at your local college. Short of that, pick up a nice C# text book (or use a free one!) and go through it page by page. When you’ve finished it, then look at how you use C# with Unity.

Edit: Should’ve known @Ryiah would beat me to linking to the yellow book!

2 Likes

Hey you can use it to get actual money. Real money! Spend it on stuff in the Windows Store.

OP, I’ve found things much the same, but by thinking about it myself and looking around more I can typically find out why something is done. There have been a few cases where I can’t, and it’s frustrating. But usually I can.

In life we have a fine dividing line when it comes to learning. We have an art and we have a science. An art is a thing to be done, a science is a thing to be known. Those of use who take the time to intertwine these two will always have an experts advantage standing above the apprentice and the journeyman. However, the time investment is often prohibitive and due to the law of diminishing returns, achieving expertise can even be counterproductive when implementation is more desirable than the pursuit of knowledge.

Technical education falls generally on the art side. In this case your learning is a narrow implementation of an art. Technical education is teaching you the application of a specific technology and often obfuscates the underlying science behind it and in many cases the craft or art behind it. In the case of a tutorial your scope of knowledge becomes even more narrow, tutorials attempt to teach you the application of a specific technology in the performance of a specific task. You are not learning the theory of how to paint, you are not even learning how to paint with water colors, you are learning how to paint this specific tree with a specific brand of water colors. This has it’s advantages it allows you to take on the skills rapidly and replicate its work very quickly, and to a certain degree you can customize based on your scope of knowledge. Unfortunately if the tutorial represents your total scope of knowledge your ability to apply the lesson in unique ways is likely to be highly limited.

The downside of this kind of learning is that it leaves the learner with bits and pieces of information and very little actual knowledge with which to form the bits and pieces into a cohesive, coherent project. I would recommend moving beyond tutorials if you are at this point (Note: I would never recommend tutorials as a starting point). If you truly want to understand C# as a language and not just it’s specific application in Unity I would recommend you head to Microsoft Virtual Academy. Microsoft designed this language and provides amazing developer support, resources, lessons and certifications. Microsoft also provides a few tutorials that bridge the gap between their C# lessons and Unity specific implementation. This will help you move from tutorial proficiency to technical proficiency with the language. If you truly desire to have deep knowledge of C# I would recommend a book like C# Unleashed for knowledge and C# in a Nutshell as reference. I own both of these books, C# in a Nutshell is a great quick reference for the general language. C# Unleashed is an exhaustive volume that contains far more C# than any man would ever need to know for practical purposes(IMO).