General programming question

locutus24

[H]ard|Gawd
Joined
Sep 13, 2004
Messages
1,642
Just starting out with programming, and have one question:
1) In programming is it more important to remember every element of a language

or

2) Remember every way that it is possible to do something

Because I am doing my homework for class and keep finding myself knowing what I need to do, i.e implement a 'for' loop with a counter variable to add an array of numbers together. But that I never know how exactly to use that thing to be able to finish my homework without having to refer to a reference manual.

Not sure if this makes sense, I just don't know if I should focus on how things work or take the time to memorize every function.
 
Honestly, remembering every little thing is not necessary. IMHO the homework and all that you do in programming classes is teaching your mind how to problem solve and to think outside of the box. When I first started out programming, I was always worried about every little line and piece of my code but now i sit down and psuedo code my whole project and then just fill in code behind that to make everything work. My best suggestion is to write code, write more code and when you are done with that write more code. Don't stop with just the assignments that are given but seek out more and more difficult challenges. Try to write code that you can adapt to other projects even if it just a couple of lines. Half of the assignments and projects I get in classes these days I reuse much code that I have written before for other things, just changing bits and pieces to match the spec.

just my 2c.
 
There's many different ways to solve a problem, and identifying the choices (and the pros/cons of each) are vital. Syntax will become more innate with constant repetition.
 
Honestly, remembering every little thing is not necessary. IMHO the homework and all that you do in programming classes is teaching your mind how to problem solve and to think outside of the box.
//snip

