October 9, 2008
CodeStuff
4 Comments
Not too often I post development stuff here, but this is one that’s been bugging me for a few years. For those unfamiliar with it, AJAX is a web technique that involves using a JavaScript call to refresh part of a web page with new content instead of the entire page. The technique is intended to transfer “XML” data (hence the ‘X’ in AJAX), but most times people just use it to move raw HTML markup around. I’ve been wanting to embed JavaScript function calls in the content that I dynamically load on a page, but the AJAX loading technique does not execute any JavaScript in the HTML.
Read the rest…
October 15, 2007
CodeStuff
No Comments
40 tips to optimize PHP code. As a PHP coder, I must say that this is quite impressive, and that it’s going to change how I approach the PHP hackoding that I do at work. w00t.
September 10, 2007
CodeStuff
1 Comment
Is there a term for the fear of software that you wrote crashing spectacularly on a client’s machine even though it works fine in every situation you could fathom in testing? If there isn’t, then there should be, because I have it, and I’m sure that I’m not alone.
June 21, 2007
CodeStuff, FunnyStuff
1 Comment
Here is a blog post on the latest in the trend of programming methodologies that take a more, ahem, *realistic* view at corporate and software development culture. While I may be guilty of some of these, all I ask is to work with people who know what they’re doing, and whose code I can trust (without having to second-guess/proofread). Good help is hard to find…
March 2, 2007
CodeStuff
No Comments
We’re in the middle of trying to deploy a Java applet at work. So as to not use the deprecated “applet” tag, we’ve taken to using the “object” and “embed” tags for launching the applet in both FireFox and IE. Only problem is that our site uses client certificates for user authentication, and Apache doesn’t realize that the certificate that was used to log in to the site should be good enough for the applet. Techy stuff to follow…
Read the rest…
February 23, 2007
CodeStuff
3 Comments
I spent a large amount of time at work yesterday trying to create a DSN-less ODBC connection in Java to some .csv (comma-separated values) files. Since I couldn’t find documentation that solved all of my problems, I’m going to post my solution here. Non-programmers can stop reading now.
Read the rest…
January 31, 2007
CodeStuff, SchoolStuff
1 Comment
At Saint Mary’s, C++ has been the de-facto language for Computing Science for the last several years. As a result, the students don’t get much exposure to other languages, like Java (although that’s changing this year, much to the chagrin of certain people in the department, myself included… I am of the opinion that Java as a “starter” language is a bit steep as it expects a lot from the developer, and it’s too easy for a beginner to to get caught in the trap of ignoring all exceptions and all that jazz. But I digress).
This semester, I’ve been tasked with teaching Object-Oriented Programming in Java. While we are spending a lot of time on things like proper OOP techniques and approaches, including (but not limited to) UML diagrams, design patterns, and all that goodness, we also spending time on some of the Java “basics”, like desiging classes, working with interfaces, fun with Swing and AWT, and of course, applets. This week’s recitation had them drawing googly-eyed happy faces, as above. Wheeeee!
November 26, 2006
CodeStuff, SchoolStuff
8 Comments
Last week I started teaching recursion to my students (for the unaware, I’m teaching a 2nd year engineering computer programming course at SMU; it’s similar in structure to the 2nd half of the 1st year course I usually teach). I’ve never tried to talk about recursion and recursive algorithms for more than one lecture, but this time I’ve gone over several sample algorithms (Towers of Hanoi, QuickSort, palindrome detection, prefix calculator, reversing a sequence of words). I just wonder if there’s a proper way to teach it… I’m sure there is, it’s just that I haven’t come up on it yet.
A little primer: a recursive algorithm is one where the solution involves applying the same algorithm to a reduced version of the problem set. Similarly, recursive functions are usually defined in terms of themselves, and thereby a recursive function will contain calls to itself. Recursive functions are elegant and easy to read, but they are usually complicated to come up with, and they are often more computationally intensive than their iterative counterparts. I have written a blog post about recursion, you can read it by following this link.
The main question is this, though: how do you get people to think recursively? When a problem is defined recursively, it’s not bad. Consider the Fibonacci number sequence. Computing Fibonacci numbers is easy: to get the next number in the sequence, you add the two previous numbers together (e.g., starting with 1 and 1, the sequence would be 1, 1, 2, 3, 5, 8, 13, 21, 34, …). The nth number in the Fibonacci number sequence can be computed by taking the sum of the n-1st and n-2nd Fibonacci numbers, given that the first two Fibonacci numbers are both 1. The Fibonacci number algorithm can thereby be written thusly:
int Fibonacci(int n)
{
if (n == 1 || n == 2)
return 1;
else
return (Fibonacci(n-1) + Fibonacci(n-2));
}
Ya dig? When I was learning this stuff, I just “got it” after a while, so obviously my profs didn’t know the silver bullet (if there is one). Bombarding them with examples is all well and good, but it only gets you so far. If you “get it”, what was it that did it for you?
October 17, 2006
CodeStuff
2 Comments
If anyone reading this is a recent University graduate in CS, my work is looking for a Software Developer. There is an ad on Career Beacon (from August 29th); only diff is that we don’t give a hoot about C#, and that we’re looking for someone who also has Java experience.
Update: the link has been refreshed, and we’ve already started receiving applications. Send yours in today! (if you’re interested, that is) FYI, a well-organized resume and an relevant cover letter go a long way. None of this “To Whom It May Concern”, or “Dear Sir/Madam”, or cookie cutter cover letters, I usually see through that in a second and regardless of whether or not you’re qualified, I toss it aside.
January 9, 2006
CodeStuff
3 Comments
Since I started my new job (more on that later), I have to learn a new language (sort of). I programmed in Pascal 10 years ago, so learning Delphi is relatively easy. Nevertheless, it’s still a bit of an uphill climb as I accustom myself to the new interface, but it’s coming along nicely. Right now I’m just introducing myself to Delphi’s object reference model, which basically means that every object isn’t an actual object, but rather a reference to an object in memory. I’m usually a pointers kind of guy as it is, but I like to be able to pick and choose when I use pointers and when I don’t.
Apparently we’ll be switching over from the Delphi language (in which I could use the development experience) over to C++ when we get our copy of Delphi 2006 in a few weeks for cross-platform portability, but in the meantime I get to resharpen my programming skills and put aside everything else.
UPDATE: It seems as though Delphi’s object reference model is just a bunch of smoke. From what I can gather, regular objects (i.e., not pointers) are similar to regular objects in, say, C++, except that you have to call the constructor manually (again, it would seem). If you want to do the pointer thing, you have to declare them explicitly, e.g.,
myObj := ^MyClass;.
On top of that, allocating memory dynamically is done with a function called GetMem, which seems to be a throwback to the malloc days of C programming. Fun fun fun!
May 1, 2005
CodeStuff
No Comments
I learned an important lesson this week as I was coding my project.
If you think you’ve found a polynomial-time solution to a space-usage optimization problem that would run in O(2n) time using a brute-force algorithm, then you haven’t.
That is all.
March 9, 2005
CodeStuff
No Comments
In the next day or so I’ll need to be able to create really big files in C++. Only problem is (from what I can gather) that the C FILE type that I’m using (because I can’t think of another way to do binary files… the stream insertion/extraction operators only do text; I figure I’m missing something real obvious) uses a signed (32-bit) integer to indicate the position in a file, limiting file sizes fo just over 2 gigs.
My temporary solution is a class that supports a buffered file system where extremely large files are chunked, but that this chunking is invisible to the user (obviously). This should solve my problem (and maybe even speed things up a bit given that I’ll be buffering, unless the C FILE pointer functions have some built-in buffering of which I’m unaware), but what I want to know is if there is a better way to do this? 64-bit architecture, anyone?
March 6, 2005
CodeStuff
3 Comments
Strange programming quirk that I stumbled on which writing some C++ code over the weekend. It seems that g++ and Visual Studio have different ways of handling the bit shift operator when 0-length shifts are involved.
I’m working with a class that is effectively an array of 64-bit integers that is being made to behave as a giant integer. To do that, I need to overload a bunch of operators, including bitshifting functionality. For example, the << operator looks like this:
for (i=numLongs-1;i>0;i--)
{
result.data[i] |= (result.data[i-1] >> (FIELDSIZE-numShift));
result.data[i-1] <<= numShift;
}
Nothing funny there, right? Here’s the strange part, though: when the value of numShift is zero, this code produces the expected result compiled under Visual Studio .NET running on Windows XP (in other words, no change to the data in the array), but when compiled with g++ running under Linux, the result is frequently something other than what was expected (off by a few bits).
The fix is simple, of course: just test the value of the numShift variable before getting to that code fragment. If that value is zero, then you can return from the function without any bitshifting (and thereby without any chance of mucking up the data). While this modification solves the problem in VS and g++, I still don’t understand why the above loop misbehaves with g++ (3.3, if you’re curious).
Strange, indeed, and the cause of many hours of hair pulling at the inconsistent results of the same code on two platforms. Argh!
February 7, 2005
CodeStuff
1 Comment
I’ve been hit a lot by WordPress comment spammers. They automagically post comments on every one of my posts, and it’s a bother to go in and delete them. They almost ALWAYS have to do with online gambling sites of some sort. Yesterday, I got fed up with the whole thing and decided to do something about it.
Read the rest…
October 20, 2004
CodeStuff
2 Comments
I read an interesting article on how NOT to write programming assignments which I found quite amusing. Of course, everybody has their own programming style which works for them, so just saying that these habits are explicitly bad doesn’t actually mean it.
Some slashdotters have even brought up the concept of coding while under the influence of something-or-other and the varying degrees of success that they’ve had at hammering out code while hammered. I for one have never tried this, but I should give it a whirl one of these days. That just might have been what was necessary to save my thesis.