-1

I'm programming a telegram bot with Python and, for a number of reasons, there are no classes in the whole project, just several functions correlated to the the file where they are located. E.g., my parse() method is defined inside a parser.py file.

If I'm not structuring the project in terms of classes and objects and states and attributes, then what paradigm is this? None?

8

The programming paradigm that organizes the software into functions is called procedural programming. For example, C is a procedural programming language. Most dynamic languages like JS or Python can be used in a procedural style.

While you are also organizing your code into separate files, there is no commonly used name that describes this. For example, modular programming is more about encapsulation than about using multiple files.

It is perfectly fine if you aren't writing classes. OOP is nice but is not always a good fit. For many problems, a procedural approach is great.

Further Reading
Procedural programming

  • You can use OOP languages in a procedural way too, especially if the language contains "free" functions. using static in C# – Robert Harvey Jun 11 at 14:23
  • At the moment, your answer is plain wrong. "organiz[ing] the software into functions" is also what happens in functional languages. So without knowing more about the structure of the OP's code, there is no way to know for sure whether they are using a procedural or functional approach. – David Arno Jun 11 at 16:28
  • @DavidArno No. The terms procedures/subroutines/methods/functions are used interchangeably by most programmers. While they do have distinct meanings (functions are mappings, procedures produce side effects, methods belong to objects), most languages use a single term for all meanings so that in C or Python the term “function” also describes “procedures”. Functional programming is more than using functions and typically describes (a) a certain declarative approach, or (b) a programming style using higher-order functions. It would be rare for FP to happen by accident. – amon Jun 11 at 16:36
  • You have no idea whether the OP is using a declarative or imperative style and thus you have no way of knowing whether they are using a functional or procedural paradigm. But regardless of that, the statement "The programming paradigm that organizes the software into functions is called procedural programming" is false as there are two programming paradigms that organise software into functions: functional and procedural. It's likely that you have guessed correctly with regard to the style used by the OP, but your opening sentence remains wrong. – David Arno Jun 11 at 16:41
  • @DavidArno We could have a long conversation about the history of programming paradigms, but the TL;DR is that paradigms are somewhat vague and overlapping. E.g. Lisp is procedural-functional-imperative, Haskell is functional-declarative (not procedural!), C# and Python are imperative-procedural-OO-functional. While structured, procedural, modular, and class based OO programming are all about organizing code to some degree, other paradigms like functional, imperative, declarative, or actor programming are more about a style of problem solving. I stand by my opening sentence. – amon Jun 11 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.