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 ...

learn more… | top users | synonyms

30
votes
12answers
5k 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 ...
0
votes
0answers
41 views

Rewrite Engine vs Boostrap type index file

I currently use apache mod rewrite on a site to redirect various queries / visitors such as this: if you come to example.com/authors/, you are redirected to authors.php if you come to ...
1
vote
2answers
167 views

Given a number X, how do I find from an array of numbers, a unique combination that adds up to X and has the lowest sum of squares?

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 ...
1
vote
3answers
139 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
1answer
95 views

How to guarantee invariants / Inner logic in setter methods

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 ...
0
votes
2answers
207 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 ...
2
votes
2answers
228 views

Implementing bussiness logic with a large number of business rules and processes

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 ...
3
votes
3answers
959 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 ...
0
votes
1answer
326 views

Is there any reason zero should still equal false in a new programming language? [duplicate]

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, ...
3
votes
3answers
557 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 ...
6
votes
2answers
2k views

Handling subscriptions, balances and pricing plan changes

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 ...
0
votes
1answer
347 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 ...
-2
votes
2answers
406 views

Is it reasonable to use Javascript MVC Frameworks for closed source paid web applications?

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 ...
2
votes
2answers
285 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 ...
2
votes
1answer
22k views

Flow Chart - While Loops process

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 ...
3
votes
1answer
250 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 ...
6
votes
1answer
248 views

Is the separation of program logic and presentation layer going too far?

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 ...
-2
votes
3answers
304 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 ...
4
votes
3answers
651 views

Is saying “if ( $a != null && $a == 5)” the same as “if ($a == 5)”

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 ( ...
10
votes
7answers
1k views

Programming knowledge vs. programming logic

Is there any difference between the two topics? I have seen companies asking for Good Programming knowledge some Good Programming logic. I have seen this in Job profiles for a developer – for e.g. ...
-1
votes
4answers
2k views

How to improve my loop logic in programming?

I know how to do simple loops but I don't know what's going on when many loops are working together. For example: for (i=0; i <= 9; i++){ document.write(linebreak); for (m=0; m <= 9; ...
-5
votes
8answers
524 views

Why aren't postfix and primary expressions symmetrical?

Every primary expression is a postfix expression but a postfix expression is not primary expression. But in mathematics, equality seems to be symmetrical. That is: If A is B, then B is A Why ...
0
votes
5answers
253 views

ternary or something similar for choosing function?

I posted this question on stackoverflow and it got a poor reception. In reality, the problems I'm facing are minor and any workaround can be considered impractical. However, I believe it might be of ...
4
votes
8answers
741 views

How do you decide between putting the code in the database or putting the code in the application? [closed]

For the sake of argument: Let's assume the application we are building is an amortization schedule. Let's also assume that the database has a table called tblAmortizationPayments that stores the ...
21
votes
15answers
8k views

Arguments for or against using Try/Catch as logical operators [closed]

I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators. Meaning, "do some code, if that throws this error, do this code, but if that throws this error ...
18
votes
6answers
2k views

How to turn truth table into smallest possible if / else block

How can I take a truth table and turn it into a compacted if block? For instance, let's say I have this truth table where A and B are conditions and x, y and z are possible actions: A B | x y z ...
11
votes
5answers
8k views

When is it appropriate to use a bitwise operator in a conditional expression?

First, some background: I am an IT teacher-in-training and I'm trying to introduce the boolean operators of java to my 10th grade class. My teacher-mentor looked over a worksheet I prepared and ...
26
votes
8answers
9k views

What do you do to improve your logical programming skills? [duplicate]

Do you think that only the programming pratice will help you to improve your logical programming skill or do you train your brain with puzzle games, trying imagine how universe works, playing ...