Questions tagged [paradigms]
A tag for questions relating to the world view underlying a particular software methodology or theory.
292
questions
0
votes
1
answer
49
views
Storing car part data in a database
I want to understand if it is possible to store car part data using the Neo4J database paradigm. I'm open to anything, so if something better suits, please suggest how.
For example:
A car has a VIN, ...
0
votes
0
answers
9
views
Static-scope-What is the output?
I'm strugling to understand what is the output of following code (STATIC SCOPE):
program Test:
var a: integer;
procedure Add(a:integer);
begin a:= a+1; end;
procedure Print;
begin a:= a+2; write(a); ...
0
votes
1
answer
31
views
What is the difference between abstraction and declarative programming?
Declarative programming seems to be achievable through abstraction. So what's the difference between abstraction and declarative programming?
[ My thought ]
I will call the person using the class &...
0
votes
1
answer
41
views
Why is mongoDB a database server?
I've recently begun learning mongoDB and came across the phrase "mongoDb is a database server."
There was no explanation, and I'm a little confused because servers simply host resources and ...
0
votes
1
answer
31
views
Can I inject the same dependency into multiple objects of the same type?
I am refactoring some code to use DI, and I set it up like this:
class ListOfFoo
{
public List<A> fooList;
private readonly IFooRepository fooRepository;
public int id;
public void ...
0
votes
0
answers
45
views
Coordinate Compression and how to implemente it?
so i came across this https://usaco.guide/silver/sorting-custom?lang=cpp#coordinate-compression in usaco guide explaining coordinate compression and i didn't understand it really , and there is not ...
1
vote
0
answers
35
views
language for data-driven programming
I'm wondering if there is a language that supports programming in the following style that I think of as "data driven":
Imagine a language like C or Python except that it's possible to ...
0
votes
1
answer
60
views
Scheme function for adding elements in nested list [duplicate]
I'm trying to create a scheme program that adds the elements of a given list (both simple and nested).
(define (adder a_list)
(cond
((null? a_list) 0)
((list? (car a_list))(adder (car ...
0
votes
1
answer
190
views
How to avoid code repetition in rust (in struct, and traits)?
This is the Trait example from the rust by example book
struct Sheep { naked: bool, noise: &'static str }
trait Animal {
// Associated function signature; `Self` refers to the implementor ...
0
votes
1
answer
39
views
Should I use a global variable or is there any other option in this example?
I have a question regarding the use of global variable. I have a situation something like this: I have to loop through forest and then through hives to find the bee and then the bee should deposit ...
0
votes
0
answers
24
views
Does event-driven paradigm has access modifiers?
According to the knowledge I have;
The procedural paradigm has no access modifiers.
The object-oriented paradigm has access modifiers public, protected, default, and public.
Does the event-driven ...
0
votes
1
answer
152
views
Alternative to OOP in Julia
I'm trying to learn a bit of Julia, so i'm writing some small projects in the language.
I'd like to write, for example, a simple Perceptron in Julia, but it is not object oriented, so i can't create a ...
1
vote
1
answer
358
views
Incrementing a counter with functional programming vs imperative programming
I likely am asking a very stupid question here, please forgive me.
I am a Java and C# backend-engineer with relatively good knowledge of OOP design patterns. I have recently discovered the debate ...
1
vote
1
answer
291
views
Practical Advantages and Disadvantages of Answer Set Programming/Logic Programming
I've recently taken an interest in Logic Programming, and more specifically Answer-Set Programming with CLINGO, and was wondering what the general consensus on this paradigm is in practical terms. For ...
1
vote
1
answer
47
views
How to express recursive calls in higher dimensions
Just a question of curiosity, not serious.
In the JS language I know that a factorial operation can be defined in the following form.
function factorial(n) {
if (n === 1) return 1;
return ...
2
votes
1
answer
64
views
What is the output when you use shallow binding?
x : integer := 3 //global scope
y : integer := 4 //global scope
procedure add
x := x + y
procedure second(P : procedure)
x : integer := 5
P()
procedure first
...
2
votes
2
answers
326
views
Generics of Generic types
I am about to start learning Rust after programming in C++. I am unsure how to create a function (or anything else generic) that takes a generic type as its template argument.
I have tried to compile ...
6
votes
1
answer
200
views
Something like Haskell's MultiParamTypeClasses
I am about to start learning Rust after programming in Haskell.
The trait Keyword interested me however I noticed you can only refer to one type (Self).
In Haskell there is a pragma for this behaviour:...
4
votes
1
answer
589
views
How to program shared behaviors in Rust without repeating same code in each module?
For writing a very large program, I see no way to alleviate having to write the same code for each struct that uses a certain shared behaviour.
For example, Dog may "bark":
struct Dog {
...
-1
votes
1
answer
58
views
Making a Racket function that applies to lists
How to apply a function to a list in the racket?
-1
votes
2
answers
95
views
I need to make a function in Racket that removes elements similar to each other from the list
I need to create a function in Racket, but I found the examples a little confusing. I need to create a function that removes the elements similar to each other from the list. You can pass a function ...
1
vote
1
answer
177
views
Python: Make program react to keywords in a string without endless if-else nightmare
So, the real world context for this is a chatbot I'm working on, but here is a condensed version of what I'm trying to accomplish.
The function is supposed to take a message, look if it contains ...
0
votes
1
answer
57
views
Getting functional method name in Java
I have run into an issue with functional programming since I want to be able to get the method name, but it's not so easy to do as it is with OOP. It makes my code very clean to stay in functional ...
1
vote
2
answers
84
views
Swift Multiple Inheritance. I am trying to recreate this Java Code in Swift related to Multiple Inheritance
public class Shape {
public static void main (String[] args) {
Circle c = new Circle(5);
System.out.println (c.getArea());
c.setColour("Green");
...
1
vote
1
answer
71
views
How do the different concurrency paradigms compare?
There are different concurrency paradigms:
Promises and Futures
Actors and Tasks
Async/Await
maybe more, can’t find definitive list
To my untrained eyes, these all do the same thing. If they are all ...
3
votes
0
answers
107
views
How can I check if an algorithmic paradigm can solve a certain type of problem or can not? [closed]
Well, I know that algorithmic paradigms are the templates to create algorithms to solve certain type of computational problems. (correct me if I am wrong) But what I don't understand is, "How do ...
0
votes
0
answers
19
views
What is the name of the relation that the attribute have to the class that contains it?
Theoreticaly speaking, if class A has an atribute B, B is an attribute of A, but A is what of B?
1
vote
1
answer
203
views
Algorithmic Paradigm of the Insertion Sort
Recently I started studying sorting algorithms again and I was wondering which algorithmic paradigm category would better describe the insertion sort. I have researched the web to link the insertion ...
2
votes
4
answers
66
views
Refactor from Procedural Paradigm to Functional Paradigm
In the process of learning functional programming, I am trying to refactor the following code using map, filter, and/or reduce.
I see that I can deal with the conditional using the filter method, ...
0
votes
0
answers
89
views
Is there a Programming Concept of Additive/Supplemental ForEach?
My question contains 2 subquestions, therefore it is not limited to java but takes programming paradigms in general into consideration.
I need a Loop which does a usual "forEach" but also provides ...
2
votes
0
answers
18
views
Objects into functions
I have a question that my teacher asked me and I could not find the answer, I am still searching in pdf for public institutions how mit (which are public), utn or related, if anyone can answer me or ...
0
votes
0
answers
31
views
different between "&" and "and" in expressions [duplicate]
I have this question and I'm really confused !
What different between "&" and "and" in expressions ?
and how can I compute the result of of (and, &) operations, should I convert the numbers to ...
1
vote
0
answers
172
views
ECS System implementation, why iterate on registered entities instead of the continuous component array
A lot of the documentations i had read on the ecs system implementation seem to have a dynamic array that register the entities that the system want to interact with.
It's true that it's allow you to ...
0
votes
1
answer
342
views
How to avoid if-else multiple checks (spaghetti code) in typescript
General question: How to avoid if-else ugly code when you have to deal with multiple checks based on some string type?
Example: I have an object "Task" in TODO app, which can be of different types, ...
0
votes
0
answers
33
views
Is there a name for the programming paradigm jQuery suggests? [duplicate]
I have written little code with jQuery. The one thing I first noticed is that it “reverses” the logic between “caller” and “action”. What I mean by that is instead of having an html button which ...
2
votes
2
answers
4k
views
What is the difference between object oriented programming and procedural programming? [closed]
From what I can gather procedural programming uses procedures and functions or sub routines. It gives a step by step instruction on what to do. Though object oriented on the other hand im not entirely ...
5
votes
1
answer
1k
views
Is Fortran a purely functional language?
I understand that some languages combine elements for many different paradigms in programming. I'm told that Fortran is an example of a Functional language, however I'm just a little confused as to ...
19
votes
1
answer
3k
views
What is the rationale behind allowing variable shadowing in Rust? [closed]
In Rust it is encouraged to shadow variables:
But wait, doesn’t the program already have a variable named guess? It
does, but Rust allows us to shadow the previous value of guess with a
new one....
0
votes
2
answers
606
views
How to work with labels in mozart oz to get the elements from pair/tuple?
I'm new to mozart oz and I have this problems to solve:
a) Implement a function Zip that takes a pair Xs#Ys of two lists Xs and Ys (of the
same length) and returns a pairlist, where the first ...
-3
votes
1
answer
207
views
What does Robert Martin mean by “Only function survive from early programming days, not routine” [closed]
Excerpt from book Clean Code authored by Robert Martin:
In the early days of programming we composed our systems of routines
and subroutines. Then, in the era of Fortran and PL/1 we composed our
...
0
votes
1
answer
87
views
How to include a cpp in another cpp like copy-paste rather than declaration-wise?
I recently adopted a style where I try to avoid unnecesary classes / scopes, so the code cannot be splitted in files by classes or functions, since almost everything happens in main. Of course for a ...
0
votes
0
answers
190
views
Correct way of operating on exact numbers in CGAL
Consider the following minimal example:
#include <stdlib.h>
#include "CGAL\Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
...
2
votes
2
answers
494
views
Whose resposibility should it be to check preconditions?
In procedural languages where functions are a key player, the design by contract paradigm basically says that there is an agreement between a function that takes parameters and the caller.
The ...
3
votes
1
answer
174
views
Why is OOP juxaposed with Procedural Programming?
From what I understand, procedural programming is a programming paradigm whereby the state of the program is determined by procedures that handle the flow of data, such as subroutines and data-fed ...
0
votes
1
answer
199
views
What should a purely object-oriented language look like to be "widely" used? [closed]
The most object-oriented language I know is Smalltalk. Its unique feature compared to other languages is to define everything as an object.
However (if we don't take into account historical events), ...
0
votes
2
answers
205
views
Create parent/child relationship in class
I have two classes, a child class:
type MyChildClass = class
public
parent: ^MyParent;
end;
And a parent class:
type MyParentClass = class
public
childs: array of ^MyChildClass;
end;
However, this ...
0
votes
1
answer
221
views
Link between models of computation, computer system architectures and programming paradigms
I have been reading about these topics for a while and may have understood something. But I am confused with some connections:
i. Turing Machine (RAM model to be exact) & Imperative Programming
...
0
votes
1
answer
102
views
A bady-written Scala code. How would look a well-written one? (playing with programming paradigms and techniques)
I am a Scala newbie. The following code is my extension of the first lesson from "Functional Programming Principles in Scala" course by professor Martin Odersky from the first lesson about Rationals "...
1
vote
2
answers
487
views
Leaving recursive functions running forever?
I came across a function where it had a setTimeout inside with a timeout growing exponentially (timeout *= 2).
let timeout = 10000
function foo() {
// doSomething without breaking, returning
...
1
vote
4
answers
4k
views
Functions declared and defined in a .c file
As I was going through a huge source code, I came across some files where there is only one function declared in, let's say, "code.h" but in "code.c" there are many functions declared and defined.
...