“Name carefully- as if your first-born child.” Think carefully and don’t settle – Try different names until you’re happy – Learn to use built-in IDE refactoring.

Slides:



Advertisements
Similar presentations
Overloading Operators Overloading operators Unary operators Binary operators Member, non-member operators Friend functions and classes Function templates.
Advertisements

1 Java Programming Basics SE-1011 Dr. Mark L. Hornick.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
Lecture 28 More on Exceptions COMP1681 / SE15 Introduction to Programming.
Software Engineering Reading Group: Clean Code Chapter 2 Led by Nicholas Vaidyanathan Lead Visionary, Visionary Software.
Operator Overloading in C++ Systems Programming. Systems Programming: Operator Overloading 22   Fundamentals of Operator Overloading   Restrictions.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
18-Jun-15 Arrays. 2 A problem with simple variables One variable holds one value The value may change over time, but at any given time, a variable holds.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 19 / 2007 Instructor: Michael Eckmann.
25-Jun-15 Managing Complexity Programming is more than just syntax.
© The McGraw-Hill Companies, 2006 Chapter 7 Implementing classes.
Chapter 9 Domain Models 1CS6359 Fall 2012 John Cole.
Operator Overloading in C++
Why You Should Make Smart Flashcards Mark Mitchell & Janina Jolley, 2014 Clarion University of Pennsylvania
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.
The Ruby Programming Language
(c) University of Washington04-1 CSC 143 Java Inheritance Example (Review)
CS5103 Software Engineering Lecture 12 Coding Styles.
C LEAN CODE Predrag Danulabs, O VERVIEW Introduction Meaningful Names Functions Comments Formatting C# Standards and Conventions.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Abstract Syntax Notation ASN.1 Week-5 Ref: “SNMP…” by Stallings (Appendix B)
CS 2430 Day 26. Announcements Exam #2: Wednesday, April 3 –Review in lab on Tuesday, April 2 –Sample problems sent via .
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
What is inheritance? It is the ability to create a new class from an existing class.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting Writing Methods.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
CPS120: Introduction to Computer Science
Objects First With Java A Practical Introduction Using BlueJ Grouping objects Collections and iterators 2.0.
Grouping objects Arrays, Collections and Iterators 1.0.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Exceptions Handling Exceptionally Sticky Problems.
CIT 590 Intro to Programming First lecture on Java.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
A First Look at Java Chapter 2 1/29 & 2/2 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
 2008 Pearson Education, Inc. All rights reserved Operator Overloading.
HashCode() 1  if you override equals() you must override hashCode()  otherwise, the hashed containers won't work properly  recall that we did not override.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010.
1 JAXP & XPATH. Objectives 2  XPath  JAXP Processing of XPath  Workshops.
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
Problem 1 Bank.  Manage customers’ bank account using the following operations: Create a new account given a customer’s name and initial account. Deposit.
CPS120: Introduction to Computer Science Variables and Constants.
A: A: double “4” A: “34” 4.
CSSE 375 Organizing Data – Part 1 Shawn and Steve Q1.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Programming Fundamentals. Today’s Lecture Array Fundamentals Arrays as Class Member Data Arrays of Objects C-Strings The Standard C++ string Class.
DOMAIN MODEL—PART 2: ATTRIBUTES BTS430 Systems Analysis and Design using UML.
Today… Style, Cont. – Naming Things! Methods and Functions Aside - Python Help System Punctuation Winter 2016CISC101 - Prof. McLeod1.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Clean Code Maciej Grabek Software Engineer | Holte Software Poland.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Good practices for readability and maintainability
ECE 382 Lesson 21 Readings Lesson Outline
A Review or Brief Introduction
Refactoring Methods: Kevin Murphy.
Setting Goals.
Review Operation Bingo
T. Jumana Abu Shmais – AOU - Riyadh
Programs and Classes A program is made up from classes
Collections and iterators
Tonga Institute of Higher Education
Widely used guidance for writing better code.
What are the differences between speaking and writing?
“Name carefully- as if a first-born child.”
CS 100: Roadmap to Computing
Collections and iterators
Presentation transcript:

“Name carefully- as if your first-born child.” Think carefully and don’t settle – Try different names until you’re happy – Learn to use built-in IDE refactoring features

Intention-revealing names – Why does it exist? What does it do? How is it used? What unit is it in? – If it requires a comment, keep thinking... int d; // elapsed time in days int elapsedTimeInMinutes; int elapsedTime; “Name carefully- as if your first-born child.”

Avoid disinformation HashSet accountList; long accountName; String numWidgets; HashSet accountGroup; long accountNumber; int numWidgets; int a = l; if ( O == l ) a = O1; else l = 01; “Name carefully- as if your first-born child.”

Make meaningful distinctions – Avoid noise words that don’t add anything – Reader should be able to determine difference between similar items int count; int theCount; int aCount; double amountVariable; String nameString; Customer custObject; getActiveAccount(); getActiveAccounts(); getActiveAccountInfo(); “Name carefully- as if your first-born child.”

Use pronounceable names – “If you can’t pronounce it, you can’t discuss it without sounding like an idiot” class DtaRcrd102 { private Date genymdhms; private Date modymdhms; private final String pszqint = "102"; } class Customer { private Date generationTimestamp; private Date modificationTimestamp; private final String recordId= "102"; } “Name carefully- as if your first-born child.”

Avoid encodings – e.g. Hungarian notation, member prefixes – Has become (largely) unnecessary Modern IDEs, strongly typed languages, trend towards small classes and methods boolean bBusy; int iListSize; PhoneNumber strPhone; private int m_iLastItem; m_iLastItem++; boolean isBusy; int listSize; PhoneNumber phone; private int lastItem; lastItem++; this.lastItem++; “Name carefully- as if your first-born child.”

Be consistent – Pick one word per concept Use fetch, retrieve or get, not all of them – If plural, probably should contain multiple things fetchFullPage() retrieveHeader() getFooter() setTemp(double newTemp) updateTime(double newTime) double scores; int [] score; fetchFullPage() fetchHeader() fetchFooter() setTemp(double newTemp) setTime(double newTime) double sumScores; int [] scores; “Name carefully- as if your first-born child.”

Avoid gratuitous context – Don't prefix every class name in a project Use a namespace instead class MailingAddress { String addrState; long addrZip; } class MailingAddress { String state; long zip; }... String addrState = "MN";... “Name carefully- as if your first-born child.”