Objects First With Java - Chapter 1
Objects First With Java - Chapter 1
Objects First With Java - Chapter 1
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Course Contents• Introduction to object-orientedprogramming…• …with a strong softwareengineering foundation…• …aimed at producing andmaintaining large, high-qualitysoftware systems.<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 3
Buzzwordsresponsibility-drivendesigninheritanceencapsulatioiteratorscohesionoverridingjavadocncouplininterface gcollectionclassesmutator methodspolymorphic methodcalls<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 4
Goals• Sound knowledge of programmingprinciples• Sound knowledge of objectorientation• Able to critically assess the qualityof a (small) software system• Able to implement a small softwaresystem in <strong>Java</strong><strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 5
BookDavid J. Barnes & Michael Kölling<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong>A Practical Introduction using BlueJ4th edition,Pearson Education, 2008ISBN 0-13-606086-2.<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 6
Course overview (1)• <strong>Objects</strong> and classes• Understanding class definitions• Object interaction• Grouping objects• More sophisticated behavior - libraries• Well-behaved objects - testing,maintaining, debugging• Designing classes<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 7
Course overview (2)• Inheritance• Polymorphism• Extendable, flexible classstructures• Building graphical user interfaces• Handling errors• Designing applications<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 8
Demo<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 9
Fundamental concepts• object• class• method• parameter• data type<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 10
<strong>Objects</strong> and classes• objects– represent ‘things’ from the realworld, or from some problemdomain (example: “the red cardown there in the car park”)• classes– represent all objects of a kind(example: “car”)<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 11
Methods and parameters• <strong>Objects</strong> have operations whichcan be invoked (<strong>Java</strong> calls themmethods).• Methods may have parameters topass additional informationneeded to execute.<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 12
Other observations• Many instances can be createdfrom a single class.• An object has attributes: valuesstored in fields.• The class defines what fields anobject has, but each object storesits own set of values (the state ofthe object).<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 13
State<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 14
Two circle objects<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 15
Source code• Each class has source code (<strong>Java</strong>code) associated with it thatdefines its details (fields andmethods).<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 16
Return values• Methods may return a result via areturn value.<strong>Objects</strong> <strong>First</strong> with <strong>Java</strong> A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 17