Friday, December 28, 2007

OOP: VB.Net Polymorphism

Continuing further with the inheritance discussion, VB.net also enables polymorphism when a class is derived from a base class.

Poloymorphism is accomplished with the following keywords. Designating an instance or base class with these keywords make the code easier to understand:
  • Overloads - Allows a method to be described using different signatures (or combinations of parameters), however keeping the same name.
  • Overridable - Used when creating a property or method in the base class which will allow the derived class to change its function
  • Overrides - Used by the derived class to manipulate a method in the base class.
  • NotOverridable - Used when creating a property or method in the base class which will not allow overriding.
  • MustOverride - Used when creating a property or method in the base class which must be overridden.

OOP: VB.Net Inheritance

Being an object oriented language, Visual Basic has the ability to derive one class from a parent class. Inheritance enables code reuse, as well as a way to express hierarchial relationships. This is accomplished in code by using the 'Inherits' keyword.

The following shows a simple illustration of inheritance. Notice the use of Access Modifiers discussed previously.
Public Class Automobile
Public wheelCount as Integer
End Class

Public Class SportsCar
Inherits Automobile

Public turboCharged as Boolean
End Class

Public Class HotRod
Inherits SportsCar

Public parachuteEnabled as Boolean
End Class

OOP: VB.Net Encapsulation

The following describes how OO programming techniques are implemented in Visual Basic code. This article is a great index, with many examples.

Encapsulation enables the developer to hide information. Information is hidden, not as much to limit access, but to make an object easier to use for its consumers.

Visual Basic enables access to information within classes through Access Modifiers. Access Modifiers determine who has access to what.
  1. Private - often reffered to as member variables and designated with an "m". Only available in the code where the variable or method was declared.
  2. Public - accessable anywhere within the application
  3. Friend - accessable only by members of the class where it was declared
  4. Protected - accessable only by members of the class where it was declared, or by members of the inheriting class.
  5. Shared - used in a base class. The value of a shared property will change accross all instances of the class, even when the class has several implementations.
Advise is given to make as little as possible public. The more public properties and methods, the more confusing the public interface could be.

Object Oriented Programming Paradigm

My plan is to discuss object oriented design, how it is applied in .Net IDE, and further how it will apply to an internal software development team. Initial concepts for this overview are here.

Basically the OO technique describes a collection of cooperating objects. This is opposed by the older technique of writing an application as a group of sub-routines. Each object is capable of receiving messages, sending messages, and processing data. They should be viewed as independent machines with distinct roles and responsibilities.
The most basic form is the class. A class describes the abstract characteristics of an object (its properties and methods). Likewise, an object is an instance of a class (Lassie is an instance of the dog class).

Furthermore, there are three main pillars of thought which make up the OO paradigm: encapsulation, inheritance, and polymorphism.
  1. Encapsulation - Each object should define which members are publicly exposed to its clients. This concept is better described as an interface. The public interface should not need to know how the implementation is carried out, or when it changes. This interface should always remain static.
    • Modularity - This concept defines the separation of the interface and the implementation. Described more basically, the application, should be built of interacting parts.
  2. Inheritance - Sub-classes should be able to inherit or derive from parent classes. They should also have the ability to add or modify members of the parent class. This also enables the developer to write significantly less code.
    • Abstraction - further describes the concept of inheritance by modeling a complex problem set with a more simple collection of objects. A developer should be able to manipulate the appropriate level of inheritance for the given operation. For example, a driver only need to know how to turn the key to get the car started, they do not need to understand how the engine works, however, the mechanic may.
  3. Polymorphism - Defines the ability of the derived classes to modify the parent class. Polymorphism is accomplished through overriding or overloading members of the parent class.
An interesting common disconnect in OO design is the interaction with the relational database management system (RDBMS). There must be a conversion bridge (object - relational mapping) created between the two systems. In our applications, this is generally accomplished between the stored procedure and business tier of the application.

Monday, December 17, 2007

Amazon SDS - Simple Database Design

This new product from Amazon poises thought provoking ideas regarding database design. It goes away from a schema based on normalization, joins, and stored procedures; and focuses primarily on speed and small message size.


Here are some principles of the Simple DB. Could we build an application on top of such a model?

  • All data elements are automatically indexed as UTF strings
  • Organized like a hash table (key - value pairs), characterized as "hash in the cloud" or library (Do you know what a hash table is?)
  • Execution time is limited to 5 seconds (processing is moved from the database to the application)
  • Objects are comprised of a Domain/Item/Attribute hierarchy.
  • Each Item can have 256 attribute values
  • Each Attribute can range from 1 to 1,024 bytes


