Style Rules I. Style is important Everyone agrees that good style is important –Everyone agrees on most of the essentials –But some people have “religious.

Slides:



Advertisements
Similar presentations
Microsoft® Word 2010 Training
Advertisements

Microsoft® Office Word 2007 Training
How to Write a Response Card By Michael Morrello, Licensed Psychologist based on Judith Becks book, The Beck Diet Solution.
Collaborating By: Mandi Schumacher.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
1-May-15 Style. 2 About the book This book is a team effort by many good programmers, not just one person’s opinions The rules have been widely distributed.
WRITING CRITIQUE GROUP GUIDELINES Writing responses to your group members’ work and receiving responses from others is the most important step in revising.
Examples of life goals: 1.Live on my own or with a family of my own. If I have this, I can use my non-working time how I see fit. FREE TIME! 2.Keep a job.
Tips for Scouts.
Cooperative Online Writing Lab Bluefield College COWL, 2005 Writing Concepts for ESL Students.
Starter: Vary your sentences How many types can you name? 1.Simple 2.Compound 3.Complex 4.Minor 5.Questions, especially rhetorical 6.Rule of three. For.
Everything you need to know in order to set up your Reader’s Notebook
Microsoft ® Office Word 2007 Training Bullets, Numbers, and Lists ICT Staff Development presents:
Debugging Introduction to Computing Science and Programming I.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Fibonacci Numbers A simple example of program design.
15-Jun-15 Style Consolidated Lectures. 2 About the book This book is a team effort by many good programmers, not just one person’s opinions The rules.
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.
26-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.
Tips for Working Successfully in a Group Disclaimer: This is not a “good” format for a presentation. There is too much text on the pages.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Notes for your sketchbook: The Three Modes of Art Making.
Creating your UCAS Personal Statement.
Cornwall Expedition Scouts The Czech Republic 2014 Click anywhere to continue Mutiny.
Word Create footnotes and endnotes. Course contents Overview: Be a footnote and endnote whiz Lesson 1: Add footnotes and endnotes Lesson 2: Beyond the.
Teens & Parents: How to Earn Your Parent’s Trust
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Microsoft ® Office Word 2007 Training Create Your First Document ICT Staff Development presents:
What is Assertiveness? It is the ability to honestly express your opinions, feelings, attitudes, and rights, without undue anxiety, in a way that.
Word Revise documents and keep track of changes. Use Track Changes and comments Course contents Overview: Insertions, deletions, comments Lesson 1: Stay.
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
’Fess up Taking Responsibility for your Actions. Everyone makes mistakes. You wouldn't be human if you didn't. The fear of making mistakes can prevent.
PET for Schools. Paper 3: Speaking What’s in the Speaking Test? Part 1: You answer the examiner’s questions about yourself and give your opinions. Part.
Organization The One Minute Organizer – Donna Smallin.
Microsoft Word Objective: Understand Basic Word/Word Processing Skills Lesson: Create and Save a New Document LOL: Understand/Apply Create your first Word.
Social Media Roundup Bad social media: 7 Ways to lose your audience.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Styles of Leadership LET II. Introduction Leadership styles are the pattern of behaviors that one uses to influence others. You can influence others in.
23-Oct-15 Style. Why style matters Good style isn’t just to make your code “look pretty” The most critical factor in style is readability If a program.
1 How-To Guides Explaining a Process, Giving Advice.
Model View Controller A Pattern that Many People Think They Understand, But Has A Couple Meanings.
Blog Responses For some times, i do not know where or how I'm supposed to turn some work in. For example, i had no idea how to submit my grandparent.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
Get to know: YOURSELF!!!. Extrovert  Extraversion (E) I like getting my energy from active involvement in events and having a lot of different activities.
Microsoft ® Word 2010 Training Create your first Word document I.
Chapter 5 Files and Exceptions I. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. What is a file? A.
Responding to Reviewers. Rare to get an acceptance with no changes So two paths, rejection or revise and resubmit Rejection Revise and Resubmit.
Human Resources. Soon you will become a job-seeker… Once you understand what employers are looking for, you can begin building your skills and personal.
High Frequency Words.
RESUME WRITING HELP YOUR RESUME STANDOUT…IN A GOOD WAY!!
SOLID Liskov substitution principle Barbara Liskov in a 1987 conference keynote address entitled Data abstraction and hierarchy In a computer program,
© 2015 albert-learning.com How to talk to your boss How to talk to your boss!!
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
Validation. What is Validation? Removing errors improves the consistency of how our pages look to a wide variety of browsers and devices. Ensuring that.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
FRIENDS. What is a Friend?  A friend is someone you like and who likes you.  A friend is someone you can talk to.  A friend is a person who shares.
25 minutes long Must write in pencil Off topic or illegible score will receive a 0 Essay must reflect your original and individual work.
Are you a Left Brain or Right Brain?
Learn all about anger and healthy ways to cope!
Dilbert Scott Adams Manage It! Your Guide to Modern, Pragmatic Project Management. Johanna Rothman.
Which Path Would YOU Take?
Microsoft® Word 2010 Training
Microsoft® Word 2010 Training
Extraversion Introversion
Software Testing and Maintenance Modifying Code
Beginning Style 27-Feb-19.
Presentation transcript:

