Design Part II Getting Ready to Build!
description
Transcript of Design Part II Getting Ready to Build!
![Page 1: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/1.jpg)
Kunal Johar Design Part III 1
Design Part II Getting Ready to Build!
Kunal JoharCSCI 4243 (Senior Design)
The George Washington University
![Page 2: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/2.jpg)
Kunal Johar Design Part III 2
Where are We in Design?
• Specifications Document Development– Idea / Problem Statement– High Level Requirements– Use Cases– Functional / Non-Functional Requirements– Components Needed– Workflow
![Page 3: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/3.jpg)
Kunal Johar Design Part III 3
Where are We in Design?
• UI / Mockups
• Final Workflow
• Data Structures / Algorithms
• Third Party APIs
![Page 4: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/4.jpg)
Kunal Johar Design Part III 4
Where Are We in Development?
• Bootcamp I Complete
• Bootcamp II in Progress
![Page 5: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/5.jpg)
Kunal Johar Design Part III 5
What is Next?
• Design Part III– Coding Structure– Repository Setup– Test Plan– Development Task List / Estimation
• Bootcamp II
• 30% Demo!
![Page 6: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/6.jpg)
Kunal Johar Design Part III 6
Good Code Structure
• Why Bother? What are some traits?
![Page 7: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/7.jpg)
Kunal Johar Design Part III 7
Good Code Structure
• Remember Shop Vote?
![Page 8: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/8.jpg)
Kunal Johar Design Part III 8
Shop Vote Code Structure
• How would you lay out your code?
![Page 9: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/9.jpg)
Kunal Johar Design Part III 9
Which Is Better?
/Data
- Vote.java
- Images.java
/Logic
- Vote.java
- Images.java
/Configuration
- General.java
- Votes.java
/Vote
- Data.java
- Logic.java
- Configuration.java
/Images
- Data.java
- Logic.java
GeneralConfiguration.java
![Page 10: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/10.jpg)
Kunal Johar Design Part III 10
Attributes of Good Structure
• Well defined, yet simple
• Intuitive to you and other developers
• Extensible– Supports additions without needing to create
a new “structure”
• Good News: There are techniques for this!
![Page 11: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/11.jpg)
Kunal Johar Design Part III 11
Naming Conventions
• CONSTANTS _constants
• VariableNaming variableNaming
• Methods / Procedures()
• Classes
• Sounds a bit OO– How about C? Or LISP?
![Page 12: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/12.jpg)
Kunal Johar Design Part III 12
Naming Conventions
• Why Have Them?– Make code readable– Common construct for developers of a
language– Fundamental to the success of an open
source project
– Makes code safer! Really.http://www.joelonsoftware.com/articles/Wrong.html
![Page 13: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/13.jpg)
Kunal Johar Design Part III 13
Where To Start
• Find a code writing style guide– Java (http://www.oracle.com/technetwork/java/codeconv-
138413.html)
– Javascript (http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml)
– C# (http://www.akadia.com/services/naming_conventions.html)
– Haskell (http://urchin.earth.li/~ian/style/haskell.html)
– C / Systems Code (http://www.seas.gwu.edu/~gparmer/csg.pdf)
![Page 14: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/14.jpg)
Kunal Johar Design Part III 14
Read Their Rules
• Capitalization Style– PascalCase, camelCase, UPPERCASE
• Notation– Brief: SetScrollX– Verbose: SetHorizontalScrollPosition– Hungarian: fBankBalance,
studentCurrentStudent
![Page 15: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/15.jpg)
Kunal Johar Design Part III 15
Add Your Rules
• Special Classes
• Folder Naming Structure
• Packages / Name Spaces
• What is a Name Space?– edu.gwu.cs.BiFi
![Page 16: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/16.jpg)
Kunal Johar Design Part III 16
Shop Vote
• C# Language
• Server Side and iPhone Application
• “Simple” application– How would you lay out the server side?– How about the client side?
![Page 17: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/17.jpg)
Kunal Johar Design Part III 17
Shop Vote
• Even Simple Applications Need Structure
![Page 18: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/18.jpg)
Kunal Johar Design Part III 18
Intro to Design Patterns
• Idea that code creation follows patterns depending on what code is for
• Widely accepted concepts on how to structure code
• Implemented across standard libraries for countless langages
![Page 19: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/19.jpg)
Kunal Johar Design Part III 19
Naming Conventions on Steriods
• Creational patterns– Builders, Factories, Singleton
• Structural patterns– Wrappers, Bridges, Proxies
• Behavioral Patterns– Iterators, Observers, States
• Concurrency Patterns– Lock, Monitor, Thread, Pool
![Page 20: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/20.jpg)
Kunal Johar Design Part III 20
Comments
• Intuitive code means fewer comments– Good naming conventions– Avoid complex code
– Loosely couple components• What does this mean?
![Page 21: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/21.jpg)
Kunal Johar Design Part III 21
Documentation
• Comment public properties / public methods
• Use a documentation tool– http://www.stack.nl/~dimitri/doxygen/
![Page 22: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/22.jpg)
Kunal Johar Design Part III 22
Setup a Repository
• Git, SVN, Mercurual
• Herve spoke to you about this a few weeks ago
• No excuse for not having one setup
• Decide when you will check in code– Only working code?– Only after full modules are built?– Make sure you comment your check ins
![Page 23: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/23.jpg)
Kunal Johar Design Part III 23
In Class Exercise
• Write out the authentication class of the web service
• Then write a set of unit tests to confirm the functionality works
• Use realistic pseudocode
![Page 24: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/24.jpg)
Kunal Johar Design Part III 24
Let’s Take a Look at ShopVote
• Model View Controller
• Makes Unit Testing a Lot Easier
• Two repositories– Server side – Client side (phone)
• [Link to code spaces]
![Page 25: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/25.jpg)
Kunal Johar Design Part III 25
Project Management Planning
• Better idea of difficulty of your project after Bootcamp I and II
• But to get to 30% we need a Bootcamp III
• 30% - 100% can then be defined
![Page 26: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/26.jpg)
Kunal Johar Design Part III 26
Plan a Daily Activity
• What to develop first?– The hard stuff
• What to develop last?– Get everything working– Make everything look good– Get a few things to look great
http://www.joelonsoftware.com/articles/fog0000000018.html
![Page 27: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/27.jpg)
Kunal Johar Design Part III 27
Filling in the Empty Shell
• Build a Shell of Major Functionality
• Fill in the shell with code
• Use Unit Tests and Mock Objects to test subcomponents– These won’t catch all errors but will help
narrow them down
![Page 28: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/28.jpg)
Kunal Johar Design Part III 28
Unit Testing
• Ensure baseline functionality works• Speeds up Debugging
• Does not require custom tools– Method stubs with expected return values
• Tools Do Help Though – JUnit / JMock– NUnit
![Page 29: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/29.jpg)
Kunal Johar Design Part III 29
Project Management Tools
• “Task List” manager• Time Estimation
• MS Project– Large learning curve, very powerful– Useful for large projects with large teams (building an airplane)
• Assembla, Google Code, Microsoft CodePlex– Simpler task tracking “ticketing” tools– Bug Tracking / Feature Tracking– Integrate with repository
![Page 30: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/30.jpg)
Kunal Johar Design Part III 30
Bootcamp III
• What are the remaining challenging parts of this project?
• What are the frameworks / APIs that need setup
• What do you have the least control over?
![Page 31: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/31.jpg)
Kunal Johar Design Part III 31
ShopVote Bootcamp III
![Page 32: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/32.jpg)
Kunal Johar Design Part III 32
30% - 100%, 110%
• Look at HW5.pdf for remaining tasks– Get the framework done
• E.g. Site map, login screens• These are easier to do now than later
– Look at your workflow steps with no dependencies
• Integrate components that depend on them• Repeat
![Page 33: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/33.jpg)
Kunal Johar Design Part III 33
Time Estmiation
• For each task– Write a description– Write a test plan to ensure results work– Estimate Time
• Time = (Coding + Testing + Integration)*P
• P = Polish, which means 3x your expected effort
![Page 34: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/34.jpg)
Kunal Johar Design Part III 34
Task Strategy
• For each major work flow create a single large task– Break each task into sub tasks of 4-6 hour
blocks
– Bootcamp tasks are all resolved so these remaining tasks are manageable chunks
• (Bootcamp tasks can be dozens of hours each)
![Page 35: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/35.jpg)
Kunal Johar Design Part III 35
What can you do in 4 hours?
• Code the front end of a single UI form
• Code the backend of a single UI form
• Develop a handful of API calls
• Input a medium (15 table) database scheme and map it to code
![Page 36: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/36.jpg)
Kunal Johar Design Part III 36
What can you do in 4 hours?
• Nothing if there are even minor distractions
• Nothing if you run into a nasty runtime error
• Nothing if you focus too hard on a minor problem (repositioning controls on a resize)
![Page 37: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/37.jpg)
Kunal Johar Design Part III 37
Work Plan
• You know how you work besthttp://www.paulgraham.com/makersschedule.html
• I recommend– 2-4 hours of coding per day– 1 day off per week– 1 marathon coding session per week– 4 hours, 1 hours testing, 3 hours fixing,
1 hour refactoring (why?)
![Page 38: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/38.jpg)
Kunal Johar Design Part III 38
Formulate Task List
• [Code Spaces Link]
• How long do you think each task should take us?
• Let’s talk about how long they really took us
![Page 39: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/39.jpg)
Kunal Johar Design Part III 39
In Class Exercise
• Start work on your coding plan
• Find a naming convention
• Determine initial directory structure
• Determine Bootcamp III tasks
![Page 40: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/40.jpg)
Kunal Johar Design Part III 40
Discipline + Good Code Structure
• Structure alone is insufficient
• We can’t forget good general coding rules
http://developerart.com/publications/4/wise-programming-techniques-for-writing-quality-code
![Page 41: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/41.jpg)
Kunal Johar Design Part III 41
Avoid Quick Hacks
• Y = Z/N
• Transform it to
If (N == 0) {Z=0;N=1; Y= Z/N}
![Page 42: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/42.jpg)
Kunal Johar Design Part III 42
Write Self-Explanatory Code
• SendThumbnailToAmazonS3(image);
• SendPushNotifications(contacts[], message){ foreach (contact c in contacts) SendPushNotification(message, c.DeviceID)}
![Page 43: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/43.jpg)
Kunal Johar Design Part III 43
Avoid Showing Off
• A = A ^ BB = A ^ B
• A = A ^ B
![Page 44: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/44.jpg)
Kunal Johar Design Part III 44
Avoid Dense Code Blocks• Acc[categoryC] += GetUniqueHours(start, end) * 24;
categoryC = NextCategory(categoryC, lookupCodes);
TotalTime += Acc[categoryC];MaxTotalTime = Acc[PrevCategory(categoryC, lookupCodes] + TotalTime;
This is the cleanest part of a 2,000 line time sheet generator that I wrote. Updated to:
foreach (TimeSheetCategory tc in TimeSheetCategories){ decimals timeInDays = GetTimeForCategory(start, end, tc); TotalTime += timeInDays; TotalTimePlusOverhead += timeInDays * 2;}
![Page 45: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/45.jpg)
Kunal Johar Design Part III 45
Avoid Duplicative Functionality
• Windows APIs– ShellExecute– ShellExecute32– ShellExecuteEx– ShellExecuteEx32– ShellExecute64
![Page 46: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/46.jpg)
Kunal Johar Design Part III 46
Other Tips
• Avoid “magic constants”– Place all constants in a properties or config file / class
– Keep related code together
– Strive for loose coupling• What does this mean?
– Optimize last!
![Page 47: Design Part II Getting Ready to Build!](https://reader035.fdocuments.us/reader035/viewer/2022081514/56815188550346895dbfbfee/html5/thumbnails/47.jpg)
Kunal Johar Design Part III 47
What Are You Here For?