Following my last post on Classes vs Functions I hit a snag, I tend to let my mind wander and think about other things I could do. I didn't want that to happen.
I had to work out how I was going to keep myself on track. It came in the form of Outliner.
Outliner is a ToDo app of sorts, it allows you to create a project and the have sub tasks you can create and check off one at a time, it gives structure to your tasks.
It's simply brilliant, the task of creating my app doesn't seem so daunting now. So every time I check off a task I can see progress and that should keep me motivated.
I highly recommend it to anyone who has a big project to work on.
Back to the app creation stuff now.
I'm very nearly finished with my book so the time is coming close to when I start writing code and testing my theories.
First though, it suddenly dawned on me I had no idea how to structure my code. I've learnt about variables, writing to a file and accessing heap memory but not how to structure my code.
Luckily, as happened last time, the very next chapter in my book covered this.
It told me about local and global variables and creating new functions.
A pretty simple tip that has never been covered in material I've read before is to break your code up into separate tasks (as I did with the whole app creation project in Outliner), and create a whole new function to carry out the task.
For instance, I need to keep track of a score in my app, I could create a function named score() and have the code for score and how to calculate the score contained within that block.
The outcome of that block would be an int variable called score, which, for the time being, I understand should be a global variable so it is available to all other functions. Although the next chapter in my book covers how to access local variables from outside functions.
All will be explained.
So what have I learned?
I should treat my coding and my life the same, if anything seems to daunting, break it up onto more manageable sizes chunks and carry them out, one at a time.
No comments:
Post a Comment