Style Rules I

Style is important Everyone agrees that good style is important –Everyone agrees on most of the essentials –But some people have “religious wars” over style –It’s the subtle points that get people really upset Subtle points mostly aren’t very important The essential points make a clear difference, so these are the ones people can agree on...Just like a lot of other things in life!

About the book This book is a team effort by many good programmers, not just one person’s opinions The rules have been widely distributed and commented upon The rules reflect widespread and accepted practices And no, I don’t agree with everything in the book!

Rule 1 Adhere to the style of the original Consistent style is very important Most times, you will enter an ongoing project, with established style rules –Follow them even if you don’t like them –Don’t try to establish “better” style rules It won’t work anyway There may be reasons you don’t know about If a project has mixed styles with no consistency, you might try to get people to agree on one

Rule 3 Do it right the first time You’re working on a large project, so you use good style......but you need a tool to help you do one little job, so you slap it together quickly Guess which program will be around longer and used by more people?

The “broken window” theory In inner cities, some buildings are beautiful and clean, while others are rotting hulks. Why? Researchers in the field of crime and urban decay discovered a fascinating trigger mechanism, one that very quickly turns a clean, intact, inhabited building into a smashed and abandoned derelict. A broken window.

From “The Pragmatic Programmer” Don't leave “broken windows” (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a "Not Implemented" message, or substitute dummy data instead. Take some action to prevent further damage and to show that you're on top of the situation.

Rule 5 Indent nested code Always indent statements that are nested inside (under the control of) another statement if (itemCost <= bankBalance) { writeCheck(itemCost); bankBalance = bankBalance - itemCost; } while (seconds > 0) { System.out.print(seconds + "..."); seconds = seconds - 1; }

Indenting particular statements Java has several kinds of statements, and the book tells how to indent each The general form is usually like this: –controlling-statement { nested-statements } Sometimes I violate good style on these slides because I have to make it all fit!

How much should you indent? If you indent too little, the indentation is harder to see and doesn’t help very much If you indent too much, deeply nested code gets pushed too far to the right In general, 2 to 4 spaces seems about right –The book suggests 2 spaces –BlueJ’s default is 4 spaces Just pick a number and stay with it

Rule 6 Break up long lines Scrolling a window horizontally is a pain! When you print on standard paper, long lines are either cut off or wrap in bad places I have long used a 72 character limit Some editors will show you a limit line The book provides good advice on how to break up long lines (read it!)

Rule 8 Don’t use “hard” tabs Once upon a time, you could depend on tab stops every eight character positions Today, every editor has its own idea of where and how to set tab stops If you change editors, your nice indentation gets ruined –It’s worse if you use both tabs and spaces –I have learned this one the hard way!

“Soft” tabs Some editors (the good ones) will let you set a preference so that, when you type a tab, the editor automatically uses the right number of spaces instead –This is what is called a “soft” tab BlueJ uses exclusively soft tabs (as of 1.1.4) –Use tabs all you like in BlueJ –Remember that most editors don’t do this automatically

What about the rules I skipped? Those rules are important, too I’m skipping around for a variety of reasons: –Rules 2 and 4 will make more sense later –Rule 7 has too much detail to talk about right now (but it’s a good rule!) I’ll try to talk about every rule in class This is a good book, worth reading several times

The End