Am i doing programming right?

  • Thread starter jd12345
  • Start date
  • #1
256
2

Main Question or Discussion Point

I started programming like 1-2 months ago - In most of the questions I actually try to tell the computer what I would actually do to solve the problem. I am just telling the computer what humans would do to solve that problem.

Is that the right practice?
 

Answers and Replies

  • #2
33,106
4,801
I started programming like 1-2 months ago - In most of the questions I actually try to tell the computer what I would actually do to solve the problem. I am just telling the computer what humans would do to solve that problem.

Is that the right practice?
That's what programming is. You write the instructions that the computer performs. One of the steps in writing a program is to figure out an algorithm, which is the set of steps you would do in solving the problem. The next step is to write your code in using the programming language of your choice (or the one you are learning).
 
  • #3
256
2
Then why is it tough( some questions ). I just need to tell the computer what I would do in that question but still that is tough, why?

Also some questions like finding gcd of two numbers- humans factorise the two numbers and multiply the common factors but for the computers we use euclid's algorithm. Why the different approaches?
 
  • #4
483
2
I started programming like 1-2 months ago - In most of the questions I actually try to tell the computer what I would actually do to solve the problem. I am just telling the computer what humans would do to solve that problem.

Is that the right practice?

Yeah, that is pretty much the idea. Most computer programs are very routine logic, just done much faster than a human can do.

I would add that most humans do a rather sloppy job with logic, this reflected in the poor quality of the average computer program. So try to do better than that, if you can. The main problem is that humans tend not to consider unusual cases and get a program that crashes whenever you do anything out of the ordinary.
 
  • #5
Borek
Mentor
28,305
2,688
Also some questions like finding gcd of two numbers- humans factorise the two numbers and multiply the common factors but for the computers we use euclid's algorithm. Why the different approaches?
Nobody ever prohibited humans from using Euclid algorithm nor computers from factorizing and multiplying common factors.

Method with common factors is rather difficult to code - way more operations to do (preparing list of prime factors, managing two sets of factors, finding the intersection). Euclid algorithm is much more elegant. No idea why Euclid algorithm is not taught in schools as a method; perhaps for pedagogical reasons.
 
  • #6
586
2
... I am just telling the computer what humans would do to solve that problem.
That has some pretty wide-ranging possibilities

Is that the right practice?
Easier to answer if you would provide a sample of your code.

What is your method of learning? (School, on-line courses, "how to" books, ...?)
 

Related Threads for: Am i doing programming right?

  • Last Post
Replies
2
Views
415
  • Last Post
Replies
17
Views
3K
Replies
2
Views
640
  • Last Post
2
Replies
28
Views
3K
  • Last Post
2
Replies
32
Views
3K
Replies
90
Views
9K
Replies
7
Views
542
Top