Questions tagged [logic]

50 questions
110
votes
8 answers

Why is polling accepted in web programming?

I am currently working on a Ruby on Rails project which shows a list of images. A must-have for this project is that it shows new posts in realtime without the need of refreshing the web page. After searching for a while, I've stumbled upon some…
dennis
  • 1,169
  • 3
  • 9
  • 8
21
votes
8 answers

Techniques to increase logic at programming

I am into programming since last 3 years. But I seems to be lost in it. I am not able to get good at it even though I code everyday. suppose I solve one problem, I will wander from solution to solution and implement some other solution. I cant focus…
unk1102
  • 646
  • 1
  • 4
  • 11
16
votes
3 answers

How to unit test method that returns a collection while avoiding logic in the test

I am test-driving a method that is to generate a collection of data objects. I want to verify that the properties of the objects are being set correctly. Some of the properties will be set to the same thing; others will be set to a value which is…
Kazark
  • 1,810
  • 1
  • 17
  • 37
9
votes
5 answers

Why is there both a short-circuit OR as well as unshort-circuited variation of that operator in C#?

Periodically, I wonder about this: The short-circuit OR would always return the same value that the unshort-circuited OR operator would? I expect that the short-circuit OR would always evaluate more quickly. So, was the unshort-circuited OR…
Phil C
  • 1,956
  • 1
  • 18
  • 34
8
votes
2 answers

Is it common practice to transform requirement specifications into predicate logic for functional programming?

I've recently been assigned to work on a small project which is being implemented in Haskell. Coming from an OO/imperative background, I'm used to converting requirements/user-stories into use-cases and sequence diagram prior to coding. However,…
PhD
  • 2,531
  • 2
  • 18
  • 32
8
votes
5 answers

In retrospect, has it been a good idea to use three-valued logic for SQL NULL comparisons?

In SQL, NULL means "unknown value". Thus, every comparison with NULL yields NULL (unknown) rather than TRUE or FALSE. From a conceptional point of view, this three-valued logic makes sense. From a practical point of view, every learner of SQL has,…
Heinzi
  • 9,646
  • 3
  • 46
  • 59
5
votes
3 answers

Matching up articles with similar ones

I am creating a site where people can write on a niche topic. It is almost like a blog, however the area as I mentioned is a small niche with (hopefully) passionate users. I want a functionality where once someone posts his article. People with…
open_sourse
  • 161
  • 3
4
votes
3 answers

Is it possible to store N bits of unique combinations, in N-1 bits? If not; why does MD5 get reprimanded for collissions?

Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array that was at least one bit smaller, with…
Anon
  • 3,565
  • 3
  • 27
  • 45
4
votes
4 answers

Generation of logic tables from if conditions

Suppose I have a large, multi-line case statement, which checks several variables before returning a final value. case when (foo='bar' OR foo='foo') AND (bar='foo') then 200 when (foo='jar') AND (bar='glue' OR bar='true') then 212 else…
Decimak
  • 69
  • 7
4
votes
2 answers

Logic design question for SQL query

Was wondering if you could help me on a SQL problem I’m having. I have a set of records of events where each event has a start time and end time. No event has the same start time, and the end time for each event is greater than or equal to the…
4
votes
4 answers

In which order should I do comparisons?

I'm a strong proponent of writing if statements like this: variable == constant Because to me it just makes sense, it is more readable than the inverted: constant == variable Which seems to be used a lot by C-programmers. And I see the use, namely…
3
votes
2 answers

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 of equipment to another. It's range is 0 to…
3
votes
3 answers

Logic behind an 'undo' for painting on a canvas

I'm working on a module that allows users a basic paint function. I want to support undoing any modifications done to the painting surface. Assuming that we have one layer (for the sake of simplicity), what is a reasonable way to store painting done…
Water
  • 356
  • 1
  • 12
3
votes
1 answer

Tests for emptiness vs tests for nothingness

Is there any consensus between languages how tests for emptiness are distinct from tests for noneness? In python the following expression is false: {} is {} However this expression evaluates to True False is False Why is the first expression not…
Niklas Rosencrantz
  • 8,008
  • 17
  • 56
  • 95
2
votes
2 answers

Confusion about strengthening/weakening preconditions/postconditions

I've recently become incredibly confused about the notion of "strengthening/weakening a precondition/postcondition". I think my confusion lies in my interpretation of the words "precondition" and "postcondition". Here is why I'm confused: In the…
user3002473
  • 674
  • 5
  • 16
1
2 3 4