Previous lecture:
Recursion (non-examinable)
This week:
Wrapping up
Past year’s paper
© CS1101 (AY2009-2010 Semester 1) Week13 - 2
Programming methodology
Abstraction
CS1102 Data Structures and Algorithms
CS2103 Software Engineering/CS2261 Entreprise
Systems Development
The Joys of the Craft
© CS1101 (AY2009-2010 Semester 1) Week13 - 3
How do we begin writing a program?
What are the style/design principles?
+
© CS1101 (AY2009-2010 Semester 1) Week13 - 4
Break a problem into subproblems.
Break each subproblem into sub-subproblems.
Simplify until the subproblem is easily solvable.
Write a procedure (method) for each subproblem.
A procedure abstracts away the details of how something is done.
© CS1101 (AY2009-2010 Semester 1) Week13 - 5
Complex data should be abstracted.
Java provides objects for data abstraction
Object can contain other objects
Objects can inherit from other objects
In CS1102, you will study Abstract Data Types (ADTs)
© CS1101 (AY2009-2010 Semester 1) Week13 - 6
Conditionals (selection)
Execute different things depending on outcome of a test.
Examples: if-else, switch.
Iteration (repetition)
Execute something repeatedly while some condition is true
Examples: for-loop, while-loop (related statements: break, continue)
Recursion
Defining something in terms of itself
An alternative form of iteration
A way of thinking/paradigm
© CS1101 (AY2009-2010 Semester 1) Week13 - 7
A way of looking at the world
A program is made up of objects.
Each object manages it own attributes (data members).
Each object has state (a set of attribute values) and behaviours (methods).
Object may interact with one another, by passing message through calling methods.
© CS1101 (AY2009-2010 Semester 1) Week13 - 8
CS1101
CS1102 Data Structures and Algorithms.
Emphasis on algorithms and data structures
Pre-requisite: CS1101
Data structures
Lists, stacks, queues and their algorithmic designs
Trees, BSTs (Binary Search Trees)
Hash tables
Heap, priority queues
Graphs
CS1102
© CS1101 (AY2009-2010 Semester 1) Week13 - 9
Algorithms
Sorting: quicksort, mergesort, radix sort, heap sort, topological sort, etc.
Tree traversals, tree balancing
Graph depth-first and breadth-first traversals
Shortest-path algorithm (Dijkstra's algorithm)
Strategies for choosing the right data structures
Recursion
Algorithmic analysis
Big-O notation
© CS1101 (AY2009-2010 Semester 1) Week13 - 10
© CS1101 (AY2009-2010 Semester 1) Week13 - 11
CS1101 CS1102 CS2103 or CS2261
CS2103 Software Engineering
The process of solving customers' problems by the systematic development and evolution of large, high-quality software systems within cost, time and other constraints.
Pre-requisite: CS1102
Should be familiar with algorithmic problem solving, Java and data structures.
What is this course all about?
Software analysis, design, implementation and testing.
Not just coding in Java.
© CS1101 (AY2009-2010 Semester 1) Week13 - 12
Course objectives
To understand the software development process, including requirement analysis, design, implementation and testing.
To develop skills in object oriented approach of software development.
To understand the process of modeling real world problems using UML.
Build and test a system that illustrate the object concepts.
Familiarize with related concepts such as design patterns, various development methodologies, modularity, coherence and coupling of modules.
© CS1101 (AY2009-2010 Semester 1) Week13 - 13
CS1101 CS1102 CS2103 or CS2261
For IS/EC students
Course objectives
To understand the software development process, including requirement analysis, design, implementation and testing.
To develop skills in object oriented approach of software development.
Similar to CS2103 but with focus on developing software systems at the enterprise level.
Technologies covered: J2EE and .NET
Topics covered: Business Information System; Enterprise
Platforms; Distributed Computing Concepts; Web Services, etc.
© CS1101 (AY2009-2010 Semester 1) Week13 - 14
Why is programming fun? What delights may its practitioner expect as his reward?
First is the sheer joy of making things . As the child delights in his mud pie, so the adult enjoys building things, especially things of his own design. I think this delight must be an image of God's delight in making things, a delight shown in the distinctness and newness of each leaf and each snowflake.
Second is the pleasure of making things that are useful to other people . Deep within, we want others to use our work and to find it helpful. In this respect the programming system is not essentially different from the child’s first clay pencil holder “for Daddy’s office.”
© CS1101 (AY2009-2010 Semester 1) Week13 - 15
Third is the fascination of fashioning complex puzzle-like objects of interlocking moving parts and watching them work in subtle cycles, playing out the consequences of principles built in from the beginning. The programmed computer has all the fascination of the pinball machine or the jukebox mechanism, carried to the ultimate.
Fourth is the joy of always learning , which springs from the nonrepeating nature of the task. In one way or another the problem is ever new, and its solver learns something: sometimes practical, sometimes theoretical, and sometimes both.
© CS1101 (AY2009-2010 Semester 1) Week13 - 16
Finally, there is the delight of working in such a tractable medium . The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures. (As we shall see later, this very tractability has its own problems.)
© CS1101 (AY2009-2010 Semester 1) Week13 - 17
Yet the program construct, unlike the poet’s words, is real in the sense that it moves and works , producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sounds, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be.
Programming then is fun because it gratifies creative longings built deep within us and delights sensibilities we have in common with all men .
Frederic Brooks, Jr.
© CS1101 (AY2009-2010 Semester 1) Week13 - 18
Let’s discuss some questions from AY2008/9
Semester 1 paper.
© CS1101 (AY2009-2010 Semester 1) Week13 - 19
+
© CS1101 (AY2009-2010 Semester 1) Week13 - 20
© CS1101 (AY2009-2010 Semester 1) Week13 - 21
Preparing for Exams: A Guide for NUS Students
http://www.cdtl.nus.edu.sg/examprep/
Every student’s nightmare exam
Contributed by Sesha Sendhil S. (see CS1101 “Chit-chat” forum)
Q. Write a program to simulate the human mind and optimize its usage. You are provided with a PC and DrJava. Requests for additional resources will not be entertained. When you are done test the program on yourself.
Estimate of the time required to be spent on this exercise :
• Devising and writing algorithm(pseudo-code) : 3 mins
• Translating pseudo-code into code: 2 mins
• Typing in the code: In no time at all
• Testing and Debugging: 5 mins
• Total Time: 10 mins.
Please submit your program using CourseMarker. If it crashes because of your submission also fix it. No additional time is allocated for this purpose.
© CS1101 (AY2009-2010 Semester 1) Week13 - 22
© CS1101 (AY2009-2010 Semester 1) Week13 - 23
© CS1101 (AY2009-2010 Semester 1)
Week13 - 24