3 |
The LA Fox Developer Newsletter
|
April 1997
|
Polymorphism is one of the greatest assets that OOP brings to the programming community. Far too often, it is underutilized, creating a great deal of unnecessary procedural style code. Furthermore, this code is hard to maintain, and usually cannot be a candidate for reuse.
Current class design is limited to visible objects such as Forms, Buttons, TextBoxes, etc. ‘Business Objects’ have been left alone for the most part. Those that do exist, serve as mere data table navigators, with methods such as First, Previous, Next, Last, and other table routines such as New, Save, and Revert. This type of class is needed
-
as a navigation class. But these classes should work in conjunction with business classes. In constructing true ‘Business Objects’, those that mimic every day business events, with the power of polymorphism, reuse becomes the norm, and flexibility with unlimited growth potential becomes the reward.
One such example is a Payroll Class. Every company needs to calculate payroll. The problem in programming has been trying to calculate all of the different ways that there are to calculate payroll. You havA hourly employees, salary employees, commissioned employees, etc. If you have multiple states that you do business in or you are a software company trying to market to multiple states, you need to worry additionally about the different state payroll tax calculations.
The typical procedural code loops through the employees and calculates each employee through a series of IF. ..THEN.. .ELSE statements or CASE statements to handle the various scenarios mentioned above. This is fine for a simple company that only has a couple of types of employees and that resides in one state. But how flexible is this code? What is involved in changing code to accommodate additional types of employees as well as additional states? You can see how this style of coding becomes unruly very quickly.
Enter OOP. Now we have a Payroll object that hopefully calculates our payroll for us. However, not much changes. The methods replace old style procedures, but generally, the same IF.. .THEN.
. .
ELSE structure applies in handling the various types of employees, and states. Many developers create separate methods for each variable, but essentially, it’s not much better than the old procedural code.
With polymorphism, and creative class design, payroll can be done, not with a Payroll object, but rather an Employee object, that knows how to calculates his/her own salary.
Employee
Business Object Calculating Payroll:
|
Book Review
Instant SQL Programming
I received an unexpected package in the mail a few months ago. The package turned out to be a book from Wrox Press titled “Instant SQL Programming” by Joe Celko (ISBN# 1-874416-50- 8). According to a letter inside the package I was one of five people to win a free book from Wrox Press. It’s certainly kind of Wrox to send me this book although I don’t know how I’m on their mailing list. Nevertheless, I didn’t read this book right away
—
I was in the middle of digesting the Client Server Survival Guide. After sitting on my shelf for two or three months I just got around to reading this book.
The book is aimed at beginning to intermediate level SQL application developers. The book is clearly written and the examples provided complement the text nicely. Also, the runtime version of the Watcom SQL engine is provided on diskette. This allows the reader to type in the examples (or experiment) and return results to the screen.
The first nine chapters cover the SQL basics
—
what is SQL, building a database, SQL arithmetic, logic and nulls, referential integrity and keys, the SELECT statement, JOINs, aggregate functions and using subqueries. The final three chapters cover more complex material such as views, embedded SQL and performance tips.
The difference in the basic SELECT syntax supported by the Watcom SQL engine versus the Visual FoxPro 5.0 engine is really rather minor. I only noted a lack of support for the keywords CROSS JOIN and IS [NOT] TRUE
I
NULL
I
FALSE (not critical at all since VFP 5.0 can handle these keywords in a different fashion), support for more than one level of nested subqueries and support for scalar subqueries (don’t worry about it). So it turns out this book is an excellent reference for last month’s L. A. Fox presentation on VFP 5.0 SQL.
Grade: Varies based on the level of prior SQL knowledge
MicroEndeavors, in cooperation with Microsoft, has announced that they will be holding a two-day pre-conference seminar on May 15-16, 1997. The purpose of this seminarwill beto show FoxProiWindows developers how to leverage their knowledge of FPW and bring it into the world of Visual FoxPro. Cost of the seminar, to be held at the LAX Westin, will be $595. For further details, visit their Website at
http://www.microendeavors.com/
foxsem97.htm.
|
Page 3
|
3 |