Download presentation
Presentation is loading. Please wait.
Published byMoses Lee Modified over 9 years ago
1
The Way to Produce Good, Clean Code That Will Blow Your Boss Away!
2
How Not To Code /* Use the insertion sort technique to sort the "data" array in ascending order. This routine assumes that data[ firstElement ] is not the first element in data and that data[ firstElement-1 ] can be accessed. */ public void InsertionSort( int[] data, int firstElement, int lastElement ) { /* Replace element at lower boundary with an element guaranteed to be first in a sorted list. */ int lowerBoundary = data[ firstElement-1 ]; data[ firstElement-1 ] = SORT_MIN; /* The elements in positions firstElement through sortBoundary-1 are always sorted. In each pass through the loop, sortBoundary is increased, and the element at the position of the new sortBoundary probably isn't in its sorted place in the array, so it's inserted into the proper place somewhere between firstElement and sortBoundary. */ for ( int sortBoundary = firstElement+1; sortBoundary <= lastElement; sortBoundary++ ) { int insertVal = data[ sortBoundary ]; int insertPos = sortBoundary; while ( insertVal < data[ insertPos-1 ] ) { data[ insertPos ] = data[ insertPos-1 ]; insertPos = insertPos- 1; } data[ insertPos ] = insertVal; } /* Replace original lower-boundary element */ data[ firstElement-1 ] = lowerBoundary; }
3
How Not to Manage Your Software Project
4
The Result of Bad Coding…...Poor Joel
5
Managing Complexity When projects fail due to technical reasons, most often it is due to uncontrolled complexity. There are two different classes of complexity: - Accidental - Essential
6
Fighting Complexity The key to beating complexity is a two- pronged approach. – Reduce the total essential complexity that any one person may have to deal with at one time. -- Prevent accidental complexity from unnecessary dissemination.
7
Design Through a Little T & E Designing is a heuristic process. This all means that designing involves trial and error testing. While initial steps of design may start with a basis of what to try, nothing is guaranteed to solve the design dilemma.
8
When you think you have found a good design solution, continue looking, and try another. Iteration helps one gain more understanding about the design both from a high-level and a low-level perspective. Iterative Design
9
Information Hiding Information hiding is vital for any design. It is one of the few theoretical techniques that has been inarguably shown as valuable for its contribution toward a good design. Asking the question “What should I hide?” will help to remove a lot of the confusion.
10
Illuminating the Logical Organization The one key to visual layout is to enunciate the logical organization of the code. Four characteristics determine if this is successful: – Correctly shows the logical structure – Constantly shows the logical structure – Enhances readability – Persists through modifications
11
Looking Good is Secondary Pretty looking code is always second to code that shows its structure. General rule is that logically organized code will make good looking code.
12
Pure-Block Layout Use Visual Basic and enjoy pure-block layout! It is pretty code, formatted for you! Strongly recommended to use this layout for our viewing pleasure. For C++, either pure-block or begin-end block boundaries work well.
13
Consistent Code Structuring We need to make sure that code is readable not only by humans, as well as computers. The details are less important it is that the program is consistently structured. Martin Fowler
14
Weeding Through Potential Layouts Use the criteria for a good layout to determine the subjective reasons versus the objective reasons. Weighing the different advantages of layouts will help determine how effective each one is.
15
Good Code Summary Coding is trial and error, do not expect to find your solution right off the bat. Reduce complexity! Enhance code layout through a structure- based code layout. Keep it consistent!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.