welcome to sigsoft
DESCRIPTION
Welcome to SIGSoft. Who are we?. Chairs: Drew Cross Eric Parsons Treasurer: Dylan Nugent “Authorized Agents”: Ciara Proctor Sean Nicolay What SIGSoft was like last year. What to expect from us this year. Side note: Our meetings will become much more informal over time. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/1.jpg)
Welcome to SIGSoft
![Page 2: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/2.jpg)
Chairs: ◦ Drew Cross◦ Eric Parsons
Treasurer: ◦ Dylan Nugent
“Authorized Agents”: ◦ Ciara Proctor◦ Sean Nicolay
What SIGSoft was like last year. What to expect from us this year.
◦ Side note: Our meetings will become much more informal over time
Who are we?
![Page 3: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/3.jpg)
Permanent Room TBA via newsgroup eventually…
Today: “Random” examples of bad code Next week: Possibly a GIT tutorial Survey results
Announcements
![Page 4: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/4.jpg)
As of 12pm Tuesday
![Page 5: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/5.jpg)
![Page 6: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/6.jpg)
What do you think about this?
![Page 7: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/7.jpg)
This is a misuse of white space In this example, the --> is a combination of
the decrement operator (--) and the greater than operator (>).
Note: the -> operator does exist in C/C++
There is no --> operator
![Page 8: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/8.jpg)
Now what do you think?
![Page 9: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/9.jpg)
On the previous slide, a while loop is performing an action typically performed by a for loop.
By switching to a for loop, the comparison and the decrement operation are isolated. This separation helps make the code easier to understand.
Use appropriate control structures
![Page 10: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/10.jpg)
Two examples of scope brace placement
Either is fine, just be consistent
I prefer the latter because of screen real estate and putting the opening brace on a new line does not convey new information to me.
![Page 11: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/11.jpg)
On the previous slide I showed two examples of curly brace place placement. Either is fine if you are consistent about your usage.
This point is moot in Python as it uses whitespace (indentation) for indicating scope.
If you join a project and everyone is following a coding convention (variable names, indentation, etc) conform to their convention; don’t try to change conventions mid-project unless there is a really good reason to.
Coding conventions
![Page 12: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/12.jpg)
Managing Complexity"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?”
--Brian Kernighan
The human brain can only handle so many tasks at once. (about 7)
Always strive for simplicity and clarity when designing your programs and when choosing names for classes, methods/ functions, and variables.
Write simple/clear code first and profile it. Only then perform optimizations.◦ “…premature optimization is the root of all evil.” –Donald Knuth
Key Point
![Page 13: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/13.jpg)
From Code Complete: Second Edition (pg 260)
What is this java code doing?
![Page 14: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/14.jpg)
Don’t be afraid to write longer names if needed (but be concise!) For example: numStudents is better than numberOfStudentsInTheClass Learn the AutoComplete shortcuts for your editor
◦ Vim: Ctrl-n Eclipse: Ctrl-Space, or Cmd-Space on Mac
Now with sane names…
![Page 15: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/15.jpg)
Bad variable names: myInt, arr, thing1, returnVal, input, output, result, a, b, c
Short names can be ok but think before using them. ◦ i.e. x,y,z for Cartesian coordinate system i,j,k for loop control
I can’t stress the power of good names enough!Which is why the next talk I (Eric) do will be on naming conventions.
A more real-world example…
![Page 16: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/16.jpg)
Hint: these are all different files and I could have picked any one of about 200 others for this example…
What is wrong here?(Aside from the fact that PHP is being mixed with HTML)
![Page 17: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/17.jpg)
In the previous slide, the PHP/HTML that generates the site’s overall layout is duplicated via copy/paste in a couple hundred files.◦ If you wanted to make a site wide change you would
have to either: Hope the relevant file was an include that all the pages used Go through every file making your changes to each Re-write the site to eliminate the repetition and separate
logic from presentation
As a result, this site is inflexible and making changes is difficult and tedious
Repetition
![Page 18: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/18.jpg)
If you find yourself wanting to violate DRY by copy-pasting code, refactor instead
Benefits of not repeating code◦ Single place for change◦ Can give a name to the set of operations being performed (Reducing complexity)
Also: Don’t reinvent the wheel. Chances are that someone has had to solve the problem you are now facing. Maybe that solution uses a software license compatible with your code.
DRY (Don’t Repeat Yourself)
![Page 19: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/19.jpg)
The GIT version control system
Next Talk
![Page 20: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/20.jpg)
Engineering Open House (EOH)◦ Will be held March 9-10, 2012
Sample Ideas: (Feel free to use them if you are stuck)◦ Where are my classes? http://goo.gl/jQZ0e◦ Hex Game w/AI opponent
http://en.wikipedia.org/wiki/Hex_(board_game)◦ Import class schedule into Google Calendar◦ Continue working on IdeaMine
Projects
![Page 21: Welcome to SIGSoft](https://reader030.vdocument.in/reader030/viewer/2022013004/56816854550346895dde6597/html5/thumbnails/21.jpg)
Break into groups based on interest Work on just coming up with an idea or
problem statement for now◦ However, if your group is set on an idea, let me
know Repository access
Share contact info◦ You can post to the newsgroup (please do) but if
you have a set of specific people that you want to contact, please try to email each other.
Projects