Day 5: So you want to be a developer

Day 5: So you want to be a developer

Yesterday, I said it was fine to start with copying and pasting someone else's code as long as you learned to read it. I also said that a second option for getting started was to code a simple application that interested you.

Before you start on that app, let's talk pseudo code

Pseudo code is one of two, not mutually exclusive, ways I get started if I'm writing something new. You simply write down what you are going to code in English (or whatever language you speak/ write.) Some people believe your pseudo code needs a structure but if you are writing it for yourself, there really are no rules.

Let me give you an example for the memory game application. Here is my pseudo code.

  • Initialize variables - number of card pairs to deal out (4) , win (set to false to begin), time (60), number of correct matches (n_correct=0), number of wrong matches (n_wrong=0)
  • Create timer function to count down from 60 and show that they lost if they don't have all the matches by 0
  • Create a two-dimensional array of images and the matching text
  • Write random number function to randomize the array
  • Write function to "deal" out the number of pairs
  • Write function to handle when the player clicks on a card. Must "flip over" card by showing image or text. Must remember the first card clicked. Must check if the second card matches the first card and if it does, increase number of matches by 1 and check if all cards are matched. If it doesn't match, flip both cards back over. Prevent player from clicking a third card before the first two are turned over. If all cards are matched, execute a win function.
  • Write a win function so that when all cards are matched in under 60 seconds, a happy tune plays, an image shows up of something nice, 10 points are added to the players overall score and an arrow shows up that, when clicked, takes them to the next part of the game.

Your mileage may vary, but for me, I find starting any reasonably complicated program with pseudo code helps me see what the main features are versus the bells and whistles. For example, it would be nice if the cards made a sound like being flipped over, and I could add that later but it's not part of getting the game to work.

Also, for me, breaking large projects down into parts like this makes it seem not so overwhelming. As opposed to feeling as if I have made no progress because the damn thing STILL doesn't work, I can see that I have knocked off a third of what I set out to do.

And now, since I really did get a lot working today, and it's late, I'll save the drawing part for tomorrow. (Okay, that also turned out to be a lie because I decided I wanted to get into coding a little bit and talk about arrays. I'll get to flow charts and other pictures some other time.)

P.S. Some other time turned out to be Day 7

要查看或添加评论,请登录

AnnMaria De Mars的更多文章

社区洞察

其他会员也浏览了