CMSC 132: Object-Oriented Programming IIObject-Oriented Programming & Java Language ConstructsDepartment of Computer ScienceUniversity of Maryland, College ParkCourse Catalog DescriptionIntroduction to use of computers to solve problems using software engineering principlesDesign, build, test, and debug medium-size software systems. Learn to use relevant toolsUse object-oriented methods to create effective and efficient problem solutionsUse and implement application programming interfaces (APIs)Programming done in JavaThings You Will LearnObject-oriented software developmentModern software development techniquesObject-oriented designAlgorithms & data structuresLists, trees, graphsProgramming skillsJava API, IDE, testing, debuggingWhy Object-Oriented Programming?Coding is small part of software developmentEstimated % of time35% Specification, design20% Coding, debugging30% Testing, reviewing, fixing15% Documentation, supportObject-oriented approach makes other parts of software development easierOrganizationPersonnelInstructorNelson Padua-PerezTeaching assistantsNikolaos FrangiadakisClass web sitehttp://www.cs.umd.edu/class/summer2007/cmsc132/ClassesLecturesLabsOffice hoursSyllabusAvailable onlineMake sure you read itTextbookRequired“Objects, Abstractions, Data Structures and Design Using Java (version 5.0)”By Elliot Koffmanand Paul WolfgangTextbook (cont.)Recommended“Java Precisely (2ndEdition)”By Peter SestoftProjects8 projectsEvaluate design, coding, testing skillsTries to involve interesting application areasNetworking, user interfaces, data compressionLate policyProjects due at 6 pm20% penalty, up to 9am the next morningPlan to complete all projects on timeGood faith attemptMust attempt all projects to passProjects (cont.)EnvironmentEclipse IDEAutomated submission & testingSubmit serverhttps://submit.cs.umd.eduMaintains record of submissionsCVS repositoryMay use for researchRelease testingCan evaluate project using real test casesGradingBased onProjects, homework exercises, quizzes, midterms, finalPoint distribution (roughly)40% Projects6% Homework Exercises14% Quizzes10% Midterm #110% Midterm #220% Final ExamAvailable on-linehttps://grades.cs.umd.eduCourse Bulletin BoardBulletin Board (Forum)https://forum.cs.umd.edu/forumdisplay.php?f=63Policy on project postingsCan ask about specification, setup, tools, etc.Do not ask about design, implementation, etc.Violators may face penalty for academic dishonestyAcademic HonestyAll individual assignments & exams must be done individually (except "open" assignments)Do not copy (or allow others to copy) your work in any waySubmissions will be compared to submissions from current and previous semestersCases of academic dishonesty will be referred to the University's Office of Judicial ProgramsVisit Student Honor Council website for more detailed explanation of academic dishonestyExcused AbsencesStudents must apply in writing and furnish documentary support for excused absencesSupport should explicitly indicate the dates or times the student was incapacitatedExcused absence does not typically translate into project extensionsStudents requesting reasonable academic accommodations due to a disability must provide a letter from the Office of Disability Support ServicesCourse AdviceStart projects earlyAsk questionsRead bookAttend lecturesAttend labsAttend office hoursOverviewObject-oriented programming (OOP)Introduction to OOP principlesJava programming languageReview language constructsIntroduce new language constructsMany from Java 5.0Object-Oriented Programming (OOP)Approach to improving softwareView software as a collection of objects (entities)Motivated by software engineering concernsTo be discussed later in the semesterOOP takes advantage of two techniques1.Abstraction2.EncapsulationTechniques – AbstractionAbstractionProvide high-level model of activity or dataProcedural abstractionSpecify what actions should be performedHide algorithmsData abstractionSpecify data objects for problemHide representationTechniques – EncapsulationEncapsulationConfine information so it is only visible / accessible through an associated external interfaceApproachFor some entity X in programAbstract data in XAbstract actions on data in XCollect data & actions on X in same locationProtects and hides XExtension of abstractionAbstraction & Encapsulation ExampleAbstraction of a RosterDataList of student namesActionsCreate rosterAdd studentRemove studentPrint rosterEncapsulationOnly these actions can access names in rosterROSTERList of namesCreate( )AddStudent( )RemoveStudent( )Print( )Java Programming LanguageLanguage constructs designed to support OOPExampleInterface – supports procedure abstractionClass – supports encapsulationClass libraries designed using OOP principlesExampleJava Collections FrameworkJava SwingJava InterfaceInterfaceCollection ofConstantsAbstract methodsCan not be instantiatedClasses can implement interfaceMust implement all methods in interfaceExampleclass foo implements bar { … } // interface barSimilar to abstract classBut class can “inherit” from multiple interfacesJava Collections FrameworkCollectionObject that groups multiple elements into one unitAlso called container Collection framework consists ofInterfacesAbstract data typeImplementationsReusable data structuresAlgorithmsReusable functionalityOverviewObject-oriented programming (OOP)Introduction to OOP principlesJava programming languageReview language constructsIntroduce new language constructsMany from Java 5.0Review of Java Language ConstructsBasic elementsPrimitive types, variables, constants, operatorsIf-else, switch, while, forClassesObject instancesCreating objects with newObject referencesThe null referenceInstance data, class (static) dataMethodsParameters, return values, polymorphismReview of Java Language ConstructsInheritanceBase class, derived class, superMethod overriding (vs. overloading)Abstract methodsUp- and down-casting, getClass, instanceofInterfaces1D ArraysCreating, indexingExceptionsTry-catch blocksNew Java Language ConstructsAutoboxingEnumerated typesGenericsEnhanced for loopIterator interfaceStream input & outputScanner classAnnotationsBitSet classAutoboxing & UnboxingAutomatically convert primitive data typesData value ⇔⇔⇔⇔ Object (of matching class)Data types & classes convertedBoolean, Byte, Double, Short, Integer, Long, FloatExampleArrayList myL = new ArrayList();myL.add(1); // previously myL.add(new Integer(1));Integer
View Full Document