Objects First Programming Education - a personal interpretation Jens Bennedsen It-vest networking universities, Denmark jbb@it-vest.dk Me 20 years of teaching experience introductory programming for 20 years introductory object-oriented programming for 15 years Published 20+ articles in the area of computer science education Some in collaboration with Carsten Writing up my ph.d. thesis Teaching and learning programming g a model-based approach Free University, Berlin, Germay Objects First Programming Education 2 Jens Bennedsen, 2005 1
Outline of the talk What is objects first? CC2001 Model-driven programming program in context Object-oriented conceptual framework There is more to OO than Java A model-driven introductory programming course progression, teaching material, assignments, final exam,... Mediation of the programming process How to unfold the programming process? Free University, Berlin, Germay Objects First Programming Education 3 CC2001 CC-2001 describes three approaches to a program- ming first curriculum imperative-first functional-first objects-first John Lewis: Myths about Object-Orientation and Its Pedagogy SIGCSE 2000, p. 245-249 Free University, Berlin, Germay Objects First Programming Education 4 Jens Bennedsen, 2005 2
Programming Education in Perspective Programming Education Programming Education = Programming Methodology + Pedagogical Design + Programming Tools Programming Methodology Programming Methodology = Theory/Techniques + Process Pedagogical g Design = Organization + Dissemination Pedagogical Design Programming Tools = Language + Environment Programming Tools Free University, Berlin, Germay Objects First Programming Education 6 Jens Bennedsen, 2005 3
Many factors influence learning Evaluation Student s learning premises External conditions Learning process Objectives Content Hiim & Hippe 2006 Free University, Berlin, Germay Objects First Programming Education 7 Programming Methodology = Theory/Techniques + Process Theory/Techniques model-driven development design by contract (assertions) patterns... Programming Methodology Process incremental development non-linearity refactoring test... Pedagogical Design Free University, Berlin, Germay Objects First Programming Education 8 Jens Bennedsen, 2005 4
Pedagogical Design = Organization + Dissemination Organization graduated exposure to complexity spiral, early bird, fill in the blanks apprenticeship... Programming Methodology Dissemination text labs videos lectures net-based learning objects Pedagogical Design Free University, Berlin, Germay Objects First Programming Education 9 A Conceptual Framework for Object-Oriented Programming There is more to OO than Java... Jens Bennedsen, 2005 5
Kristen Nygaard on Object-Orientation A program execution is regarded as a physical model system simulating the behavior of either a real or imaginary part of the world. Physical modeling is based upon the conception of reality in terms of phenomena and concepts. A physical model system is constructed, modeling phenomena by objects and concepts by categories of objects. Kristen Nygaard, 1926-2002 Free University, Berlin, Germay Objects First Programming Education 11 Three Perspectives on Programming Instructing the computer (coding) the purpose of programming is to instruct the computer focus is on aspects of program execution such as storage layout, control flow, parameter passing, etc. Managing the program description the purpose of programming is to create a software architecture that provides overview and understanding of the entire program focus is on aspects such as visibility, scope, encapsulation, modularity, software design etc. Conceptual modeling the purpose of programming is to express concepts, structure and relations focus is on constructs for describing concepts, phenomena and relations between these Free University, Berlin, Germay Objects First Programming Education 12 Jens Bennedsen, 2005 6
Conceptual Modelling Conceptual model modelling Specification model abstraction abstraction Problem/vision concerning phenomenons Program, language, g OS, machine Problem domain Model Free University, Berlin, Germay Objects First Programming Education 13 Overview Conceptual framework for object-orientation Concepts and modelling Structure: aggregation, association, specialization is used for organizing knowledge about a problem domain and structure in the solution domain Is (to some extend) supported by language constructs in OO languages Modelling examples Abstract models in UML Implementation in Java Smaller examples from textbook [Barnes & Kölling] which does not explicitly present the models... Free University, Berlin, Germay Objects First Programming Education 14 Jens Bennedsen, 2005 7
Association (X-a) Relation that describes a dynamic relation between concepts that can exist independently of each other. MailServer keeps MailItem Person owns Person rents Car Car Person loves Person Person is-friend-with Student is-enrolled-at Person Course Patient have-had Disease Free University, Berlin, Germay Objects First Programming Education 15 Association in UML MailServer keeps * MailItem Person owns * 0..1 owned can-drive * Car Student takes * * Course Multiplicity (cardinality): 0..1, 1, n, a..b, 0..* (*) Role Orientation (1-way, 2-way) Free University, Berlin, Germay Objects First Programming Education 16 Jens Bennedsen, 2005 8
Association in UML (X-a) X = keeps MailServer howmanymessages(string who): int getnextmailitem(string who): MailItem post(mailitem item) 0..* MailItem from: String to: String message: String getfrom(): String getto(): String getmessage(): String print() Free University, Berlin, Germay Objects First Programming Education 17 Association in Java class MailServer { } Set<MailItem> messages; public MailServer() { messages = new HashSet<..>(); } public int howmanymessages (String who) {... } public MailItem getnextmailitem tmailitem (String who) {... } public void post(mailitem item) {... } class MailItem { private String to; private String from; private String message; public MailItem(... ) {... } public String getfrom() {... } public String getto () {... } public String getmessage() {... } public void print() {... } } Free University, Berlin, Germay Objects First Programming Education 18 Jens Bennedsen, 2005 9
Systematics in OOP Modelling from problem description to conceptual model refinement of conceptual model to specification model (method signatures and specifications) Implementation structurally: from specification model to Java code (automatically) body: attributes t and methods (creativity it and systematics) ti Problem domain Free University, Berlin, Germay Objects First Programming Education 19 Hand-in-Hand Modeling and Coding (1) David Gries (Edsger W. Dijkstra) the loop body and the loop invariant is developed hand-in-hand with the latter leading the way We (Kristen Nygaard) coding and class modeling is done hand-in-hand with the latter leading the way Design by contract and systematic programming a class model is a design contract in precisely the same way as a loop invariant is code is introduced on purpose (fulfilling the contract) Free University, Berlin, Germay Objects First Programming Education 20 Jens Bennedsen, 2005 10
Programs as models K. Nygaard A program execution is regarded as a physical model system E.W. Dijkstra It s not the purpose of our programs to instruct the computer; it s the purpose of the computer to execute our programs Free University, Berlin, Germay Objects First Programming Education 21 Contents and Progression Traditional approach typical textbooks only address the first and to some extend the second perspective topics are organized according to the syntactical structures in the programming language (bottom-up) tendency to completeness in coverage of topics syntax-driven progression Our approach a balanced coverage of all three views conceptual modeling is leading the way systematic programming (killing rabbits) early bird & spiral approach model-driven progression Free University, Berlin, Germay Objects First Programming Education 22 Jens Bennedsen, 2005 11
Model-Driven Progression (1) Model-driven programming tasks starts from a class model mostly, the model is given sometimes, also the model must be developed Progression models become increasingly complex during the course associated systematic programming techniques language issues covered by need Free University, Berlin, Germay Objects First Programming Education 30 Course Progression Conceptual model Design Specification model Analysis Implementation Problem/vision Implementation model Problem domain Model Free University, Berlin, Germay Objects First Programming Education 31 Jens Bennedsen, 2005 12
Revealing the Programming Process Pointing Out the Problem David Gries, SIGSCE 1974 What Should We Teach in an Introductory Programming Course? Suppose you attend a course in cabinet making. The instructor briefly shows you a saw, a plane, a hammer, and a few other tools, letting you use each one for a few minutes. He next shows you a beautifully-finished cabinet. Finally, he tells you to design and build your own cabinet and bring him the finished product in a few weeks. You would think he was crazy! Free University, Berlin, Germay Objects First Programming Education 33 Jens Bennedsen, 2005 13
Absurd Expectation? Nevertheless, this is what traditionally takes place (judged by the majority of existing textbooks) Free University, Berlin, Germay Objects First Programming Education 34 Predictable Outcome? Free University, Berlin, Germay Objects First Programming Education 35 Jens Bennedsen, 2005 14
The Missing Link... tools concepts language constructs? finished programs Free University, Berlin, Germay Objects First Programming Education 36 Strategies, Principles, and Techniques... of problem solving and the development of programs The Practice of Programming Describe strategies, principles, and techniques Demonstrate how to apply these in action Develop programs instead of simply tools showcasing them Demonstrate that programming is a nonlinear process concepts finished Demonstrate incremental development language programs Demonstrate model-driven development constructs Demonstrate t test-driven t di development Demonstrate refactoring Demonstrate how to find and handle errors Demonstrate how to use online documentation Demonstrate,... Free University, Berlin, Germay Objects First Programming Education 37 Jens Bennedsen, 2005 15
Strategies, Principles, and Techniques... of problem solving and the development of programs tools Descriptive levell (theoretical) concepts language constructs finished programs Performance level (practical) Video mediation Free University, Berlin, Germay Objects First Programming Education 38 Apprenticeship learning Learning is an integral part of generative social practice and through legitimate peripheral participation Leve and Wenger most well-known CoP legitimate peripheral participation i Free University, Berlin, Germay Objects First Programming Education 39 Jens Bennedsen, 2005 16
Apprenticeship Jordan (1989) found Work is the driving force. The apprentices progressive mastering of tasks is appreciated for getting the problem solved, not as a step toward a distant, symbolic goal (such as a certificate). Apprentices start with skills that are expected by the master to be easiest and where mistakes are least costly. (The tailors start out sewing, not cutting, the cloth.) Learning is focused on bodily performance. It involves the ability to do, rather than the ability to talk about something. It often focuses on skills rather than academic competencies. Standards of performance are embedded in the work environment. Teachers and teaching are largely invisible. Free University, Berlin, Germay Objects First Programming Education 40 Cognitive apprenticeship We call this rethinking of teaching and learning in school cognitive apprenticeship to emphasize two issues. First the method is aimed primarily at teaching the processes that experts use to handle complex tasks. Where conceptual and factual knowledge are addressed, cognitive apprenticeship emphasizes their uses in solving problems and carrying out tasks Second, our term, cognitive apprenticeship, refers to the learning-through-guided-experience on cognitive and metacognitive, rather than physical, skills and processes [ ] The externalization of relevant processes and methods makes possible such characteristics of apprenticeship as its reliance on observation as a primary means of building a conceptual model of a complex target skill. Collins, Brown and Newman (1989) Free University, Berlin, Germay Objects First Programming Education 41 Jens Bennedsen, 2005 17
Two aspects of apprenticeship Person-centered aspect Expose the learners to how an experienced programmer works. The master reflects and thinks aloud of the particular action, making them visible ibl and as a source of identification. The apprentice learns from observing the master (teacher) performing the actions embedded in a programming practice. De-centered aspect Consider the learner as an active participant in a community of co-learners. The master (teacher) legitimates the skills and knowledge of the individual learner. Nielsen and Kvale (1997) Free University, Berlin, Germay Objects First Programming Education 42 Refinement of class Date demonstrating two principles An Example... The special case principle p public class Date { systematic treatment of special cases suppress implementation details introduce private methods to handle special cases The mañana principle introduce an abstraction worry about implementation details tomorrow date udsnit.wmv private int d, // 1 <= d <= daysinmonth m, // 1 <= m <= 12 y; public Date(int dd, int mm, int yy) { d = dd; m = mm; y = yy; } public void settonextdate() { d = d + 1; } public String tostring() { return d + "-" + m + "-" + y; } } Free University, Berlin, Germay Objects First Programming Education 43 Jens Bennedsen, 2005 18
Free University, Berlin, Germay Objects First Programming Education 44 Jens Bennedsen, 2005 19