Okay so your new to programming and you need to start somewhere, well first you need to have the mindset of a programmer and you might be asking how do i do that,
You start your journey by learning this techniques
- White boarding
- Flowchart
- pseudocode
- algorithm
Before we get into the technical parts we need to learn how to acquire the mindset or we need to think like a programmer,now how do we do that?
so most beginners think that programmers know every syntax to every language to every framework and to tell you the truth is not true, not knowing that they wast much of their time learning languages on YouTube(also called tutorial hell) than practicing different software architecture and solutions and when faced with practical software building task they can't recall most of the things they learned.
Programming is like a speaking human language but for machines. Like normal language your goal is not to memorize your entire dictionary but to learn how to convey ideas in a way that is understandable to other people.
Programming is not about memorizing code snippets its more about building a solution by using your fundamental knowledge to break a problem down, So you need to get your hand dirty as soon as possible.
one way i always use when i get a problem is to talk about it out loud or talk to a rubber duck on how to break down the problem, well you might be saying am not crazy to do that well it is an effect way and you got to give it try.
Tip: instead of thinking if your solution is correct, think how is this solving the problem.
Tip: Don't search every coding problem your faced with on stack overflow or google. try reading the documentation first and correcting yourself.
mind you this are some very simple concepts you need when starting, so lets get with it.
1. White boarding
Develop problem-solving skills when you practice a lot of coding questions.
While most advance programmers have their own way of approaching a problem beginners have a hard time of solving a problem on their own and following their train of thought even though they can understand a languages syntax, or follow along with other peoples coding tutorial.
Here is a strategy to solve a programming problem on your own as a beginner
Step 1: Understand and Analyze the Problem
most of the time when faced with a question we just read the core of it and think we can solve the problem without reading the hole part.
we need to understand the hole problem even missing a sentence can change the a problem fully, so carefully read the question and understand it.
-Understand the question fully.
-get a paper and write all the given(input) and the output.
-explain this question to someone else, if your alone use the rubber duck or something.
-what would be the output for a given input
Step 2: Go Through The Sample Data And Examples Thoroughly
Get a sample of input to feed your code from that analyze the output or what would be the output if there is no input.
try all the possibility
Step 3: Break Down The Problem When you see a coding question that is complex or big
when faced with a problem break down the problem into smaller chunks and then try to solve each part of the problem.
make a flowchart for the problem and divide the big problem in to smaller subprograms and solve these subprograms using the flowchart.
Step 4: Write Pseudocode, make a flowchart
Before starting a problem write a pseudocode to the problem. pseudocode is a written form of the solution in English format.
It gives a clear idea of the problem, most programmers skip this part but when you write a pseudocode solving a problem becomes easier,So write down every step and logic in your pseudocode.
Step 5: Replace Pseudocode With Real Code
Once we have written a pseudocode we need to translate each line into code.if you have divided your problem into subproblems then write down the code for each subproblem.
Keep 3 things in mind:-
- The point where you started
- Where are you right now?
- What is your destination (end result)?
Step 6: Simplify and Optimize your Code
What you need to go for when writing a code is to write as many of the write code as you can which is more efficient than the other one.
Once you have finished your problem try to explore a more efficient alternative .
So once you are done with writing the solution for your code below are some questions you should ask yourself.
- Does this code run for every possible input ?
- Is there an alternate solution for the same problem?
- Is the code efficient?
- Can it be more efficient
- can the performance be improved?
- How else can you make the code more readable?
- Are there any more extra steps or functions you can takeout?
- Is there any repetition in your code? Take it out.
2. Flowchart
What is a Flowchart
A flowchart is a type of diagram that represents an algorithm, workflow or process.
Why use a Flowchart?
They can be understood by non-developers and by developers that do not know the language the process is written in.
Flowchart Symbols
A good symbol set to use is the ISO 5807 symbol set, as they are well-known and often used in the technology industry.
Flowchart Usage
- Create a flowchart before coding a task to either help create or validate pseudo-code
- Add to a README.md to visually show how your project/process works
- Use in a presentation to aide audience understanding
- Your function or process is not working as expected?
Tip: best free tool for flowchart is Diagram
3. pseudo code
Pseudocode is basically a higher-level description of some algorithm meant to help describe the "core essence" of some particular algorithm. You typically write pseudocode when you're trying to figure out what exactly you want to do or if you're trying to communicate your idea to another programmer.
Since psuedocode is a tool for communication, it can take many forms. The most common way people write pseudocode is by writing something that vaguely looks like code (if statements, indentation), but they strategically replace certain sections of code with English sentences to remove the tedious bits/to make the description easier to understand.
However, that isn't the only way you can write pseudocode. Pseudocode can also look like:
Literally a bunch of regular English sentences, with nothing resembling code
Some mathematical equations with a few brief explanations sprinkled in
Numbered steps, cookbook style
Diagrams (boxes, arrows, colors, some labels...)
As you can see, there's no formal standard for what pseudocode looks like: you simply write whatever you think will be most effective at communicating your idea.
A related question you have is "why not just use code to communicate our idea?".
The problem with this is that code can sometimes be overwhelming: actual code tends to contain all sorts of fiddly (and frankly irrelevant) details, some of which are specific to that programming language. This forces the reader to have to spend some time first deciphering the low-level details instead of immediately jumping to the core idea, which is sub-optimal.
It also requires you, and the other human, to both understand the same language, which isn't always possible.
So for example, while I might say the following in code...
for(var i = 0; i < 10; i++) {
console.log(i);
}
We could also express it in more human readable pseudocode..
loop from 0 to 10
print loop index
There is no specifix syntax for pseudocode, it literally can be anything you want.
Here is a Great resource on how to write a pseudocode
4. algorithm
An algorithm is a set of instructions for solving a logical problem. A program is code that puts those instructions in a form the computer understands.
Here is a good introduction Video to this concept is algorithm
Please Follow me for more content on Software engineering am going to post as much as i can.
Top comments (0)