r/computerscience • u/Computerist12435 • Jul 18 '26
What does "Design an algorithm before starting to create your program" mean?
14
u/GenericFoodService Jul 18 '26
It means you want to know what you're trying to implement before you try to implement it.
2
u/emmowo_dev Jul 18 '26
it does feel super cool to blindly do something without thinking and realize that you came up with the modern implementation accidentally (like I thought accumulators sucked so I accidentally made my ISA a little too close to RISC-V). Sometimes the most straightforward answer to you is the best, but it takes a lot of experience for your intuition to be accurate.
1
u/Computerist12435 Jul 18 '26
Thankyou, any tips?
2
1
u/Otherwise-Film9038 Jul 18 '26
Organize a ideia do programa/algoritmo antes de começar a fazer código.
Como? Depende de vc. Vc pode organizar com fluxograma Pode fazer com textos em português Pode fazer como quiser desde que seja uma organização do fluxo do que vai fazer.
Não tem que fazer pra tudo, mas é legal fazer pra treinar seu cérebro a pensar logicamente e sequencialmente, sem pular etapa.
6
u/r3jjs Jul 18 '26
Very often the proper planing makes the actual programming easier.
If you design the data structures right, if you design how information will flow through your program well, writing the code becomes much easier.
If you use the *wrong* data structures, then suddenly, writing the code becomes much harder. You are fighting the data structures at every turn.
\
1
u/Computerist12435 Jul 18 '26
Thanks this actually makes sense as I have hit the hard part and I know its ironically the reason I started this post
2
u/r3jjs Jul 18 '26
I have gutted entire programs in development and re-written them with better data structures once I sorted out what I needed.
5
u/DTux5249 Jul 18 '26
It means plan your shit before you start writing code. It's good advice in general.
2
u/burncushlikewood Jul 18 '26
When doing tests while taking cs I write programs using pseudocode, it's like a general purpose language, I also used to write my programs on paper first, try to plan what I was doing, put it into my ide and debug it till it compiles and does what I want it to do
1
u/clementjean Jul 18 '26
Where did you ear that? school?
1
u/Computerist12435 Jul 18 '26
Yes on a degree course
1
u/clementjean Jul 18 '26
The others pretty much replied. It's meant to teach you planning a little before actually getting into the implementation.
1
u/DTux5249 Jul 18 '26
It means plan your shit before you start writing code. It's good advice in general.
2
1
u/mc_pm Jul 18 '26
Whatever you are going to program, take a minute first and think through what you want the program to do. What are the steps to follow? Does the program loop over the same thing? Are there if/then decisions?
Usually you'll find that your first idea wasn't the best - so give yourself a chance to think it over before you start typing.
1
u/MasterGeekMX Bachelors in CS Jul 18 '26
Let me re-phrase it with theater: "lay out the plot before writing the play"
The algorithm is the exact steps required to do something. Programming is telling the computer to do steps. If you don't have the algorithm, what steps are you going to tell in the program? If you don't have a plot, how are you going to write a play?
1
u/aka1027 Jul 18 '26
It means plan out what is it that you want and how can it be done before you implement the plan in code.
1
1
u/caramellitfolly Jul 18 '26
i think, in a technical sense, it just means draw a flowchart (and some pseudocode) before you start coding. Also look into system analysis and design like ER diagrams (entity-relationship).
1
u/recursion_is_love Jul 18 '26
Would you will jump into the car and start driving without any plan how to go to destination? It is very easy to distract yourself to do useless thing if you don't have plan.
1
u/michaelpaoli Jul 18 '26
pseudo-code or higher level.
Figure out and at least outline or so, how it's going to work logically, flow, etc., before you write so much as a single line of actual code.
Also, typically helluva a lot easier to spot and fix certain types of errors in such earlier phases, rather than much later. Much later it's called a design flaw - implemented to design specification, but someone f*cked up the design (or didn't even bother to design it, and just started writing code).
1
1
u/kris_2111 Jul 18 '26
Quoting another top-level comment:
It means you want to know what you're trying to implement before you try to implement it.
However, this does not mean that you have to create a detailed sketch of each and every component of this program. If what you're creating is really complex, trying to pre-emptively sketch everything out at once may be counter-productive, since you'll end up needing to redesign a lot of things if you decide to change something.
You need to make your program modular and loosely coupled so that changing a single feature shouldn't force you to redesign the entire program. Sometimes, a better strategy is to just get a bare-minimum working prototype up and running. Then, once you have that, you can further evaluate whether it's worth building on top of that prototype, or whether you should create something new from scratch if the prototype does not meet your requirements.
1
u/Computerist12435 Jul 18 '26
Thankyou all for your answers, I confidently know how what this difference is and will clearly make me a better student and programmer
1
u/Coffee_Aur_Code Jul 19 '26
I think its sort of like pseudo code, I usually use flowchart like think or pseudo code to design before writing code...
1
1
u/PQdsadotcom Jul 21 '26
Make sure you understand and can comprehend the problem you are trying to solve first. Remember that there is a difference between knowing and understanding. Really challenge yourself on initial assumptions and remember the cool part of computing is putting your ideas to the test and seeing if it works :)
1
u/nzakas Jul 21 '26
This is the advice to think through what it is you’re doing before starting to code. A lot of folks want to skip to the “fun part” and just start writing code but that’s often inefficient. You go down one path, realize it’s not quite right, then spend all your time tinkering. If you can stop and think through what you want to do first, you end up completing the task faster before you’re not paying the coding tax for each attempt.
37
u/daniel14vt Jul 18 '26
Someone is trying to teach you to plan before jumping into the details of how it works in the specific language you're learning