What do you think about before writing code for anything? What's your process? Comment down below, i need some tips :)
For further actions, you may consider blocking this person and/or reporting abuse
What do you think about before writing code for anything? What's your process? Comment down below, i need some tips :)
For further actions, you may consider blocking this person and/or reporting abuse
Felipe Gustavo -
Saurabh Rai -
Daanish2003 -
Alex Roor -
Top comments (1)
My process usually begins with plain and simple pen and paper. I have several notebooks that I keep around for brainstorming. There are two benefits to this habit. Firstly you can look back and see how far you have come over the years. And finally, there may be a situation where you can reuse the logic you worked so hard on.
Don't forget we were able to reach the moon with programs written by hand ;)
These are the steps I usually try to follow:
This boils down to thinking about what requirements are absolutely necessary for the project to be a success. Try to keep them as simple as possible. After you have finished this you can write down your "stretch goals" as well. These are goals you would like to try and implement if given enough time (and energy).
It may be useful in the early stages to think about what you may need to learn for the project. If you aren't sure what you need to learn you can begin by doing some research. Usually, your requirements will guide you on what you need to search.
Example: One of your requirements is reading and writing from a file. If you are not familiar with this process do some quick research.
You can always revisit this step later as well.
There are several different programming approaches that can be taken. Here are the main ones I can think of:
When you first start learning Python you are most likely writing all of your code in one file. This is a perfectly good approach for small projects that aren't too complex. However, this approach isn't recommended once you start tackling harder projects. It is still useful in situations where you are creating a simple test script.
After writing down your requirements it should become clear whether or not your project needs to be broken down into smaller more manageable parts. This knowledge will also come with experience. The easiest way to do this is to utilize functions and split your code into several files. Here is a resource to get you started if you haven't already.
The best part about this approach is reusability. Once you create a Module you can reuse it as many times as you need for other projects.
I am unsure if you have ever heard about Object Oriented Programming so here is a resource. It is an extremely powerful principle. You may consider using this approach if you are implementing a complex system of "objects". An object can be a number of things but some of the classic examples are real-life objects.
Here is just one example of a case which may benefit from using OOP:
After playing with this you will get a feel for when OOP will be useful. You will also learn to recognize when it will overcomplicate your project.
:)
Up until this point, you have been thinking mostly about the "big picture" of the project. Once you have completed the above you can start planning the structure of your project. I promise this is a worthwhile step and will save you a big headache down the road.
The goal for this stage is to think about the project in smaller parts without thinking about the how. You might ask yourself what functions and classes (if you are using OOP) will be useful. Another question you can ask yourself is, what files can I split this up into?
Before I move onto the next step I usually create the skeleton of the project. I create each file I think I may need, organize them into folders, and write the outline of functions and classes. To avoid compiler errors you may want to format them in the following way:
The last step I take is to write pseudocode. It is a method of writing the logic for a program down without actually writing functioning code. The goal for this is to think about where you may need loops, and if-else statements. I usually write this as comments directly in my function or class. The benefit to this is later on when you come back to look at your code it will be easier to read.