The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

C to SQL

I've got a gig at a company who now write most of their software in SQL - only problem is that one of their older applications has it's business logic implemented in C and they now want me to shift all of this over to SQL. Easier said than done. I've come to the realisation that emulating the C code in PL/SQL line-for-line is not a good idea. What's the best approach for this?
silvermonkey Send private email
Tuesday, April 29, 2008
Are you working against an existing schema, or are you about to design your own schema to support the SQL you are about to write?

Do you know how to use SQL to work well with sets of data, without coding a loop that processes one row at a time? 

When you read the original C code,  can you separate out the business logic rules from the rest of the code?
Walter Mitty Send private email
Tuesday, April 29, 2008
Existing schema, I'll probably be doing this row-by-row and the code is quite a bad mess. I'm still trying to understand it all.
silvermonkey Send private email
Tuesday, April 29, 2008
Try to avoid doing things row by row. I'm hardly an expert, but I've found very few situations that actually require a cursor. Set-based operations are your friend.
Ron Porter Send private email
Tuesday, April 29, 2008
Scope Creep :-)

If the C code contains also business logic, I'd suggest to split this into several parts to learn the system before you  jump into coding. If it's only (really?) data storage and manipulation, leave out step 1:-)

(1) Business Analysis / Reverse Use Case Engineering
(a.k.a. observe in action)
Sit together with existing users of that app (if there is a UI - or analyze the code that calls your C code) and extract the following W's:
- Why is the scenario started
- What data is displayed, changed, stored?
- Who (business user / transaction) is initiating the scenario

This should give you some good clues about what the current benefits of the existing system are. (very likely also some negative points if there are human users involved:-).

(2) Data Analysis
There are some tools out (I'm out of that business for some years) that can reengineer C code and create diagrams and schemes out of it. This makes it much easier to learn the existing code and to sorrt it out.

(3) There's only a slight chance that the C code can be 'compiled' into SQL. No code I ever saw was so cleanly modularized that you could transfer it to another paradigm (C-functional versus SQL-data oriented).

(4) The test activities of your project will be most complex. You won't handle only the straight requirements (do exactly the same like the C code), but people will expect to have somethin on top of it (loose annoyances or win smiles). Im if may: be sure to set your stakeholder's expectations right.

Most inhouse projects replace something. A mentor told me once that the management and team of the system/code 2b replaced are your greatest enemies in such situations:-)
Volker Kopetzky Send private email
Tuesday, April 29, 2008
The question is, why do they want it in PL/SQL? To store it in the database?

You could use Java to do that or alternatively create a dll or so out of your C sources and include it via extproc.
Tuesday, April 29, 2008
You could move all the code into an extended stored procedure, leave it in C, and say "here's the sql: EXEC xp_myLogic"

Not helping, I know. ;-)
Chris Tavares Send private email
Tuesday, April 29, 2008
I currently tend to design logic to work on the client in client/server apps... many current clients are More powerful than that old "investment" server...
- Multiple cores twiddling their digital thumbs.
- Lots of ram (only used to cache youtube videos).
- Lots of HD Space (But I still don't think about offloading storage)....

Having logic on the server has only one reason, when you get a "high-level" command to change all that "Legacy" C/C++ code that works perfectly well to the latest FAD .NET4.0, that way you'll only change to UI, and they'll be happy.
Totally Agreeing
Thursday, May 01, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz