Questions tagged [programming-logic]
According to Wikipedia, Logic (from the Ancient Greek: λογική, logike)[1] has two meanings: first, it describes the use of valid reasoning in some activity; second, it names the normative study of reasoning or a branch thereof.[2][3] In the latter sense, it features most prominently in the subjects of philosophy, mathematics, and computer science.
60 questions
1
vote
2
answers
919
views
How can I code synchronous programs in Node?
I'm a career programmer, very comfortable writing programs in Python, and recently started learning Node.
I understand the asynchronous features are useful in many situations, but when I debug my code,...
-1
votes
1
answer
1k
views
Drawing UML Activity Diagram - Fetching data decision logic
I have a function to fetch data from remote API and store it in local database. Its logic is:
Is network available, if yes proceed to next step, if no show
error massage.
Is app launched for first ...
-2
votes
1
answer
818
views
Refactoring nested if-else interface method in Java8
I have the below default method in an interface and it seems to be pretty complex because of the many if-else conditions.
default void validate() {
Application application = application().get();
...
2
votes
1
answer
420
views
Design of dropdown lists to handle optional selection
Consider the following example in a CRUD application. A user can select their favourite food from a dropdown list ("Burgers", "Pies", "Chips"). This is an optional field i.e. not mandatory. Thus a ...
0
votes
1
answer
117
views
Logic circuit simulation: homebrew or third party solution?
Software I'm working on requires simulation of logic circuits, both combination and sequential.
Now the simulation doesn't need to be too detailed, in fact it could be detrimental to the function of ...
0
votes
3
answers
223
views
Do i need 2 tables to book entity?
I am developing a website to store books info such (title, book_no, author, edition, container...). I have two types of insert
insert series of books (Eg: harry porter series: chapter 1, 2,3...)
...
4
votes
2
answers
7k
views
Understanding LSB and MSB
In reference to one interface control document, I found difficulty in understanding this concept. There is one parameter having LSB of 0.0625 and MSB of 2048 that should be transmitted from one piece ...
12
votes
3
answers
3k
views
What is the best practice around De Morgan's Law [closed]
We all know De Morgan's Laws
!(a && b) === (!a || !b)
!(a || b) === (!a && !b)
Is there a community consensus around which one of these representations is easier to reason about (and ...
1
vote
2
answers
5k
views
share method logic along classes without inheriting from abstract class
In some languages (e.g. C#) a class can only ever have 1 base class which seems like a problem for what I'm trying to do. I will give you an example of what i'm trying to do, hopefully this will make ...
-2
votes
3
answers
437
views
What's a good way to extract what's needed programatically from business logic? [closed]
I'm new to programming and I've discovered something that causes me confusion and frustration: Translating business logic into actual code. I'm trying to develop a set of questions I can ask myself ...
1
vote
2
answers
662
views
Parallel vs Simple Assignment question
I'm quite new to Python and learning it on Lynda.com, which does not seem to have any way to ask questions about lesson content. In a video about while loops there is this code:
a, b = 0, 1
while b &...
2
votes
1
answer
2k
views
Sudoku Solver BackTracking vs Simulated Annealing
Before you read any further, assume you know what sudoku game and how to go about solving it.
So I have created a sudoku solver with brute-force:
The algorithm goes as
calculate(through an simple ...
1
vote
0
answers
662
views
Best way to structure a complicated web-based quiz [closed]
I have a web project that requires I build a quiz and am having some difficulty working out how to efficiently code it. I'd like to create some sort of json template system so that the quizzes can be ...
3
votes
2
answers
245
views
Refactoring wordy conditional tests [duplicate]
My first attempt at this question was too theoretical, so I've rewritten it with actual code. See the edit history if you care.
Supposing this logic, "suffering" from the arrow anti-pattern:
/**
* ...
-4
votes
2
answers
2k
views
How can I Identify which condition satisfied the if statement? [closed]
Suppose, I am using a if statement as such:
if(A || B || C || D)
{
echo "Hurrah! if is satisfied!";
echo "But! How can I know which was true of the 4 (A,B,C,D)";
}
Is there any way I can know ...
1
vote
1
answer
104
views
Efficient ordering of objects online
I have a list with objects stored in a database. These objects are shown in a list and the user can drag and drop them to order them in a specific way. I want that specific order to be stored.
How ...
36
votes
14
answers
9k
views
How to define "or" logically
Recently, I came across a problem that required me to define the logical "OR" operator programmatically, but without using the operator itself.
What I came up with is this:
OR(arg1, arg2)
if arg1 = ...
1
vote
3
answers
523
views
Are functional languages a kind of program derivation?
Program derivation is defined as the derivation of a program from it's specifications. Usually this specification language is some form of propositional logic, but from what I understand, it need not ...
1
vote
2
answers
1k
views
Making server logic independent of client interaction
I'm trying to make a realtime multiplayer web-game in node.js with express framework and socket.io library.
But I can't seem to make my server-side logic independent of client interactions.
I want ...
8
votes
3
answers
10k
views
Ordering if conditions for efficiency and clean code [closed]
This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am ...
5
votes
4
answers
1k
views
Finding an object on an infinite line
Question:
There is an infinite line. You are standing at a particular point you can either move 1 step forward or 1 step backward. You have to search for an object in that infinite line. Your object ...
0
votes
1
answer
826
views
Good Data Structure book to improve programming logic for children [closed]
My cousin (Age 10) who studies in Standard 5. He wants to learn programming and programming logic.
Which book or resources should I refer? Is there any Good Data Structure book to improve ...
3
votes
2
answers
717
views
How to unit test code which is intended to have different results on different platforms
I noticed some duplicate code in a codebase I am working on that appended a filename to a directory path, so I decided to refactor it into its own method. The application I am working on is not well ...
3
votes
1
answer
393
views
Best Traversing Strategy / Logic Help Needed
Background: Here is the scenario, imagine I have a little Robot. I give this robot a Map, and I want him to traverse the map, after doing so, I want the Robot to tell me the shortest possible path on ...
-2
votes
3
answers
386
views
Should I use AND or should I use OR [closed]
An order can be in the "status" of Completed, Corrected or some other status.
I saw some code that is checking it like this, the purpose is to disable some stuff when the status is in Completed or ...