12.07.2015 Views

Chapter 6 VB/Access Programming

Chapter 6 VB/Access Programming

Chapter 6 VB/Access Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Information Systems Developers Handbookor maintenance by clearly showing where each statement or loop starts and finishes.The programmer can easily identify common errors, such as failing to end a loop orplacing a line of code outside the if statement when it should be within it.Indent within If statements and LoopsFor intIndex = 1 to LengthOflstCustomerStatement 1...If lstCustomerNo(intIndex) = txtCustomerNo ThenStatement 1Statement 2...End IfStatement n...Next intIndexRather thanFor intIndex = 1 to LengthOflstCustomerStatement 1...If lstCustomerNo(intIndex) = txtCustomerNo ThenStatement 1Statement 2...End IfStatement n...Next intIndex6.4 Coding for ReusabilityCode can be reused in a number of ways. It can be reused within a program bydeveloping applications high in cohesion, that is, by writing code in subproceduresand functions. Ideally, each subprocedure or function will process only one task.Whenever that particular task needs to be processed that module can be called. Ofcourse, there are other considerations. A specific task may require different datavalues at different times. That data will need to be passed to the module at the timeof possessing. This, naturally, is passed from the calling procedure as an argumentand received by the called procedure’s parameter. It is in the passing and receivingof data that loose coupling is important. Coupling is the extent to which theinformation exchange between procedures is independent of other procedures. Thenext section will look at cohesion and coupling in greater depth.However, before doing so, there is another way code can be reused. That is, byimporting code that has already been written to do a particular task. This is easilyachieved in <strong>VB</strong> by including modules, forms, etc. Students will be reusing codeextensively, in the form of modules (*.bas). This will allow you to see how amodule that is developed and thoroughly tested, can be reused many times. Theprogrammer may take a ‘black box’ approach, as knowledge of the inner workingsPage 70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!