Skip to main content

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.

Filter by
Sorted by
Tagged with
1 vote
2 answers
926 views

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,...
SupaCowaFraja's user avatar
3 votes
3 answers
574 views

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 ...
SunflowerLuau's user avatar
-1 votes
1 answer
1k views

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 ...
Abdelaziz Faki's user avatar
1 vote
1 answer
161 views

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 ...
user1527613's user avatar
-2 votes
1 answer
818 views

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(); ...
AnOldSoul's user avatar
  • 173
-3 votes
2 answers
130 views

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. ...
Taco's user avatar
  • 1,175
2 votes
1 answer
421 views

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 ...
Aveer28's user avatar
  • 131
6 votes
2 answers
2k views

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 ...
Benson's user avatar
  • 79
0 votes
1 answer
117 views

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 ...
user1561358's user avatar
66 votes
16 answers
16k views

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”...
Arseni Mourzenko's user avatar
0 votes
3 answers
223 views

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...) ...
Sam's user avatar
  • 113
1 vote
1 answer
221 views

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 ...
samus's user avatar
  • 475
4 votes
2 answers
7k views

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 ...
Master shifu's user avatar
3 votes
3 answers
828 views

In a generic sense, my question goes something like this: if (p) { if (q) { a(); } else { b(); } } else { if (q) { c(); } else { d(); } } There ...
Kyle Delaney's user avatar
12 votes
3 answers
3k views

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 ...
Abraham P's user avatar
  • 289
1 vote
3 answers
325 views

Apparently, for some built-in type of C++, the following does not hold: a==b || a!=b Which type/value is it? The question is originally from this video: https://www.youtube.com/watch?v=etZgaSjzqlU&...
vetijo's user avatar
  • 41
1 vote
2 answers
6k views

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 ...
Vincent's user avatar
  • 383
0 votes
1 answer
3k views

I'm new to programming and I'm trying to develop a template of questions I can apply to business rules that will help me extract what's needed to begin coding. Do programmers have a set of ...
JM1's user avatar
  • 109
-2 votes
3 answers
437 views

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 ...
JM1's user avatar
  • 109
1 vote
1 answer
1k views

Given a list of transactions like: A -> 10 to B B -> 10 to C The naive way to settle the transaction would be: C owes 10 to B B owes 10 to A But the same transaction could be settled by: C ...
CodeYogi's user avatar
  • 2,186
1 vote
2 answers
662 views

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 &...
Daniel Cardenas's user avatar
0 votes
2 answers
291 views

Currently um working in an application and it has the following hierarchy WEB API2 Controllers (hilds the end points) Business Logic Layer (Dedicated for business logic handling ) Data Access Layer ...
Kalanamith's user avatar
2 votes
1 answer
2k views

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 ...
j4rey's user avatar
  • 121
54 votes
6 answers
14k views

I'm a student of systems engineering, and all my teachers and friends (that actually work in the area) say that it is better to have as much logic as possible implemented in the database (queries, ...
Larizza Tueros's user avatar
1 vote
0 answers
662 views

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 ...
user2424495's user avatar
2 votes
2 answers
822 views

I have been stuck at a requirement for way too long too handle it :(. Our company is having increased number of customers who wants to upgrade or downgrade their subscription. For now, the ...
Ange1's user avatar
  • 123
3 votes
2 answers
245 views

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: /** * ...
bishop's user avatar
  • 730
5 votes
1 answer
2k views

I'm programming a process in which clients will be separated in 3 different groups, and for every group a different action will be performed. My question concerns the process of deciding which client ...
Michel's user avatar
  • 971
-4 votes
2 answers
2k views

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 ...
radiopassive's user avatar
0 votes
1 answer
776 views

I am a relatively new programmer. I can pick up languages and learn syntax at a speed that I consider good, but I can't figure out how to solve problems logically using algorithms very well. I know ...
jklsfdgs's user avatar
1 vote
1 answer
104 views

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 ...
Mathijs's user avatar
  • 123
0 votes
1 answer
784 views

Suppose I have the following matrix with values 1-25 as input to my program. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 The inward spiral should give me the output 13 ...
GermanShepherd's user avatar
36 votes
14 answers
9k views

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 = ...
logicNoob's user avatar
  • 511
1 vote
2 answers
3k views

Given the number 15 and the array [1, 2, 3, 4, 5, 6] Possible combinations (sum=15) would be: [1, 2, 3, 4, 5] [2, 3, 4, 6] [1, 3, 5, 6] [4, 5, 6] Their respective sum of squares would be: 55, 65, 71 ...
Vinayak's user avatar
  • 113
1 vote
3 answers
524 views

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 ...
Nathan BeDell's user avatar
5 votes
1 answer
971 views

According to DDD-principles I use factory-methods to create consistent objects and to ensure that the objects are in the right state. Now I'm in doubt about inner logic of setter methods. I'm tied up ...
shylynx's user avatar
  • 2,134
1 vote
2 answers
1k views

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 ...
laggingreflex's user avatar
3 votes
2 answers
1k views

We are currently working on a project that heavily relies on a database. Among many tables the main focus is on table "data" which is linked to another table "data_type" as many-to-one, which is then ...
Tez's user avatar
  • 33
8 votes
3 answers
10k views

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 ...
user avatar
0 votes
1 answer
845 views

I understand that 0 is false because math established that a long time ago and C established it in the programming world, as talked about here. However, other than following established conventions, ...
dallin's user avatar
  • 412
5 votes
4 answers
1k views

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 ...
Chander Shivdasani's user avatar
11 votes
2 answers
17k views

Preamble My aim is to create reusable code for multiple projects (and also publish it on github) to manage subscriptions. I know about stripe and recurring billing providers, but that's not what this ...
pdu's user avatar
  • 579
0 votes
1 answer
826 views

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 ...
Md Mahbubur Rahman's user avatar
-1 votes
2 answers
599 views

I am wondering if it is reasonable to write closed source, paid web apps in Javascript (JS MVC Frameworks like AngularJS, Backbone, Knockout, ...)? I'm concerned because in this type of frameworks you ...
Robert Niestroj's user avatar
3 votes
2 answers
719 views

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 ...
Kazark's user avatar
  • 1,820
3 votes
1 answer
74k views

I'm having difficulties understanding whether or not this is the right process to use for a flow chart which illustrates the processes involved in an algorithm. For this, assume the following: A 1D ...
Phorce's user avatar
  • 209
3 votes
1 answer
393 views

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 ...
J86's user avatar
  • 297
7 votes
1 answer
788 views

In a Drupal programming guide, I noticed this sentence: The theme hook receives the total number of votes and the number of votes for just that item, but the template wants to display a percentage. ...
Timwi's user avatar
  • 4,459
-2 votes
3 answers
386 views

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 ...
Blake's user avatar
  • 839
5 votes
3 answers
1k views

First off, sorry if this is answered somewhere else. I did a brief search, but wasn't sure how to ask in search terms. I'm looking at some code and came across lot's of statements like this: if ( ($...
user127379's user avatar