procedural-programming

Does procedural programming have any advantages over OOP?

醉酒当歌 提交于 2019-12-02 16:12:48
[Edit:] Earlier I asked this as a perhaps poorly-framed question about when to use OOP versus when to use procedural programming - some responses implied I was asking for help understanding OOP. On the contrary, I have used OOP a lot but want to know when to use a procedural approach. Judging by the responses, I take it that there is a fairly strong consensus that OOP is usually a better all-round approach but that a procedural language should be used if the OOP architecture will not provide any reuse benefits in the long term. However my experience as a Java programmer has been otherwise. I

Does function definition order matter?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 15:38:40
In the script below, does the order in which items are declared matter? For example, if the add_action points to a function that has not yet been defined? Does it matter or should the function declaration always precede any code in which its called? add_action('load-categories.php', 'my_admin_init'); function my_admin_init(){ //do something } Shakti Singh That doesn't matter if the function is declared before or after the call but the function should be there in the script and should be loaded in. This is the first method and it will work: some_func($a,$b); function some_func($a,$b) { echo

Does function definition order matter?

北慕城南 提交于 2019-12-01 13:43:00
问题 In the script below, does the order in which items are declared matter? For example, if the add_action points to a function that has not yet been defined? Does it matter or should the function declaration always precede any code in which its called? add_action('load-categories.php', 'my_admin_init'); function my_admin_init(){ //do something } 回答1: That doesn't matter if the function is declared before or after the call but the function should be there in the script and should be loaded in.

What is Method, Property and Function?

拜拜、爱过 提交于 2019-11-30 20:18:58
Yeah, I'm struggling with that. I cannot distinguish among them because every explanation I read is so unclear and philosophical enough. Can someone clear up these definitions for me ? Thanks guys. These definitions apply as much to procedural-programming as oop ? Thanks. Function is a combination of instructions coupled together to achieve some result. It may take arguments and return result. If a function doesn't return a result it is usually called a procedure. Examples: function drawLine(x1, y1, x2, y2): // draws a line using Bresenham's algorithm from x1,y1 to x2,y2. // doesn't return

What's the difference between a procedural program and an object oriented program? [closed]

烈酒焚心 提交于 2019-11-30 10:20:17
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I'm fairly new to programming but I've been reading some interesting discussions on StackOverflow about various programming approaches. I'm still not 100% clear on what the difference is between procedural programming and object oriented programming. It sounds like object oriented

How do i get out of the habit of procedural programming and into object oriented programming?

隐身守侯 提交于 2019-11-29 20:50:52
I'm hoping to get some tips to kinda help me break out of what i consider after all these years a bad habit of procedural programming. Every time i attempt to do a project in OOP i end up eventually reverting to procedural. I guess i'm not completely convinced with OOP (even though i think i've heard everything good about it!). So i guess any good practical examples of common programming tasks that i often carry out such as user authentication/management, data parsing, CMS/Blogging/eComs are the kinda of things i do often, yet i haven't been able to get my head around how to do them in OOP and

Truly understanding the difference between procedural and functional

a 夏天 提交于 2019-11-29 18:34:29
I'm really having a hard time understanding the difference between procedural and functional programming paradigms. Here are the first two paragraphs from the Wikipedia entry on functional programming : In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in lambda calculus, a formal system developed in the 1930s

What is the difference between declarative and procedural programming paradigms?

巧了我就是萌 提交于 2019-11-28 15:10:36
What is the difference between the declarative and procedural programming paradigms? Could you please provide some examples? What other programming paradigms exist? DigitalRoss Imperative There are several sub-paradigms of the imperative programming paradigm, such as the procedural or the object-oriented programming paradigms. In the imperative programming paradigm, you describe the algorithm step-by-step, at various degrees of abstraction. Examples of programming languages which support the procedural paradigm: C (and most other legacy languages) PHP, mostly In some sense, all major languages

Are side effects a good thing?

前提是你 提交于 2019-11-28 05:49:53
I feel the term rather pejorative. Hence, I am flabbergasted by the two sentences in Wikipedia: Imperative programming is known for employing side effects to make programs function. Functional programming in turn is known for its minimization of side effects. [1] Since I am somewhat Math-biased, the latter sounds excellent. What are the arguments for side-effects? Do they mean the loss of control or the acceptance of uncertainty? Are they a good thing? Every so often I see a question on SO which forces me to spend half an hour editing a really bad Wikipedia article. The article is now only

Why is object oriented PHP with mysqli better than the procedural approach? [closed]

梦想与她 提交于 2019-11-27 13:08:38
I have been using the procedural approach with mysql* until recently. Now I want to shift to mysqli and object oriented approach. Many online resources and books state that OOP is better than procedural even in case of PHP. After going through some online tutorials, I have written a small program that connects to the database and selects a value. I want to know why the object oriented approach is better? Plus is this the right way to code an OO php web page? The object oriented approach $host = "localhost"; $username = "root"; $password = ""; $dbname = "compdb"; @ $db = new mysqli($host,