1 / 6

Opening comments

Opening comments. Annoucements. Office Hours: MGH 450, 2:00-3:00pm Course webpage almost up! http://www.cs.washington.edu/education/courses/cse143/CurrentQtr/AC/. Section swaps. Make sure you get e-mail from me today on the section list!

lyris
Download Presentation

Opening comments

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Opening comments Annoucements Office Hours: MGH 450, 2:00-3:00pm Course webpage almost up! http://www.cs.washington.edu/education/courses/cse143/CurrentQtr/AC/ Section swaps • Make sure you get e-mail from me today on the section list! • If you want to move out (or in) get it settled this week! Newsgroup • READ IT!

  2. Basic Style Guidelines • Tip 1: Read the style guide and memorize it. • Tip 2: Stay consistent. If you do myVar, there should not be an • other_var. If you do if(cond) {, then there should not be • if(cond) • { • Tip 3: Use descriptive variable names. An ‘f’ is not descriptive • Tip 4: Don’t comment things in that are obvious: • cin >> f; // loads a value into f.  bad. Code clutter. • Tip 5: If you can’t remove all your comments and still understand • without much work, you probably screwed up. Count on your • variable names and function names to convey the bulk of the • information. • Tip 6: Quote from Amer: “If it isn't aesthetically pleasing, it's • probably wrong.” • Tip 7: If it doesn’t make sense to you, don’t do it. • Tip 8: Argue with me or listen to me. Don’t just ignore me. • Tip 9: Style is a religious issue. However, some religions are just • wrong. • Tip 10: The text book does not show good style. Follow it and die.

  3. Homework 0 oddities

  4. Grouping of Related Items - 1 • Related lines of code in a function should be group together by surrounding them with extra newlines and optionally comments. • int printHello() { • string name; • /* Prompt user for name */ • cout << “Hello! Can I please have your name?”; • cin >> name; • /* Print out reply */ • cout << “Hi! You enetered “ << name “ as your name” • << endl; • return 0; • }

  5. Grouping of Related Items - 2 • Related sets of functions and data structures (functions and data structures that have high cohesion) should be groups in a module. • promptUser.h – Good • int promptInteger(string message); • double promptDouble(string message); • string promptString(string message); • promptUser.h – Not Good • int promptInteger(string message); • double promptDouble(string message); • string promptString(string message); • double fToH( double fahrenheitTemp );

  6. ADTs and sensible data manipulation ADT – Abstract Data Type An Abstract Data Type (from my understanding at least) is what you call a method of organizing data and the operations that you can use to ‘mutate,’ ‘access,’ and ‘interpret’ the data. Sensible Data manipulation An Abstract Data Type is just data – an abstract description of a type. To implement one in a language, often times the best way to do it is to have a grouping of relevant data and a slew of functions that act on it. To make things even cleaner, it is often times the case that you would want make it so that you can only look at and manipulate the data through these functions. Another idea that is not as related to ADTs, but can be helpful in their implementation is that of functional programming. It is conceivable that you could write fToC like this: void fToC( double &temp ) where the convereted value would be placed back in the paramter. However, it will often be cleaner to write it like double fToC( double temp ) where the result is given back without affecting the parameter. Stick to this and you will make your life simpler.

More Related