Reduce Code Complexity

Whenever I analyze and design, I look at the lines of code which are so long they need to wrap to the next line.

Often, in an application, code can be simplified (shortened) by reducing the code to essentials. Often, the lengthy lines are the result of many parameters which remain the same in the application or are not needed in the application.

Often, the code can be replaced with shorter (sometimes one word) lines. I give as an example the following:

As an example, some related database navigation commands were reduced to the following:

 nextRecord()
 prevRecord()
 firstRecord()
 lastRecord()
 currRecord()
This helps me in writing the remainder of my database program, including navigation buttons as simple as:

 Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs?) Handles btnLast.Click
    lastRecord()
 End Sub

the lastRecord() Subroutine:

Private Sub lastRecord() Me.BindingContext?(DsCompanies?, "Company").Position = Records - 1 whatRecord() End Sub
The remainder of the record navigation commands and buttons are handled in like manner. The whatRecord() is to update a display label which is of the form "Record 23 of 1027". At the time of changing records, all bound controls are also changed.

If one of the ideas in PowerProgramming? is to understand and to be understood, such coding conventions enable this.

When in the future I come across such code, it will be easy to understand, having been treated to ReduceCodeComplexity.

--AnonymousDonor


See also: WorkBackwardFromPseudoCode


CategoryComplexity


EditText of this page (last edited January 18, 2013) or FindPage with title or text search