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
1vote
2answers
629views
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,...
3votes
3answers
484views
Is there an approach to keep a large number of conditionals maintainable
I work on a survey that has a lot of questions. This means we have a lot of columns/variables to work with. This translates to a lot of conditionals that have to be done a certain way according to a ...
-1votes
1answer
921views
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 ...
1vote
1answer
151views
Ranking results from a Question and Answer game
I have a question and answer trivia game app which randomly picks questions from a database and prompts the user to answer the question correctly. The total number of correct answers, the total number ...
-2votes
1answer
796views
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(); ...
-3votes
2answers
117views
Is there a better way to write the logic for handling "close plus open" and "partially close" trades?
I am writing a paper trading system, and what I have works, but I can't help but feel that there's a better way to partially close a stock position; what I currently have seems a little overboard. ...
2votes
1answer
386views
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 ...
6votes
2answers
2kviews
What is the logic in the order of operator precedence? [closed]
Absolutely academic context question- I found countless articles listing the order of operator precedence in all languages, but what is the logical reasoning behind that specific order? For clarity ...
0votes
1answer
97views
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 ...
66votes
16answers
16kviews
How to avoid logical mistakes in code, when TDD didn't help?
I was recently writing a small piece of code which would indicate in a human-friendly way how old an event is. For instance, it could indicate that the event happened “Three weeks ago” or “A month ago”...
0votes
3answers
211views
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...) ...
1vote
1answer
197views
Passing 0's (literals) to a constructor
I have a function that creates a new object by passing to it's constructor integer ids primarily with values of 0. This function is called when saving a newly created record (not an edit). public ...
4votes
2answers
7kviews
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 ...
3votes
3answers
791views
Is there a way to have four possible outcomes without repeating the two conditions? [duplicate]
In a generic sense, my question goes something like this: if (p) { if (q) { a(); } else { b(); } } else { if (q) { c(); } else { d(); } } There ...
12votes
3answers
3kviews
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 ...