Good programming practices updated

Post on 19-Jan-2015

99 views 2 download

Tags:

description

 

Transcript of Good programming practices updated

Good Programming PracticesJack Boys

Topics

• Practice Try and Fail• Breaking a Problem: Work In

team• Be a coding Ninja• ABC Always be coding• Bug Debug and error• Testing • Conclusion

Practice Try and Fail

• Basic of programing: Write Code on paper

• Improve your syntax• Thinking are clear• Improves Ability to remove a bug

or syntax error.• Time your self• Divide a task into subtask• If stuck interview your self• Ask a friend• Don’t love your code

Breaking a Problem: Work in Team• Make team of at least 2• Use flow charts flow diagram to

solve a problem• Solve tough coding problem in

front of your team• Admire one for asking and for

giving a solution• Ask the team why we are solving

in certain way• Discuss about alternate solution• In market you have to work like a

team

BE A CODING NINJA

Be a Coding Ninja

• Nail the programming fundaments

• Write an attractive peace of code• Add handsome comment to your

code, Comment should be in same level of code

• Commenting should be simple that after a year when you read your comment you can understand what your code is doing

Be a Coding Ninja

• Indent your code, it improve readability

• Use switch statement instead of if else if else

• Introduce functions in code• Work think like a pro• Use standard variable naming i.e.

Pascal casing and camel casing• Variable name should be

meaning full

Be a Coding ninja

• Every line of code should be useful

• A method should be not more than 30 lines

• Refactor your code, eliminate useless code

• Make the variable private or protected and expose public/ protected properties.

ABC: Always be coding• Join programming society in your

institute• Participate in programing

competition i.e. online, inside outside university

• Teach your junior it will help you keeping your coding saw sharped

• Programming is not something you can master in a couple of weeks. Set yourself a realistic target of a month and a half.

Bug Debug and error

• Your code should crash gracefully and with honor

• Use try catch throw technique its called exception handling

• Exception handling will help you finding the error

• Be a code snippiest you should know why your code have crash

Test your Program

• Test your program that it gives the correct answer we desired

• End user of your program are dull so your code should be flexible

• Give your code to your friend for testing

• Test weather the way we started to solve the problem had we covered all of them.

Class ActivityWrite down a c program which prints your complete name in the output screen, you have to use If else statement. One printf command will print your first name while the second will print your second. You have to use If else statement.You have to use GOOD PROGRAMMING PRACTICE to break this problem.HINT: One printf will be executed in checking of if statment

Solution

#include<iostream>using namespace std;void main(){if (!printf("Muhammad\n")){}elseprintf("Iqbal\n");system("pause");}