Best strategy to study computer science?

In summary, it is important to focus on writing and debugging one section (perhaps no more than a dozen or so lines of code) at a time, don't move on to the next section until you've got the previous sections working properly, and write code that is legible and efficient.
  • #1
Nano-Passion
1,291
0
What is the strategy to master computer science. My class is Fortran 90 based :D.

I never really took a computer science class before and I'm sure its a bit different than preparing for mathematics.
 
Physics news on Phys.org
  • #2
Never try to write a non-trivial program all at once and toss it to the compiler. When something goes wrong, you'll never figure out where the problem is.

Write and debug one section (perhaps no more than a dozen or so lines of code) at a time. Don't move on to the next section until you've got the previous sections working properly.
 
  • #3
jtbell said:
Never try to write a non-trivial program all at once and toss it to the compiler. When something goes wrong, you'll never figure out where the problem is.

Write and debug one section (perhaps no more than a dozen or so lines of code) at a time. Don't move on to the next section until you've got the previous sections working properly.

Words of wisdom.
Every programming task can be subdivided into a series of smaller tasks, and you want to focus your attention on each one of them individual and ensure that one is working before you go onto the next. I recommend keeping a library of code that you've written for this reason; it will happen very often that you've coded a particular "sub-task" before, and you can easily modify it to fit the new code.