Perhaps that is my problem, not a lack of knowledge but a disconnect in my being able to see through a problem to solve it :( .

Well any book or other reading suggestions on how a person can develop their problem solving faculties.

Thanks for those two replies, just what I was looking for. Now just feeling stressed if I can even get through this class.
 
There's many different ways to solve a problem, and identifying the choices (and the pros/cons of each) are vital. Syntax will become more innate with constant repetition.

This.

Just because you know how to solve a problem does not mean it's the only way... or the right way for that matter ;)

You`ll find as you progress over the months / years you start doing things completely different than you did before, and are using fewer lines of code to accomplish the same thing.

You will look back and think "wow, why did I do it like that?".

Once you figure something out don't get set in your ways and think it's the only way.


One of the things I really like is to test performance and optimize my code as I work on projects and have free time. It's fun to see improvements in performance, cleaner code, and less code accomplish the same thing.
 
Pretty much everything people have said above. Focus more on the "why" of doing things. Why would you use recursion in a scenario over iteration? Why would you want to go with a specific data structure? Is there an existing pattern out there that would help you out with your problem, could you recognize it if there was? If you are using object oriented stuff, what is encapsulation and what is it good for? Theory, data structures, etc. is what you want to be learning, as they more or less span across all languages. If you understand the underlying principles of how stuff works, picking up new languages is easy for the most part (with some interesting twists here and there).
 
Knowledge of technologies (such as the programming language) is like a toolboox. While knowing everything about a language can be helpful (like having a garage full a tools), its wasted energy memorizing them without actually knowing how to use any if them. On the other hand you can't get too comfortable with just knowing how to solve the task that is in front of you right now. That would be analogous to "if you only have a hammer, you'll view every problem as a nail."

It's important to know both the technology you use and the analytical skill how how to make the technology work for you. Don't worry about 100% understanding from the start, it comes with time and practice. Knowledge consists both of the specific language you use, and the higher level concepts such as OO programming and software development methodologies.

Knowing everything is an impossible goal, but that is not an excuse to stop learning. I've interviewed "senior" Software engineers that were happy with working in their little domain and knowing nothing else. While there may be jobs that don't need people to expand their horizons, I wouldn't hire anyone like that, or work at a company that did hire people like that.

Referring to a reference manual or googling it is fine, but make sure you spend time to understand the solution instead of just copying it. The Internet is a powerful tool to tap into a large collection of knowledge and solved problems.

Going forward, be sure to never stop learning. I like having a minimum of trying to learn a new concept or understand a concept better every day. One very useful thing is to connect with other developers, through class or other groups. It's not only useful for networking for finding a job later, but surrounding yourself with other developers who have a passion for it will really help motivate you to continue on. Not connecting with other developers enough was probably the biggest mistake I made in college.
 
I feel like knowing what your language is capable of is very important but it's not really too important early on in your programming journey because you're usually only a quick search away from finding the answer.

Once you start creating projects though you'll find that having to lookup things constantly is really really costly. Every time you leave your editor to Google some syntax or to see if some class has a specific method available you take a mental context switch and it throws you out of the zone.

It might only take you 30 seconds to find the answer but it's a serious burden on your train of thought.

I'm in the process of learning rails and there's just so many methods and call signatures to memorize. What I've started doing was writing down things on index cards (by hand), and if I forget I just look for it in in the index card with the question face up.

IMO make hand written index cards for things you find yourself looking up frequently. Eventually you will remember it.
 
You'll never remember or know everything there is to know because the material is extremely vast. The best thing to do is to just solve the problem at hand and re-visit it and improve it as you go. No one writes perfect code that is why we use version/source control. You do what you can with the knowledge at hand, you learn and improve more from the mistakes you make. It's like not knowing where every key is on the keyboard till you place your hands on the keyboard and start typing without looking down at the keyboard.
 
IMO, a solid understanding of how to apply concepts is most important. Many IDEs (Integrated Development Environments) such as Visual Studio provide inline help for just about any function as well as brace matching and syntax highlighting to help you. My recommendation is to learn the basic features of an IDE and start coding in it. It makes it much easier than trying to hack things through with notepad when you're screwing around with syntax errors.

As many people have said so far, you can't be expected to memorize everything. I have been writing code for several years in several different languages (VB, C, C++, Perl, PowerShell, etc) and I frequently have to look things up - even simple things like foreach loops. I may forget how to format one now and again, but I understand how to use them.

Understanding how to use the functions in simple programs is key to learning any language. That is what you'll struggle with at first. It's all logic based, and you really have to pattern your thinking around breaking the program you're writing into small pieces that can be ran as functions.

To answer your question completely - I would say neither of the options you presented are "most" important in learning to program. Either of them can help you write code faster or more efficiently, but neither of them can help you create the logic that is necessary to properly develop something useful.
 
Appreciate all the feedback from each and everyone of you. Beings how this is my first programming class, meeting the time constraints for each assignment has been difficult, but now with a better idea of what to focus on things won't necessarily be easier, they will at least be less stressful. Since now I am not going to make it a point to memorize each and every chapter I read, or every function I use just focus on learning.
 
You can't remember everything.

I'd rather have someone who knew where to look to find information and how to apply it versus someone who knew EVERYTHING (no such thing) but could not apply the knowledge.
 
You can't remember everything.

I'd rather have someone who knew where to look to find information and how to apply it versus someone who knew EVERYTHING (no such thing) but could not apply the knowledge.

yup, even experienced programmers still use search engines to look stuff up sometimes. (like when i'm neck deep a problem and need to do something I rarely do)

eventually once you learn a few languages picking up new ones just becomes a matter of spot the differences. (picked up PHP in a few days once I learned the syntax)
 
Just starting out with programming, and have one question:
1) In programming is it more important to remember every element of a language

or

2) Remember every way that it is possible to do something

Because I am doing my homework for class and keep finding myself knowing what I need to do, i.e implement a 'for' loop with a counter variable to add an array of numbers together. But that I never know how exactly to use that thing to be able to finish my homework without having to refer to a reference manual.

Not sure if this makes sense, I just don't know if I should focus on how things work or take the time to memorize every function.

Once you use for loops and the other things enough they will come naturally. It is more important you know what you need to do to solve a problem than knowing the syntax.

You can look up how to write a for loop in a second using google, but it could take a long time to figure out you need to use a for loop if you didn't know.

If you are using a nice IDE like Visual Studio 2012 with Resharper, you don't need to remember things like syntax. You just start to type "for" and the IDE autocomplete helps you out with the rest.

Of course this is just from my experience in the real world. You may need to know for tests and such.
 
Once you use for loops and the other things enough they will come naturally. It is more important you know what you need to do to solve a problem than knowing the syntax.

You can look up how to write a for loop in a second using google, but it could take a long time to figure out you need to use a for loop if you didn't know.

If you are using a nice IDE like Visual Studio 2012 with Resharper, you don't need to remember things like syntax. You just start to type "for" and the IDE autocomplete helps you out with the rest.

Of course this is just from my experience in the real world. You may need to know for tests and such.

In the end using a for loop was correct, it's just I didn't understand how to initialize it so that it would count to a user specified number. After a quick google realized its value had to be initialized at 1 and using a <= to compare against what the user entered, it was such a simple solution I felt bad I hadn't caught that on my own. :(
 
In the end using a for loop was correct, it's just I didn't understand how to initialize it so that it would count to a user specified number. After a quick google realized its value had to be initialized at 1 and using a <= to compare against what the user entered, it was such a simple solution I felt bad I hadn't caught that on my own. :(
You're going to make many more mistakes in the future; just make sure that you learn and grow from them, and are regularly asking "why" on top of "how".
 
I write and maintain apps coded in Classic ASP, ASP.NET/C# and PHP. Sometimes I'll work on a project in one language for weeks, sometimes months, before switching back to another language. I find there's always that embarrassing 1-2 day period where I have to relearn some basic language syntax and best practices. So, yeah, sometimes I have do a refresher on how to write things like a simple parametrized query in C# even though I've done it thousands of times in the past. I think it just takes that much time for my mind to un-learn the syntax and coding styles of the previous language.

The point though is that it's far more important that you know WHY you need to write a parametrized query, the language you write it in won't change that fact.
 
In the end using a for loop was correct

While its correct, it may not be the best technique. For instance, going with a foreach loop mitigates the chance of missing elements off either side of the array. Or better yet, use the languages (I take it we're talking c#) built in .Sum method (to save you the possibly of fucking it up yourself, you're only human).

While there may be many ways to solve a problem. Writing good code, that's easy to follow and doesn't break with the slightest change. Takes some time to master, some never do! :(
 
Back
Top