logic

SQL user-defined functions vs. stored procedure branching

Hello. I currently am working on a legacy application and have inherited some shady SQL with it. The project has never been put into production, but now is on it's way. During intial testing I found a bug. The application calls a stored procedure that calls many other stored procedures, creates cursors, loops through cursors, and many ot...

c# calulcation logic

hi, i am looking to put together some logic to look at a particular number and based on a simple calulcation tell me what another number is. Example - lets say that i have a string of characters and each 50 characters will increment an integer by 1. so if i have 0 - 49 chars, counter = 1, if i have 50-99 chars, counter = 2, if i have 100...

stupid or smart database?

I'm developing an multi-user application which uses a (postgresql-)database to store its data. I wonder how much logic I should shift into the database? e.g. When a user is going to save some data he just entered. Should the application just send the data to the database and the database decides if the data is valid? Or should the appl...

Best logic for storing categories of images.

I am creating a system where a user can select any combination of four options. Then results are displayed based on their exact combination. For example, if a user chose color, text, and logo. Only results featuring color, text, and logo would return. On the other side, I am creating "templates" that will eventually be the results ret...

Do formal methods of program verfication have a place in industry?

I took a glimpse on Hoare Logic in college. What we did was really simple. Most of what I did was proving the correctness of simple programs consisting of while loops, if statements, and sequence of instructions, but nothing more. These methods seem very useful! Are formal methods used in industry widely? Are these methods used to prov...

OR-ing bytes in C# gives int

I have this code. byte dup = 0; Encoding.ASCII.GetString(new byte[] { (0x80 | dup) }); When I try to compile I get: Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) Why does this happen? Shouldn't | two bytes give a byte? Both of the following work, assuring that each i...

How does a programmer think?

This may be a hopelessly vague question. But I am interested to hear whatever logical thought processes people go through when learning a new concept or trying to get their brain around code they might not have ever seen before. Basically, what general steps does one take to to break down problems and what does it take to "get it"? If y...

Automatic Spacing for Flowchart

So I'm working on a project that will, in the end, generate a kind of flow chart using the Flickr api. You will supply a seed tag, and the program will use that seed tag to find other related Flickr pictures that have common tags... I have all of the back end stuff up and running but I'm stumped on the formatting. Here is a screenie of...

Best way to store and select multiple states/cities for a Company?

Hello, I have Company A. I need the ability to link this Company to multiple States, and each state can in turn be linked to multiple Cities. For example: Company A \ - State A |-City A |-City B \ |-City C - State B |-City A ...

User Interface and Business Logic... Cyclic Reference

I have 2 main dlls.....one which has my user interface (windows form) and other which has the business logic.....I have a requirement in which the user interface has to be launched from the business logic with arguments......and on click of a button in the user interface, I need to send data from the user interface to the business logic....

Round robin in C#

I'm having a problem (possibly due to lack of sleep!) where I'm trying to solve a maths problem in C#. Let's say I have a drinks machine, and I have three empty rows that can be filled with Cola. I have 17 cans of Cola in my hand and I have to fill each row one at a time. For example... Pass 1: Add Cola to Row 1. Drinks = 1 A...

adding logic to datagrid item template

Dear All, how would you go about adding logic to a datagrid item template? In my datagrid, i want to add a logic to it. that is, if the result for the data equals to "Yes", an "asp:label" control will be displayed; otherwise a "asp:imagebutton" control will be shown <ItemTemplate1> <% if DataBinder.Eval(Container.DataItem, "boflag").e...

OSX Audio: use Garage Band Plug-ins in my own app

Hello everybody! I'm writing a little app for the Mac, that involves recording a voice. In GarageBand, and in Logic for that matter, there is a plug-in called Speech Enhancer. Is there any way I can piggyback on this plug-in, offering those users that have GB or Logic installed the comfort of noise cancellation and equalizing the built-i...

PHP Conditional Logic

In PHP, is the following logic allowed If (x && y) //Do A Elseif (x) // Do B Elseif (y) // Do C Else // Do D Basically, are you allowed to use more than one elseif? ...

how to: retrieve values from database only when they are updated

I have a scenario where I want to display a bunch of data on a web page. The data gets populated into database by some process (which I have no control over) only at (7:00 AM) a specific time in the morning or manually starting the process. (P.S The same data is also being used in some other place on the web page in a different form, ...

Or gate using 2 NANDS

The diagrams I've seen for making an OR gate from a NAND gate use 3 NAND gates but if you have both inputs connected to both connectors of a NAND gate and then the output of this gate as inputs to both connectors of a second NAND gate it should behave like an OR gate. So you'd need only 2 gates? edit: this pic below was an attempt I m...

Editor to draw program logic and focus on big picture?

Hello This question has probably been asked before, but I don't know what keywords to use to find previous answers. When writing code, I tend to get lost in details, and would like some editor that I can use to be able to move from the little picture (actual code) to the big picture (big blocks of logic). Ideally, it should integrate ...

Why are there not more control structures in most programming languages?

Why do most languages seem to only exhibit fairly basic control structures from a logic point of view? Stuff like If ... then, Else..., loops, For each, switch statement, etc. The standard list seems fairly basic from a logic point of view. Why is there not much more in the way of logic syntactical sugar? Perhaps something like a propos...

Why does my localization cookie seem to not want to change?

Why cant I change cookie? If you chose a language you cant change. You have to empty your cookies if you want to change language. Why is that? if (isset($_GET['setLang']) && $_GET['setLang'] == 'en' || isset($_COOKIE['setLang']) && $_COOKIE['setLang'] == 'en') { setcookie("setLang", 'en', time()+(3600*12)); //expires in 12 hours incl...

Generic sub-set algorithm problem

I have the following problem. I've got a set of items {a1, a2, a3, ... aN}. Each one of those items can contain another set of items {b1, b2, b3, ... bN}. So the end result looks something like this: a1 b4 b22 b40 b11 b9 a2 b30 b23 b9 b4 b11 a3 b22 b4 b60 b9 As a result of the execution of the algorithm I ...