How to divide a program into functions?

Asked

Viewed 75 times

1

How to divide the code into functions in the imperative paradigm? Depends on the type (procedural, modular, OOP)? Is it broad to ask this, even if only for one of these subparadigmas? Is there any reference material? There are good... I mean, recommendations?

Specific recommendations:

  • The statement below (taken from here) is true?

Backus asserted that the Von Neumann Architecture and its Associated Imperative Languages are fundamentally flawed, and presented a Functional-level Programming language (FP) as a Solution.

  • I’m analyzing if the question has the problems it cites, I haven’t seen everything :D The final paragraph I don’t know if it has to do with or just isn’t clear the relationship with the rest. I think I can give an answer, but one that I don’t say categorically because the subject isn’t simple, so I hope I don’t have naive answers that cite the popular concept that might not be quite right. The quote even I can dispute the merit, I do not know if the content is more complicated. The "how to divide" for broad yes. I understand the intention, but this washes to something very open.

  • The relation of the final paragraph to the rest in my understanding would be that working with less specific types affects the design of the functions and therefore the way to divide the program into them. Whatever you can save in question is worth.

  • Just follow the principle of the single answer. A function must do one, and only one, thing well done. Everything else is a consequence.

  • What I think is hard in this question is to know what "divide into functions" is, because the body has some interesting things. I’m thinking about starting to answer, but the problem is it would be almost interactive because it’s still confusing. In a way the answer to the title is what @Andersoncarloswoss said. Is it vague? Yes. That’s why I often find it best to show something and see if it hurts the SRP to begin to understand this. And almost falls into opinion because each person can have a different criterion. I question one of the most SRP-speaking sources in the world that forces you to write too much code for an ideal

  • I have no examples. I agree that "dividing into functions" is vague, depends on context and makes the question broad, just as respecting the SRP is vague. I am starting from the premise that dividing into functions is a well-known science and goes beyond simply "following the SRP" (unless this is a very old and traditional rule), so I ask what there may be of reference material, as for example something along those lines or even that one.

  • It’s not, that’s the problem, it’s so vague almost everything you teach in writing. Apart from orthography, grammar, these more objective things, the style takes place in a subjective way. It has a certain objectivity in the subjective, but it is still subjective. You give general lines that are a little vague. When we talk about language we are talking about expression, no matter what kind of language. It has styles and styles. There are general rules to follow, but specific rules are difficult. You can even make a collection of examples, but this is very broad. So doing and asking can be much more specific.

  • I get it, I’ll try to improve the question.

  • Seeing some links you posted, I wonder if what you want to know is how to divide or if it is something else :) In fact it depends on the paradigm there are different criteria to follow, but it has nothing to do with dividing.

  • You ask that because of the link asking how to break down into modules, right? But this you already answered in my question about modular programming, the doubt is about splitting, breaking into even functions. And the link about SADT is the question of whether there is a method to proceed with this division. I realize that the links don’t have much cohesion, they’re kind of random, but the general intention is the title of the question. It would be like breaking a module into functions, but I think it bumps into how to divide into modules. I can’t explain it better, it lacks an example.

  • In fact as a module can be a function as well and as my greatest disability is in designing functions (dividing is being used as a synonym for designing, modularizing), the doubt lies on how to design functions in procedural programming, which leads to how to design modules and a complete program. I must study Structured Analysis?

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.