+ 2
What process do you utilise when trying to write a programme/solution?
I'd love to hear your tips and strategies for designing a program.
8 Respostas
+ 6
I usually create many none variables and store data's on that to work from . so my code becomes less readable :(
+ 3
first write in comments what I need... then I write TODOs like this ..
//TODO: here what I have to do yet
then If I will make it visual.. I define visual things like buttons or editext or text view...
then if I require user input I define input method and variable to solve it....
then define one other function/method where calculation will happen.. and one method to print answer to screen..
then I will call both methods in main for calculation and printing it to screen...
I declare variables when I need them.
+ 3
I make a rough sketch on a piece of paper
+ 1
to give some context, as I used c and assembler before I try to understand the question, rewrite it often and think about the data I'm using.
then I do a flow diagram detailing how the program will flow and any decisions that need to take place.
finally, I do a program structure, I.e. main() and all subsequent functions.
I'm not sure how to adapt this approach to include oop and find myself kinda stuck at a procedure approach.
+ 1
For OOP, if you find yourself using a certain section of code multiple times, try to see if you can make that section into its own function. An example would be, if you need to check user input to make sure it is formatted a certain way or is a certain variable type. Create a new function so you can just call that instead of rewriting code.
Think of it this way. if it's a noun it's a class. If it's a verb, it's a function of the class.
+ 1
I use an IPO chart first decide what inputs you will receive, then how you will process them to get the desired output.
+ 1
1. Idea
2. basic algorythm on paper, mind, textfile
3. from 2 - some obvious problems and their solutions
4. debug-style-coded alpha
5. beta
6. repeat until it works perfect
0
I'm a visual person...I draw a sketch of the endpoint, and work backward or forward and fill in the gaps.