Understand What the Function Should Do
◀ Generality of a Function▶ Steps to Write a Function Amazon
he first and foremost thing you need to do is to understand exactly what the function should do. Writing a function takes precision and caution because the preconditions and postconditions must be determined in advance and be preserved all along.
I have the experience that I misunderstood a small part of a programming assignment I was writing and ended up earning only half of the credit. Even if I did detect this little misunderstanding before I turned the assignment in, chances are that I needed to pull major changes in my program and I wouldn’t be able to turn it in on time.
Therefore, knowing what the program needs to do is the first task at hand!
We will discuss efficient steps of writing a function in the next section!
◀ Generality of a Function▶ Steps to Write a Function