Introduction to Programming

Uploaded from authorPOINT Lite
Download as
 PPT
Presentation Description 

No description available

Views: 430
Like it  ( Likes) Dislike it  ( Dislikes)
Added: January 22, 2008 This Presentation is Public 
Presentation Category : Education All Rights Reserved
Presentation Transcript

Introduction to Programming: Introduction to Programming Zhang Miao Ph.D Candidate CNPT Lab, CS, Tsinghua University zm@csnet1.cs.tsinghua.edu.cn http://netlab.cs.tsinghua.edu.cn/~zm


Introduction: Introduction NO details for specific language NO details for specific method Try to provide some ideas and guidelines On software development On project management


Outline: Outline How to do programming How to do project Other related topics Introduction to CNPT Lab


What is a software?: What is a software? Some wrong ideas Only code Only a running system Program = language? (VC, Delphi, VB, …)


What is a software? (cont.): What is a software? (cont.) Not only code Design: also the product of a project Document: for both developer and user Code: run, read and maintain Service …… Bill Gates, “make this world better with great software”


一流代码的特性: 一流代码的特性 鲁棒 - Solid and Robust Code Basic Requirement, 正确性 简洁 - Maintainable and Simple Code 简短 - Small Code For maintenance 高效 - Fast Code Performance consideration 共享 - Re-usable Code 可测试 - Testable Code 可移植 - Portable Code (“写好代码的10个秘诀”-微软,林斌)


Write Clean Code: Write Clean Code The code is not written for yourself Write clean code To work with other people To share with other people Responsible to your code It’s my baby!!


Work hard, and work smartly: Work hard, and work smartly Think more, code less Coding only occupies less than 1/3 time Divide and conquer Data oriented (NOT function oriented) To think the data structure first! (Richard Stallman) Programming language does not matter much


Writing Comment: Writing Comment Good comment is necessary for good code Comment is good document Easy to synchronize with the code Some critical comments Function interface description Description of complex functions Description of important variables Natural to write comment when coding


Code Layout: Code Layout Not only an issue of format Indent: to show the logical structure Naming variable To show the meaning of the variable Avoid too long name Author, copyright and date The ownership, and responsibility


Error Detection: Error Detection Assume error is possible for EVERY function invoked assert() and error processing Condition in the assert() is forbidden Pass a NULL pointer to a function Condition in the error processing is possible Get a NULL pointer from malloc() The code in the assert() is not present if not in debug mode


Try to write less code: Try to write less code No need to write too much code Combine code into function when possible Easy to maintain and optimize Search for system functions first E.g., qsort() Many free codes are available At least, it can be a reference design


Style Guidelines: Style Guidelines Small function and small file Much higher error probability in large function Use macro to define const Clear meaning Avoid multiple modification Function declaration in header file Let the compiler work for you!


Style Guidelines(cont.): Style Guidelines(cont.) Localize the variable and function as much as possible Use keyword “static” in C Object Oriented (C++) vs. Object Based (C ): inheritance, polymorphism Viewpoint: data, & operation


Outline: Outline Introduction to programming How to do project Other related topics Introduction to CNPT Lab


Whole Process: Whole Process Investigation Requirement analysis Design & documentation Coding Testing Project summary


Have a plan: Have a plan Identify the goal first The vision should be shared by all the people! Make a clear and feasible plan Often behind the plan is dangerous Have several big milestones Have many little check points Risks Perfect plan is nearly impossible Good plan needs experience and more consideration


Requirement Analysis: Requirement Analysis The resource is limited Consider the resource People, fund, and time The mythical man-month No assumption for your user, do investigation and ask them The requirements have different priority More important to know what we do not need


Design: Design Design before coding As detail as possible Make a modification in the code is VERY hard Doing review, if possible Find a defect as early as possible The modification cost increases aggressively Hierarchical design Divide and conquer


Testing: Testing Very important for large and critical project Person MS: 1:1 NASA: 10:1 White box testing and black box testing Be responsible to your own module! Always no enough test cases Can only find error, but can’t prove right


Project Tracing: Project Tracing Collecting data during the project Some rules exist in the development It is a long time process Includes Modification history Bug report All documents …..


Teamwork: Teamwork It is what we lack most! NO single hero for a large project Microsoft Windows 2000 5000 people work together 50,000,000 lines of code An open environment is preferred Share good ideas with other people


Communication: Communication Communication is everywhere > 50% effort is used in communication The ways of communication: Document Code Talk BBS …. Always to try to improve communication


Conventions: Conventions Better to have conventions in a large project Try to decrease communication cost The “Babel Tower” in the Bible Examples Document conventions Coding conventions Debugging conventions ……


Document: Document Document is VERY VERY important Remind yourself Work together with other people Consider for maintainer Document is NOT restrict to ONE style To make other people understand! To communicate To make yourself understand further


Document (cont.): Document (cont.) What should be documented? Requirement analysis Project conventions Design Discussion memos Project Plan … (everything) Share the document Everyone can reach it!


Using More Tools: Using More Tools The difference between man and ape Tools available Design, Document, Code control, Testing Tools we use now CVS: Much easier to do code synchronization BugTracer


Performance Optimization: Performance Optimization Identify the bottleneck point Avoid assumption, try first! Priority Architecture The specific algorithm The specific lines of code the compiler is more and more smart


Outline: Outline Introduction to programming How to do project Other related topics Introduction to CNPT Lab


The Pursuit of Perfection: The Pursuit of Perfection No end for pursuing the perfection Continuously study and practice Books and documents At least one book every year Think more Don’t avoid doing those tedious things Be patient! No free meal! Rome is not built in one day!


All Aspects of Knowledge: All Aspects of Knowledge Only know how to program is not enough Knowledge of specific area Economic Management ……


Happy Work: Happy Work Don’t work TOO hard Keep your health first! No more time, but more efficiency Collaboration is a joy Promote yourself to high-level programmer Remember you are a student of CS! Utilize the knowledge you have learned!


A Bright Future: A Bright Future China: the most promising market Many companies transfer R&D to China More and more knowledge is open Internet: a good library


Outline: Outline Introduction to programming How to do project Other related topics Introduction to CNPT Lab


Brief Introduction: Brief Introduction Leader: Prof. Wu Jianping Focus now IPv4 / IPv6 dual stack router (863 Project) High Performance Router Tester (863 Project) Protocol Testing Research on many topics Optimizing the process of system development


What can you learn here?: What can you learn here? Knowledge on networking Protocol, network architecture System architecture, OS Software developing process Method of doing research Teamwork Organizing a project


Summary: Summary “立场,观点,方法” Goal Benefit other people Be a useful thing: what is the requirement? Pursuit of perfection Passion It’s my baby! China will be a great country!


Summary(cont.): Summary(cont.) Teamwork No single hero in a large project Enjoy the happiness of cooperation Be professional: focus on work, not people Think less about your own interest Method Work hard and work smartly Keep studying and improving Pay attention to key factors


For more information: For more information For software development, visit http://netlab.cs.tsinghua.edu.cn/~zm/se.html For learning network, visit http://netlab.cs.tsinghua.edu.cn/~zm/booklist.html Feel free to send Email: zm@csnet1.cs.tsinghua.edu.cn Or come here to have a talk,  东主楼9区402室


Slide40: Thank you!