On a side note (and I can't stress this enough), focus on clean (legible) and efficient (computationally speaking) programming right from the start. Bad habits are hard to break.
 
  • #4
Pick a naming convention, and stick to it. The last thing you want when you're shuffling dozens of variables is to have to go back and look up what each one is.

Try to have an idea of your program's general structure at all times. If something comes up that puts a kink in your original plan, see if there's anything in that structure that you can alter that will fix the problem. The alternative of adding a bunch of case structures and exceptions is just asking for a migraine.

Code legibility is key. You should be able to quickly glance at any block of code, and immediately have an idea of what it does and how it works. Comment as you go, even if you think you don't need to. At the beginning, it always seems easy to keep everything straight in your head. This will probably change within the first hour of coding, and if it sneaks up on you, you may be in for an arduous line-by-line journey through your code to recomment it.
 
  • #5
Number Nine said:
On a side note (and I can't stress this enough), focus on clean (legible) and efficient (computationally speaking) programming right from the start. Bad habits are hard to break.
But do not sacrifice the former for the latter -- a lot of harm gets done in the name of efficiency. (so much that "premature optimization" is sometimes cited as the #1 cause of programming sins)

99 times out of 100, it's better to write a piece of code quickly, clearly, and correctly, with little regard to efficiency. The remaining 1 time out of 100 can be discovered after the fact by profiling your code, then going back and improving the parts that need improved. (of course, you have to be diligent about actually doing that...)
 
  • #6
To "master" an area takes years or even decades. Just focus on learning.
 
  • #7
Thanks everyone! I will take them all into consideration. :)

But my biggest concern: how can I go about actually studying and getting good at programming?

For example, in math I carefully take notes of the sections, go over the proofs, make sure I understand everything at a non-superficial level, and then tackle the problems.

What do I do for my computer science class exactly?

comp_math said:
To "master" an area takes years or even decades. Just focus on learning.

Well, by mastering I mean it towards my class. Getting an A would be an indicator for me.

This is random but just to throw it out there, my psychology book cited about 10 years to master any area.
 
Last edited:
  • #8
But my biggest concern: how can I go about actually studying and getting good at programming?

You don't study, you just program. Keep writing programs and you'll get used to it. Get a book on FORTRAN and don't just replicate the code in the book, but write your own that incorporates the techniques you're learning. There's no substitute for actually doing coding yourself.
 
  • #9
Number Nine said:
You don't study, you just program. Keep writing programs and you'll get used to it. Get a book on FORTRAN and don't just replicate the code in the book, but write your own that incorporates the techniques you're learning. There's no substitute for actually doing coding yourself.

This is basically my first CS class so bare with me a bit hehe. The problem is I have no idea what to write a code about or where to write one and or to get started or anything.. :confused: The actual class material didn't really start yet either so I'm a bit lost on what to do.
 
  • #10
Nano-Passion said:
This is basically my first CS class so bare with me a bit hehe. The problem is I have no idea what to write a code about or where to write one and or to get started or anything.. :confused: The actual class material didn't really start yet either so I'm a bit lost on what to do.

I wouldn't worry about it. The whole programming "thing" seems incredibly daunting at first, but you'll find it comes pretty easily. Your professor will walk you through some simple code and give you a sense of what the language actually does, and there'll be plenty to experiment with from there.
 
  • #11
Number Nine said:
I wouldn't worry about it. The whole programming "thing" seems incredibly daunting at first, but you'll find it comes pretty easily. Your professor will walk you through some simple code and give you a sense of what the language actually does, and there'll be plenty to experiment with from there.

It doesn't daunt me at the least, its just that I believe highly in learning strategically. Its made a huge difference in my ability to absorb mathematical concepts.
 
  • #12
In my experience, learning to program is fundamentally different from learning math or science. As others here have noted, a big part is playing around by yourself, and learning things by trial and error. In some intro science classes, you can get away with plugging and chugging without actually understanding the underlying principles; this tends not to work in computer science, since a given block of code needs to accomplish a very specific task, and it won't unless you know exactly how you want to do it. Classes are great for learning the basics and getting exposed to the major libraries, but at some point, you're going to want to start little projects of your own. Start thinking of cool little things that would be useful, perhaps to satisfy your own curiosity or even to help with your other classes. Take some problem that would be difficult or impossible to do by hand, and try to make your computer do it. Then see if you can generalize it to a broader range of problems, make your solution more exact/realistic, or just make it cooler. Here's one that I was able to get a lot of mileage from:

http://xkcd.com/135/

Try solving the third "problem" there computationally. Then use your imagination and see how realistic you can make it. Do the raptors slow down when they turn? Can the person change directions in mid-simulation? Do the raptors engage in pack behavior, and work together to corral the person? (That last one is probably the hardest, but may be the most fun, especially if you're mathematically-inclined.) The bottom line is to have fun and keep learning new ways of doing things, rather than hitting the books as one might do for other classes.
 
  • #13
Nano-Passion said:
The problem is I have no idea what to write a code about

You have a textbook with exercises in it, right? That should give you some ideas.

or where to write one and or to get started or anything..

That depends on the tools that you have available to you. Some schools use a packaged "integrated development environment" (IDE) under Windows. Some schools have you write code with a plain text editor, and run the compiler and the finished program at the command line under Unix or Linux. Most textbooks don't cover details like that because they're so different from one school to another. You'll probably cover it in class before too long, or else there will be instructions available in your computer lab or on the school's web site.
 
  • #14
Nano-Passion said:
This is basically my first CS class so bare with me a bit hehe. The problem is I have no idea what to write a code about or where to write one and or to get started or anything.. :confused: The actual class material didn't really start yet either so I'm a bit lost on what to do.

https://www.amazon.com/dp/0070411565/?tag=pfamazon01-20
 
Last edited by a moderator:
  • #15
On top of the great advice I would suggest you always keep Murphy's Law in the back of your mind the whole time you are writing code.

Murphy's law is basically the saying that if something can go wrong it eventually will.

In application to programming, always think about your state (variables, and allocated memory) and picture in your mind what values they can take and what can go wrong with regard to specific realizations of those values.

For example if you are say learning C for the first time and need to work with dynamic memory (i.e. allocation from the heap), then chances are you will probably write code that crashes (it happens to us all) and most likely the error is with what the contents of the pointer are (null pointer, pointer outside range of heap).

So when you declare a variable, or use some form of allocated memory, think about what could go wrong and keep that in the back of your head.

For really simple programs you may think "what's the point", but when you start to get bigger programs and then create a lot of modules that contribute to the complexity of the program, you'll find that being paranoid (but not too paranoid!) will actually serve you well.

Good luck with your course.
 
  • #16
Number Nine said:
You don't study, you just program. Keep writing programs and you'll get used to it. Get a book on FORTRAN and don't just replicate the code in the book, but write your own that incorporates the techniques you're learning. There's no substitute for actually doing coding yourself.

This^^^

But study a little bit too. Read the text 10%, Practice programming 90%. It's the key to success in programming.
 
  • #17
Thanks everyone for your input. ^.^ I'm doing great in the class. Fortran is an awesome language. =D
 

FAQ: Best strategy to study computer science?

1. What are the essential skills needed to study computer science?

The most important skills for studying computer science include proficiency in mathematics, critical thinking and problem-solving abilities, attention to detail, and strong analytical skills. Additionally, basic knowledge of programming languages and computer hardware is also beneficial.

2. Is it necessary to have prior knowledge of computer science before starting a degree?

No, it is not necessary to have prior knowledge of computer science before starting a degree. Many computer science programs are designed for students with little to no coding experience. However, having a basic understanding of coding concepts and familiarizing oneself with programming languages can be advantageous.

3. What is the best study strategy for computer science?

The best study strategy for computer science involves a combination of hands-on practice, conceptual understanding, and continual review. This can include completing coding exercises, attending lectures, participating in group discussions, and regularly reviewing study materials.

4. How much time should I dedicate to studying computer science?

The amount of time needed to study computer science can vary depending on individual learning styles and course load. However, on average, students should dedicate at least 10-15 hours per week for coursework and practice. It is also important to prioritize understanding concepts over memorization.

5. What resources are available to help me study computer science?

Many resources are available to help students study computer science, including textbooks, online tutorials, coding bootcamps, and study groups. Additionally, most universities offer academic support services such as tutoring and study sessions. It is also beneficial to attend lectures, ask questions, and utilize office hours with professors for extra help.

Similar threads

Replies
3
Views
1K
Replies
6
Views
2K
Replies
6
Views
1K
Replies
1
Views
757
Replies
9
Views
479
Replies
1
Views
1K
Replies
9
Views
1K
Replies
8
Views
2K
Back
Top