While this schema would necessitate a major shift in schema design, it seems that forcing the processing from the database to the application may move in the right direction.

Wednesday, December 12, 2007

Inland Arrival Communication Preferences

Here's the query for communication preferences logic. The key is lt_serial = 0042


select distinct contact.pd_last_name, contact.pd_first_name, contact.pd_own_email, communicationPrefs.lt_serial,
communicationPrefs.lk_custno_1, communicationPrefs.lk_custno_2, communicationPrefs.cp_doc_type_id,
CommunicationPrefsDocType.doc_type_name, CommunicationPrefsDocType.doc_type_ref_id, CommunicationPrefs.cp_form_type_id,
CommunicationPrefsFormType.form_type_name, CommunicationPrefsFormType.form_type_ref_id, CommunicationPrefs.cp_role_id,
CommunicationPrefsRole.cp_role_name, CommunicationPrefsRole.cp_role_ref_id, CommunicationPrefsRoleDocType.fax_type
from ACInlandAgedTable with(nolock) LEFT OUTER JOIN CommunicationPrefs with(nolock)
ON ACInlandAgedTable.CustomerNumber = CommunicationPrefs.lk_custno_1
INNER JOIN CommunicationPrefsDocType with(nolock)
ON CommunicationPrefs.cp_doc_type_id = CommunicationPrefsDocType.doc_type_id
INNER JOIN CommunicationPrefsFormType with(nolock)
ON CommunicationPrefs.cp_form_type_id = CommunicationPrefsFormType.form_type_id
INNER JOIN CommunicationPrefsRole with(nolock)
ON CommunicationPrefs.cp_role_id = CommunicationPrefsRole.cp_role_id
INNER JOIN CommunicationPrefsRoleDocType with(nolock)
ON CommunicationPrefs.cp_role_id = CommunicationPrefsRoleDocType.cp_role_id
AND CommunicationPrefs.cp_doc_type_id = CommunicationPrefsRoleDocType.doc_type_id
LEFT OUTER JOIN Contact with(nolock)
ON CommunicationPrefs.lk_custno_2 = Contact.custno
Where communicationPrefs.lk_custno_1 is not NULL
and Contact.custno is not NULL
and communicationPrefs.lt_serial = '0042'
and CommunicationPrefsRoleDocType.fax_type = 'IMPORT'
and communicationPrefs.cp_doc_type_id = 7
Order by CommunicationPrefs.lk_custno_1

QChat Enhancement - Contextual Branching

I. Capture New DataSet Objects
A. New Stored Procedures
1. CQMContextualBranchingArea - Used to fill the 1st level drop down
2. CQMContextualBranchingAreaToSubArea - Associations between 1st and 2nd drop down
3. CQMContextualBranchingSubAreaToReason - Associations between 2nd and 3rd drop down
4. CQMInteractionUpdate - Call whenever a survey is Updated. Should be called when the
CQMCompleteSurveyUpdate stored procedure is called. This does inserts into customer interactions.
B. Amended Stored Procedures - These added customer interactions to grid return, should be displayed in Survey.
Each grid query now has AreaReason, SubAreaReason, ReasonReason.
1. CQMGridCoach
2. CQMGridMonitor
3. CQMGridReview
4. CQMGridSearch
III. Application Adjustments
A. Contextual Branching - This branching should not go back to the database, but use filtering of data tables similar to StarCarExpress
1. The Area Drop down should key off of the first word in the DepartmentText field (we already get this field)
a. If this first word is not 'Import' or 'Export' then leave blank and force user to choose
b. If there is a match, you will have to fire the next set of drop downs
2. The main display grid should pass Interaction Reason values to the Survey, and set drop downs appropriately
3. Must pass contextual values to the CQMInteractionUpdate
a. Validate to ensure each drop down has a choice
4. You can remove the CallType and Call Category drop downs, as these choices will be represented in the contextual branching

Thursday, December 6, 2007

Gnarly Problems

While long, this article says some accurate things about being successful in business. Essentially, "the market pays for solutions to gnarly problems, not solutions to easy problems."

MQ Depth Web Application

Cool little web application which reads the depth of all the production MQ queues. Interesting method to read clustered queues. Also new IIS setting to enable the website to run under a user who is on the domain instead of the default local user.

The domain user must be in the IIS_WPG, then put the domain user in the application pool indentity configuration. This, in addition to securities granted to the MQ itself, allows the website to have security access to the MQ Server application.

More SL Integrity Notices

In addition to notices sent Friday, November 30; more notices today.