Posted on Friday, October 16, 2009 at 12:25 PM
An often overlooked aspect of application development is how to design the database so that it facilitates maintaining the application. This can be especially crucial when an application offers users the ability to customize it or it is to be used in conjunction with third-party applications.
Applications today frequently have to interop with third-party applications. One of the reasons for the success of the Windows platform was OLE and DDE which allowed different applications to share common data between them. So, how can we design the back end database, so that third-party applications can interop with our application? How can the way we design the data tables affect the maintainability of our application?...
Posted on Friday, September 18, 2009 at 1:54 PM
This addendum just provides the C++ alternative to the reverse words in a string algorithm. When I first started working on the algorithm I used C++ to code it, so I am providing how I did it in C++. For an explanation of the code here see the Second part which uses C to implement the algorithm. Basically, the only difference between this code and the C code is that this code uses string instead of
char*.
The header file:
- /*
- reverse.h by Alex A'Neals (LaniSoft) August 26, 2009
- Reverses the words in a string
- */
-
- #ifndef ALX_REVERSE_STRING
- #define ALX_REVERSE_STRING
-
- // include files
- #include <iostream>
- #include <string>
-
- using std::string;
-
- // function prototypes
-
- // Reverse algorithm functions
- string& ReverseWordsInPlace(string& buffer);
- string& ReverseWord(string &word, int startIdx, int endIdx);...
Posted on Thursday, September 10, 2009 at 3:23 PM
In the
first part I showed how to reverse the words in a string with a simple Perl script. Perl is an excellent language for string manipulation; however, the original question was how could I write the algorithm using C# or C++. Take the following simple string:
A stitch in time saves nine
One way to reverse the words would be to take parse the string into individual words. These words could be stored in individual strings or they could be pushed onto a stack. For example (using _ to indicate the pointer position in the string for each operation and using {} to indicate stack elements with as {top...bottom}):
Before parsing: _A stitch in time saves nine stack = {}
1st Read: A_stitch in time saves nine stack={A}
2nd Read: A stitch_in time saves nine stack={stitch A}...
Comments:
1
Tags:
C algorithm
Posted on Wednesday, September 09, 2009 at 2:12 PM
This is the first in a two part series that talks about how to solve a commonly asked algorithm. Recently, I received a job proposal that listed this simple algorithm as one of the problems to be solved to qualify for the job. The problem to be solved is to reverse the words in a string (phrase entered by the user) and display the new string. The keyword being “words” and not letters or characters.
In other words if the original string is
Birds of a feather flock together
the output should be
together flock feather a of Birds
and not
rehtegot kcolf rehteaf a fo sdriB.
One solution to the problem is the following Perl script:
#! /usr/bin/perl
print "Please enter a string of text: \n";
if(defined(my $inbuf = <STDIN>))
{
{print reverse split /(\s)/, $inbuf};
print "\n";
}
I am only beginning to use Perl, so I am sure there are more elegant ways of doing this. Basically, the key driver for the algorithm is...
Posted on Tuesday, August 18, 2009 at 2:17 PM
While working as a maintenance coder, I was handed a bug report that went something like this. After the last release we received this error message:
"SQL Error 205 - All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists."
The problem with the error message received was that the function being invoked by the program resided in module A; however, the changes made to the program were made in module B. What made the problem even more baffling was that module B's functionality had no direct relation to module A. In fact, module A contained functionality that was exclusive to one segment of the company and module B was exclusive to another group. The only group that had access to functionality in both modules was the admin group and this error was being reported by a non-admin member...