1 / 32

Principles of Software (CSCI 2600) Fall 2014

Principles of Software (CSCI 2600) Fall 2014. www.cs.rpi.edu/~milanova/csci2600/ Ana Milanova Lally Hall 314, 518 276-6887 milanova@cs.rpi.edu Office hours: Tuesdays and Fridays 4-5pm. Outline. Logistics Goals and topics Java (for a C++ programmer). Logistics. Course webpage

kellsie
Download Presentation

Principles of Software (CSCI 2600) Fall 2014

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Principles of Software (CSCI 2600) Fall 2014 www.cs.rpi.edu/~milanova/csci2600/ Ana Milanova Lally Hall 314, 518 276-6887 milanova@cs.rpi.edu Office hours: Tuesdays and Fridays 4-5pm

  2. Outline • Logistics • Goals and topics • Java (for a C++ programmer) Fall 14 CSCI 2600, A Milanova

  3. Logistics • Course webpage http://www.cs.rpi.edu/~milanova/csci2600 • Announcements – check regularly • Schedule, Notes, Reading • Schedule, lecture slides and assigned reading • Homework • Homework assignments posted there • RPILMS • Discussion board, your grades Fall 14 CSCI 2600, A Milanova

  4. Logistics • Required textbook • Effective Java, 2nd Edition, by Joshua Bloch, Addison Wesley, 2008 • Recommended books/resources • Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, Addison Wesley, 1995 • Refactoring: Improving the Design of Existing Code by Martin Fowler, Addison Wesley, 1999 Fall 14 CSCI 2600, A Milanova

  5. Logistics • Java Resources • Main Java website by Oracle: http://java.com • Java documentation: http://docs.oracle.com/javase/ • 1.7 JDK: http://docs.oracle.com/javase/7/docs/api/ • Java tutorial: http://docs.oracle.com/javase/tutorial/ • Java language specification: http://docs.oracle.com/javase/specs/ • Café au Lait: Java FAQ, News, and Resources

  6. Logistics • Syllabus www.cs.rpi.edu/~milanova/csci2600/syllabus.htm Topics, outcomes, policies and grading • 2 midterm exams and a final exam: 50% • 10 homework assignments: 50% • 5% extra credit for attendance and participation Fall 14 CSCI 2600, A Milanova

  7. Logistics • Programming assignments must be be completed individually! • Principles of Software builds individual skills • Carry these skills to collaborative projects Fall 14 CSCI 2600, A Milanova

  8. Logistics • Homework will be submitted and released through Subversion (SVN) • Checkout repository to obtain csci2600 project and first homework, hw0 • To submit a homework, commit into repository • To obtain next homework, update repository • Install Eclipse and Subclipse (plugin that interfaces with SVN) • More on SVN, JUnit and Javadocs next time

  9. Academic Integrity • Homework assignments must be completed individually • Discussion is allowed, but carrying material out of a discussion is not allowed • I trust you. • But…, cheating is extremely easy to catch • I will not tolerate it • Policy does not apply to HW0. Ask anyone! Fall 14 CSCI 2600, A Milanova

  10. How to Study • Read textbook in advance of lecture • I will assign reading ahead of class, whenever possible • Read lecture notes and textbook (again) right after class • I will post lecture notes about an hour after class • Form study groups • ASK QUESTIONS – in class, after class, etc. Fall 14 CSCI 2600, A Milanova

  11. Goals • Principles of Software teaches you to write correct and maintainable programs • What does it mean for a program to be correct? • Specifications • What are ways to achieve correctness? • Principled design and development • Abstraction and modularity • Documentation Fall 14 CSCI 2600, A Milanova (based on a slide by Michael Ernst, UW)

  12. Goals • What are ways to verifycorrectness? • Reasoning about code, verification • Testing • Debugging Fall 14 CSCI 2600, A Milanova

  13. Goals • What does it mean for a program to be maintainable? • Well-documented and understandable • “Open for extension but closed for modification” • Canonical example: We have an editor that manipulates shapes. We have coded Square and Circle and have written tons of client code that manipulates them. It should be “easy” to add a Triangle Fall 14 CSCI 2600, A Milanova

  14. Goals • What are ways to achieve maintainability? • Object-orientation and polymorphism greatly facilitate maintainability • Principled design and development • Abstraction and modularity • Documentation • Ultimately, correctness is most important! Fall 14 CSCI 2600, A Milanova

  15. Goals • Building good software is incredibly hard! • Large software systems are enormously complex. Lots of “moving parts”! • Software is constantly put to new uses sometimes without relevant experience • Software engineering is about: • Mitigating and managing complexity • Managing change • Dealing with software failures Fall 14 CSCI 2600, A Milanova (based on slide by Michael Ernst, UW)

  16. Topics • Reasoning about code • Invariants • Specifications • Polymorphism, abstraction and modularity • Design patterns • Testingand debugging • Refactoring • Tools: Java, the wealth of Java libraries, Eclipse IDE, Subversion, JUnit, debuggers, Javadocs and other • Principles are more important than the tools!!! Fall 14 CSCI 2600, A Milanova

  17. Topics • You will learn a lot! • You will carry what you learn into • SD&D - 4000-level software engineering class • Focuses on teamwork, software process, requirements • Other programming-intensive classes • RCOS • Research projects • Internships and jobs

  18. Outline • Logistics • Goals and topics • Overview of Java (for a C++ programmer) Fall 14 CSCI 2600, A Milanova

  19. Java • Java is a prerequisite • I expect you to have experience with Java • … If not, you can pick it up • ASK Questions! • What are most important differences with C++? Fall 14 CSCI 2600, A Milanova

  20. Java: Differences with C++ • Model for variables • Type safety • Compilation vs. interpretation • Reflection • Classes and inheritance • Other Fall 14 CSCI 2600, A Milanova

  21. Models for Variables • Value model for variables • A variable is a location that holds a value • I.e., a named container for a value • a := b • Reference model for variables • A variable is a reference to an object which has value • Every variable is an l-value • Requires dereference when r-value needed (usually, but not always implicit) l-value (the location) r-value (the value held in that location) Fall 14 CSCI 2600, A Milanova

  22. Models for Variables: Example b := 2; c := b; a := b + c; • Value model for variables • b := 2 b: • c := b c: • a := b+c a: • Reference model for variables • b := 2 b • c := b c • a := b+c a 2 2 4 2 4 Fall 14 CSCI 2600, A Milanova

  23. Questions • What is the model for variables in C/C++? • Value model • Python? • Reference model • Java? • Mixed. Value model for variables of simple type, reference model for variables of class type! Fall 14 CSCI 2600, A Milanova

  24. Models for Variables • This code has different meaning in C++ and in Java …Foo p; // p is a local variable double d = p.bar(); … Fall 14 CSCI 2600, A Milanova

  25. Equality Testing: == and equals() • Java uses the reference model for class types class Point { int x; // x-coordinate int y; // y-coordinate Point(int x, int y) { this.x = x; this.y = y; } } ... x = new Point(2,5); y = new Point(2,5); z = y; x y 5 2 5 2 z true or false?x == y ? true or false?y == z ? true or false?x.equals(y) ? true or false?y.equals(z) ?

  26. Equality Testing: == and equals() • In Java, == tests for reference equality. This is the strongest form of equality • Often, we need a weaker form of equality, value equality • In our Point example, we want x to be “equal” to y becausethe x and y objects hold the same value y z x y 5 2 5 2 Fall 14 CSCI 2600, A Milanova

  27. Equality Testing: == and equals() • What happened in our Point example? • Point inherited Object.equals: public boolean equals(Object o) { return this == o; } • OverrideObject.equals to get value equality! • Much more on this later in the class x y true or false?x == y ? true or false?y == z ? true or false?x.equals(y) ? true or false?y.equals(z) ? 5 2 5 2 z

  28. Equality Testing • In languages with reference model for variables we have two equality tests • One tests reference equality, whether two references refer to the same object • == in Java. E.g., x == y • is in Python. E.g., print x is y • Other tests value equality. Even if the two references do not refer to the same object, the objects can have the same value • .equals() in Java • == in Python

  29. Pointer Types • In C/C++, we need pointers • Allocate dynamic memory on the heap • Define recursive types (types defined in terms of themselves) such as linked lists. Think why. • In Java, references are essentially pointers • The reference variable (the address) may be on the stack, the object is always on heap • We cannot have an object on the stack! • Defining recursive types is easy

  30. Java: Differences with C++ • More on Type safety, Compilation vs. interpretation, Reflection, and Classes and inheritance on Friday! Fall 14 CSCI 2600, A Milanova

  31. Homework 0 • Setup Eclipse and Subclipse • You should be receiving an email from CS Labstaff regarding authentication • If you don’t receive it today, let me know ASAP • Checkout the csci2600 repository • Text of HW0 comes with it • Practice of basic Java, use of Java libraries, Eclipse and JUnit • LET ME KNOW IF YOU HAVE ISSUES! Fall 14 CSCI 2600, A Milanova

  32. Next Class • Will finish discussion of Java vs. C++ • Will discuss Eclipse, SVN, Junit and Javadoc • Will discuss UML and UML Class Diagrams Fall 14 CSCI 2600, A Milanova

More Related