Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Learn to think like a programmer???


  • Please log in to reply
16 replies to this topic

#13 DarkLordoftheMonkeys

DarkLordoftheMonkeys

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 232 posts

Posted 07 November 2009 - 10:24 AM

I'm a novice programmer, but I've become moderately good at a few things. First of all, there are two distinct things a programmer must do. One is writing code, the other is reading code that others have written and modifying it. In the programming classes I take at my college, I've had to do both. For me, the first is a lot easier than the second, and my method basically consists of:

1. Figure out what the problem is.
2. Write a plan or pseudocode (sometimes mental) for how the program is going to solve the problem.
3. Break the pseudocode into modules.
4. Break the modules into even smaller modules.
5. Test the values of each of the variables I'm going to use, using commands like alert (for Javascript) or echo (for Shell), to see how they behave.
6. Write the program one module at a time.
7. Test the program and find out that it doesn't work.
8. Go back and fix errors. This is the most frustrating part, and also the part I spend 90% of my time on.
9. Repeat steps 6, 7, and 8 as long as necessary.
10. Find that the program works, and then do my "happy dance" for about five minutes.:lol:

I've used this method for writing sorting algorithms, recursive algorithms, Unix file utilities, and just about everything else.

For reading and modifying programs:

1. Look at the code and be totally mystified by it.
2. Mark all of the modules in Vim (my text editor).
3. Write mini-programs mimicking each of the modules to see what it does.
4. Figure out how to fix the code.
  • 0

#14 DarkLordoftheMonkeys

DarkLordoftheMonkeys

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 232 posts

Posted 07 November 2009 - 10:30 AM

Really to a large extent objects are similar to structures in C, except with objects you can place function code inside the definition.


I've always thought of objects as temporary records that can be created from templates. I never really got that far in C though.
  • 0

#15 Natrobius

Natrobius

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 144 posts

Posted 07 November 2009 - 10:39 AM

Templates are a good way to think of objects, to a certain extent. You have to remember that we are thinking in terms of real world objects though.
  • 0
The Natrobius
http://natrobius.info
CodeCall User

#16 DarkLordoftheMonkeys

DarkLordoftheMonkeys

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 232 posts

Posted 07 November 2009 - 11:02 AM

Templates are a good way to think of objects, to a certain extent. You have to remember that we are thinking in terms of real world objects though.


Well, I think objects can be more abstract than that. For instance, in Java, classes are used to contain modules of code, not necessarily representing a real world object. They also have a lot of other uses, such as protecting variables by making them private.

That said, the way I see it, the main difference between OOP and procedural programming is that in OOP the modules are nouns while in procedural programming the modules are verbs. Then again, I'm not an experienced programmer and have minimal knowledge of abstract computer science, so my views may be somewhat naive.
  • 0

#17 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 07 November 2009 - 12:07 PM

In GUI programming, classes are used to represent widgets, which are frequently in a hierarchy. They can also be used to represent a variety of abstract concepts.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download