






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Algorithm and complex analysis. Data structures
Typology: Summaries
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Programming Style Programming style is set of coding rules followed by all the programmers to write the code. It is a set of guidelines used to format programming instructions. When multiple programmers work on the same software project, they frequently need to work with the program code written by some other developer. This becomes tedious or at times impossible, if all developers do not follow some standard programming style to code the program. An appropriate programming style includes using function and variable names relevant to the intended task, using well-placed indentation, commenting code for the convenience of reader and overall presentation of code. This makes the program code readable and understandable by all, which in turn makes debugging and error solving easier. Also, proper coding style helps ease the documentation and updating. Principles of Good Programming Styles Guidelines can be developed from coding conventions used in an organisation with variations of style occurring for different programming languages. Key elements of programming style guide include i. Naming Conventions, ii. Use of Comments iii. Indenting and White Spaces. iv. General Formatting In some languages (e.g. Python), indenting is used to indicate control structures (hence correct indentation is required), whilst in other languages indenting is used to improve the visible appearance and readability of the code (e.g. Java). i. Naming Conventions When naming variables, functions/methods, classes, files etc. it is important to follow a naming convention, and use correct English spelling (this assists with search/find/replace operations). Naming conventions are used to improve visual appearance and reduce the effort needed to read and understand the code. They can vary in different programing languages. The following items are a good guide:
Program Documentation Any written text, illustrations or video that describe a software or program to its users is called program or software document. User can be anyone from a programmer, system analyst and administrator to end user. At various stages of development multiple documents may be created for different users. In modular programming documentation becomes even more important because different modules of the software are developed by different teams. If anyone other than the development team wants to or needs to understand a module, good and detailed documentation will make the task easier. These are some guidelines for creating the documents − ● Documentation should be from the point of view of the reader ● Document should be unambiguous ● There should be no repetition ● Industry standards should be used ● Documents should always be updated ● Any outdated document should be phased out Types of Program Documentation The documentation process starts from the problem analysis phase to debugging and testing. Documentation consists two types of documentation, they are:
Structured Programming In the process of coding, the lines of code keep multiplying, thus, size of the software increases. Gradually, it becomes next to impossible to remember the flow of program, difficult to share, debug and modify the program. The solution to this is structured programming. Structured programming also known as Modular Programming is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. These functions are also known as modules , subprogram , subroutines and procedures. A defined function or set of similar functions is coded in a separate module or submodule, which means that the code can be loaded into memory more efficiently and that modules can be reused in other programs. After a module has been tested individually, it is then integrated with other modules into the overall program structure. Structured programming encourages the developer to use subroutines and loops instead of using simple jumps in the code, thereby bringing clarity in the code and improving its efficiency Structured programming also helps programmer to reduce coding time and organize code properly. A key characteristic of a structured statement is the presence of single entry and single exit point. This characteristic implies that during execution, a structured statement starts from one defined point and terminates at another defined point (there should be an entry and exit point for each module). This is one of the reasons why the Structured Programming Approach is well accepted in the programming world. Structured programming also focuses on reducing the following statements from the program:
var test var test var average average = test1 + test 2 + test3 / 3 print average When you run the program, you get results that are obviously incorrect. It is not a syntax error as the code can be compiled and run, it is a logic error. What is the logic error? The program is dividing test3 by 3 and then adding it to test1 and test2. Should be (test1 + test2 + test3)/
remain in the program and these errors appear during compilation or linking or execution. Debugging is generally done by program developer. To make the software programs or products bug-free, this process should be done before releasing them into the market. Steps involved in Debugging The steps involved in this process are,
1. Identify the Error: A bad identification of an error can lead to wasted developing time. It is usual that production errors reported by users are hard to interpret and sometimes the information we receive is misleading. It is import to identify the actual error. 2. Find the Error Location: After identifying the error correctly, you need to go through the code to find the exact spot where the error is located. In this stage, you need to focus on finding the error instead of understanding it. 3. Analyze the Error: In the third step, you need to use a bottom-up approach from the error location and analyze the code. This helps you in understanding the error. Analyzing a bug has two main goals, such as checking around the error for other errors to be found, and to make sure about the risks of entering any collateral damage in the fix. 4. Prove the Analysis: Once you are done analyzing the original bug, you need to find a few more errors that may appear on the application. This step is about writing automated tests for these areas with the help of a test framework. 5. Cover Lateral Damage: In this stage, you need to create or gather all the unit tests for the code where you are going to make changes. If you run these unit tests at this stage, they all should pass. 6. Fix & Validate: The final stage is the fix all the errors and run all the test scripts to check if they all pass. Benefits of Debugging Debugging has many benefits such as: ● It reports an error condition immediately. This allows earlier detection of an error and makes the process of software development stress-free and unproblematic. ● It also provides maximum useful information of data structures and allows easy interpretation. ● Debugging assists the developer in reducing useless and distracting information. ● Through debugging the developer can avoid complex one-use testing code to save time and energy in software development. Debugging Strategies ● It is important to study the system in depth in order to understand the system. It helps the debugger to construct different representations of systems that are to be debugged. ● Backward analysis of the problem traces the program backward from the location of failure message in order to identify the region of faulty code. You need to study the region of defect thoroughly to find the cause of defects. ● Forward analysis of the program involves tracking the program forward using breakpoints or print statements at different points in the program. It is important to focus on the region where the wrong outputs are obtained.