Naming Programming Studio Spring 2008 Lecture 2. Purpose of Coding.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
 Lex helps to specify lexical analyzers by specifying regular expression  i/p notation for lex tool is lex language and the tool itself is refered to.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
15-Jun-15 Beginning Style. 2 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don’t.
CS1061: C Programming Lecture 23: Review; Examination Details A. O’Riordan, 2005.
CP Week 2 zReserved words zVariables zInput and output zData types zTesting and Documentation.
1 Introduction to Software Engineering Lecture 42 – Communication Skills.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
Introduction to a Programming Environment
Adapted from Dr. Craig Chase, The University of Texas at Austin.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
General Issues in Using Variables
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Group practice in problem design and problem solving
Code as Communication Programming Studio Spring 2015.
CPS120: Introduction to Computer Science Lecture 8.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
1 Chapter 9 Scope, Lifetime, and More on Functions.
Communicating in Code: Naming Programming Studio Spring 2013.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
Java Data Types Data types, variable declaration, and initialization.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
CPS120: Introduction to Computer Science
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Web Database Programming Week 3 PHP (2). Functions Group related statements together to serve “a” specific purpose –Avoid duplicated code –Easy maintenance.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Type Conversions Implicit Conversion Explicit Conversion.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
1 Building Java Programs Chapter 7: Arrays These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Guidelines for a Language- Independent Convention Identify global variables –Use g_prefix –Exp: g_RunningTotal Identify module variables –Use m_prefix.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Introduction to C Programming Lecture 6. Functions – Call by value – Call by reference Arrays Today's Lecture Includes.
©John Samuel 2008 Introduction to PHP. ©John Samuel 2008 Objectives At the end of this class the student will be able to; Create and run a simple php.
INT213-Week-2 Working with Variables. What is variable
Computing and Statistical Data Analysis Lecture 2 Glen Cowan RHUL Physics Computing and Statistical Data Analysis Variables, types: int, float, double,
Communicating in Code: Naming Programming Studio Spring 2009.
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
CPS120: Introduction to Computer Science Variables and Constants.
Review of HTML and CSS A (very) brief review of some key fundamentals to be aware of in IT-238.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Bill Tucker Austin Community College COSC 1315
Computing and Statistical Data Analysis Lecture 2
Communicating in Code: Naming
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Functions, Procedures, and Abstraction
CMSC 202 Java Primer 2.
Tonga Institute of Higher Education
Tonga Institute of Higher Education
EECE.2160 ECE Application Programming
Functions, Procedures, and Abstraction
CMPT 120 Lecture 4 – Unit 1 – Chatbots
Communicating in Code: Naming
Presentation transcript:

Naming Programming Studio Spring 2008 Lecture 2

Purpose of Coding

To give the computer instructions?

Purpose of Coding To give the computer instructions

Purpose of Coding To give the computer instructions To demonstrate your skill?

Purpose of Coding To give the computer instructions To demonstrate your skill

Purpose of Coding To give the computer instructions To demonstrate your skill An effective way to express ideas of what you want the computer to do

Purpose of Coding An effective way to express ideas of what you want the computer to do Communication! –To the computer –To yourself (later on) –To others

Names We assign names throughout a program Good names are better than good documentation –They are a critical part of documentation –With good naming, other comments are often unnecessary!

Naming Gives identity Implies behavior/purpose Makes it recognizable

What gets named? Variables Functions Types/classes Namespaces Macros Source Files

Choosing Names Sometimes there are naming conventions –If you work at a company that has an agreed convention, follow it! But, there are several “wise” ideas to consider when choosing names.

Naming Considerations Be sure it’s not reserved (Duh!) Sometimes it’s easy to forget… 1.Make it informative 2.Keep it concise 3.Make it memorable 4.Make it pronounceable

Informative Names The amount of information a name needs depends on its scope – understand it when seen Use descriptive names for globals, short names for locals s = 0; for (WhichGroup=0; WhichGroup<num; WhichGroup++) { s += G[WhichGroup].n(); }

Informative Names The amount of information a name needs depends on its scope Use descriptive names for globals, short names for locals nAnimals = 0; for (i=0; i<NumAnimalGroups; i++) { nAnimals += AnimalGroup[i].getnumber(); }

Descriptive Names Names should convey what it represents or does, unless obvious from context Functions: Active names –AnotherStudent(s) vs. AddStudent(s) –Query functions different: numStudents() Booleans: Be clear what is returned –checkEOF vs. isEOF

Conventions Lots of conventions out there Globals have initial capital letters Constants are in ALL CAPS Etc.

Conventions Beginning/ending with a p if a pointer Starting with n for a number i, j are integer indices s is a string, c or ch are characters

Consistent Names Key: Be Consistent! –nKids, numKids, num_kids, NumKids, nkids, Number_Kids Functions too: Write1stObject() WriteSecondObject() write_third_object()

Other Random Considerations Beware of “temp” variables Be careful of reusing variable names Be careful of overloading names

Hungarian Naming Convention Base types: –wnWindow –scrScreen Region –fonFont –chCharacter –paParagraph Eg: wnMain, scrUserWorkspace

Hungarian Naming Convention Prefixes –aarray –ccount –ddifference between two variables –eelement of array –gglobal variable –hhandle –iindex into array E.g. iwnUserView = index into array of windows giving user views