language-agnostic

Pattern: Elegant way to do something upon function exit?

I have a function with logic that looks like this: doStuff1() try: doStuff2() except type1: error1() return endstuff() except type2: error2() return endstuff() except: error3() return endstuff() if doStuff3(): error4() return endstuff() doStuff4() return endstuff() As you can see, endstuff() is do...

Simplifying if statement logic

I have seperated out a test to determine if two schedule items overlap because of the unreadability of it. Is there any application to assist in simplifying a logic statement? Example: (originally a faulty example, but exposes reasons I request this) if (x < y && y < z && x < z) could be reduced to if (x < y && y < z) My code ...

Do you use 1-3 letters variables EVERYWHERE?

I notice, in C# i use very short variable names EVERYWHERE. My code is polluted with foreach(var (v|f|i) in SOMETHING) for(int (i|n|z)=0 var (ret|r) = blah(); ... return ret; var sw = new StringWriter(); using(var r = cmd.ExecuteNonQuery()) { while(r.Read()) { r.GetSomething(3) I dont know if this is bad or ok. I can c...

What is the best language independent source to learn Lambdas/Closures?

Most programming languages are utilizing lambdas/closures. Which language agnostic source is recommended as the best to learn Lambda basics? Lambdas/Closures in different languages: Perl Lambdas Python Lambdas .Net LINQ Java Closures Scheme Lisp Php Closure and Lambdas Javascript Closures C++ ML Wikipedia: Closures (computer science)...

Software that thinks about itself

What concepts are important to learn when considering writing a program that can "think" about itself? By "think", I mean software that can look at itself and improve over time. How easy is it to write a program that can introspect at a basic level? ...

Are concept-mapping tools useful for software analysis and design?

I've become interested in abusing concept mapping (Wikipedia article, explanation by the inventor) as a technique for analyzing the design of moderately large software systems. (The systems are two compilers: One is about 25,000 lines with a 1,000-line runtime system; the other about 200,000 lines with a 90,000-line runtime system. Nei...

What's the name for the first line of a function?

I'm writing a worksheet, and want to ask students to write a function that looks like this: isPrime(int number) What's that line called - manifest comes to mind, but I don't think that's it... ...

Binary Search Tree - node deletion

I am trying to understand why when deleting a node in a BST tree and having to keep the children and adhering to the BST structure, you have to either take the node's right child (higher value, then node being deleted) and if that right child has a left child take that child. Else just the the node being deleted right child. Why don't ...

Handling a form and its action: one page or two?

When doing web programming there seem to be two different ways of handling a form and its action. Is there a reason to prefer one method over the other? Method 1: One page that displays a form or handles a submitted form. This seems simple, in that there's one form for everything. But it also means the if/else cases can become rather l...

Legacy Data Feed, trade off between Standards, Xml and Performance.

We're working with legacy data feeds and apps that consume them. We want to introduce Xml but the additional performance overhead is hard to justify. How have you addressed this issue? We're working with a number of pre-existing data feeds, often files in a well known directory which are updated every few minutes. One approach to making...

How did you practically use recursion?

How did you practically use recursion? I mean practical problems you had to solve in day to day programming, be that for work or for pleasure. Not school tasks/homeworks but something you did for yourself or others. The ones where I used it myself are: drawing some fractals traversing directory tree to search for a file traversing the ...

What is the difference between "image/png" and "image/x-png"?

What is the difference between "image/png" and "image/x-png"? ...

Why do we need high-level languages?

I was teaching my wife C a few days ago and went on to teach her the basics of C++. Now my question is all programming languages have been devised so as to make our mode of communication with the computer easy right ? Else it would have been a chore communicating with them in machine language instructions, right ? So programming langu...

Software and Security - do you follow specific guidelines?

As part of a PCI-DSS audit we are looking into our improving our coding standards in the area of security, with a view to ensuring that all developers understand the importance of this area. How do you approach this topic within your organisation? As an aside we are writing public-facing web apps in .NET 3.5 that accept payment by cred...

What is the algorithm for parsing expressions in infix notation?

I would like to parse boolean expressions in PHP. As in: A and B or C and (D or F or not G) The terms can be considered simple identifiers. They will have a little structure, but the parser doesn't need to worry about that. It should just recognize the keywords and or not ( ). Everything else is a term. I remember we wrote simple ari...

Real world use cases of bitwise operators

What are some real world use cases of the following bitwise operators? AND XOR NOT OR ...

What's that CS "big word" term for the same action always having the same effect

There's a computer science term for this that escapes my head, one of those words that ends with "-icity". It means something like a given action will always produce the same result, IE there won't be any hysteresis, or the action will not alter the functioning of the system... Ring a bell, anyone? Thanks. Apologies for the tagging, I...

Sort months ( with strings ) algorithm

I have this months array: ["January", "March", "December" , "October" ] And I want to have it sorted like this: ["January", "March", "October", "December" ] I'm currently thinking in a "if/else" horrible cascade but I wonder if there is some other way to do this. The bad part is that I need to do this only with "string" ( that i...

How to handle an "OR" relationship in an ERD (table) design?

I'm designing a small database for a personal project, and one of the tables, call it table C, needs to have a foreign key to one of two tables, call them A and B, differing by entry. What's the best way to implement this? Ideas so far: Create the table with two nullable foreign key fields connecting to the two tables. Possibly with...

Give tab spacing after first word in text file

Consider I have a .txt file as of the format, Name: Abc Id: 123 Age: 12 Address: xyz I want to convert this file of the form, Name : Abc Id : 123 Age : 12 Address : xyz i.e the Colon after each tile should move 2 or 3 tab spaces. The title will be only a single word and wont have spaces. So the title wont be of th...