How do programmers know what and how they should code something?
For instance, the attached pic is part of a code from a bot for Telegram:
How do they know what they need to get/request, values they need to insert, parameters to be defined etc.? It's obviously so much different from what is learned in Programming Logic and even Introduction in any language. To me, most of them make no sense and we, learners, just have to "accept" them as they are.
Plus, if you follow up some tutorials, it works more like a copy and paste thing.
I feel I'm caught in a loop of simple codes (codes to read and generate a result, like calculating some mathematical thing or whatever) but they won't ever be useful.
Am I overthinking or is it really that hard?
- 2 months ago
Usually they already know the algorithm (call it a list of what to do)
a complex program usually consisted of a bunch of simple process, and for each process it has it's own algorithm.
Just make a simple one first and add with another until it can function properly.
How to properly do it is an experience matter
- twiigssLv 42 months ago
The unfortunate answer is: Go to college. A friend of mine went to Devry college for 3 years, got a degree and learned C++, and something called AS400. Before he went to Devry, he had never done C++ programming, and now, he can easily put together programs while I sit here struggling (can't afford college)
No, you are not overthinking it, it really is that hard. And for people like me and you, we are completely left out of the programming loop. So unless you got 40 grand a year, we won't get very far.
I tried programming Fractals in Python with tutorials. I got 2 to work, but I don't understand the programming behind it. And I never took algebra, the regular math 9 classes just went too fast and I couldn't keep up, went from an A to a D in two weeks, so had to go back into the special math.
Everyone is different. Some people can pick up on stuff, others can't. But I have strengths in other places.
- The_Doc_ManLv 72 months ago
The secret of knowing what to do isn't actually much of a secret. It is a repetitive process of problem analysis using a "divide and conquer" method.
You start with the statement, "I need a program to do X" (where "X" is a fairly broad-brush type of thing, like "recipe management" or "inventory" or "moon landing computations" or .... you get the idea. Big-picture goals.)
Now you say, to do X, what are the steps. And you identify steps like "gathering input" and "data validation" and "computation" and "results output."
Now you say, "What will I need to do with the input gathering step?" And you decide what needs to be done. You break THAT part down further.
Eventually you will reach steps broken down enough that you know how to write the code for that step. You break down the problem into its component elements until you can write code for EVERY STEP that you have identified. That is how we do what we do.
- ∅Lv 72 months ago
learning coding is tricky. which is why they try to teach you the basics and core principles first. once you know enough of those, you can pair them and combine them in interesting ways to accomplish tasks and reach goals.
and once you've done enough of THAT, you start thinking more broadly. you try things you weren't necessarily TAUGHT, but that you figured out on your own, through trial and error.
once you've been coding for a certain period of time (or actually, once you've written and rewritten enough code), you learn some of the quirks, workarounds, and tricks that your chosen language allows you to do. this may be intended use, or even a "glitch" that isn't really hurting anything, and may end up being patched or removed or altered at some as yet undisclosed point in time.
but sometimes, there are just things that were not PLANNED, but just happen to work that way, and they are known by most coders with enough experience, and so coders just know it, and understand its caveats, and use it knowing that it will work.
the more you know about something, the better you understand it. there are some things that cannot be TAUGHT, they must be EXPERIENCED to be learned, and the only way to do this is to be a very proactive coder. you have to really WANT to code, and WANT to try new things, and want to see what will happen if i do this...
great inventions came about because somebody took something that existed and did something different with it. great coders work the same way.
- How do you think about the answers? You can sign in to vote the answer.
- husoskiLv 72 months ago
What you're looking at is client code in Python using HTTP requests (using the standard library module "requests") to communicate with a server (located on whatever computer the domain name "random.dog" translates to) and using an application programming interface (API) supported by three classes (Updater, InlineQueryHandler, CommandHandler) imported from a custom package (or module) named "telegram.ext".
There's also an import for the "re" standard library module (regular expressions) but that isn't being used in this example.
That's a rough description based on over 10 years of Python experience, plus some simple HTTP coding. (...and not much else, as it also tells you just about all I know about interfacing to Telegram.)
In order to understand and work with something like this, you need to know the basics of HTTP requests and responses, and then read the documentation on those custom classes from telegram.ext. You can get a start on that with "tutorials" and "cookie cutter" programming. In my experience, the best way to read and understand documentation is to write code as you read about each feature. Type in the examples and get them running, and then experiment with changing them as you learn about the methods of each class that you'll be using.
And yes, there is a lot of complexity in any modern computer system. A big part of programming methodology is learning how to build and maintain complex systems from (mostly) simple components. As you design, write and test each of those components, you'll find that some of the ideas from your Programming Logic class can help.
- EddieJLv 72 months ago
If you want to go to get dinner, how do you know if you should drive to McDonald's, or if you should drive to Burger King?
When you are ordering, should you mention the burger first, or should you mention the chicken nuggets first?
You DO seem to be overthinking it. AND it seems like you are jumping ahead by looking at someone else's code -- which is something that is difficult, even for experienced programmers.
Have you had a course in Python? If not, maybe you don't even recognize that the picture is a Python program.
Meanwhile, I've never heard of Telegram before. I was a professional programmer for 25 years, but I never programmed a bot. No one can know everything.
Wired magazine: "Many cryptographers and security engineers, though, including White, say that the safest way to use Telegram is just not to use it at all."
- UserLv 72 months ago
A - you have a goal, something that a program is supposed to accomplish or enable users to accomplish
B - you have a computer language / compiler and platform (PC, Mac, whatever), and as a programmer you ought to know the capabilities of the computer language and the platform
C - you then use that language to write code that accomplishes that goal
It's not for nothing that it's called a "computer language".
You have a limited set of words you can use
and mathematical and logical equations
and you put them together in such a way
as to achieve your aim.
Very similar to what you do
when you put words together
to form a sentence that has the intended meaning.
it sounds like you have a poor programming class / teacher.
I didn't take "Programming Logic".
I took "Intro to Fortran", and afterward taught myself Pascal, Basic, C, C++, various assembly languages, various internet-related languages, database languages, etc.
It's a sort of puzzle
where you put the words of the programming language together in such a way
as to produce the results the project requires.