You are on page 1of 8

International Journal of Advanced Computer Science, Vol. 3, No. 7, Pp. 355-362, Jul., 2013.

A Structured Approach to Problem Solving in CS1/2

Carmen Morgado & Fernanda Barbosa
Received: 19,Feb., 2013 Revised: 5,Mar., 2013 Accepted: 18,May, 2013 Published: 15,Jun., 2013

problem solving, teaching programming, abstraction skills

Abstract Programming teaching is a complex task, mainly because of the students difficulties on building structured solutions and also on problems interpretation. At introductory courses, we need to develop on students, programming skills to help them to apply their knowledge effectively on solving problems. This led us to use an approach that will be followed from the problem presentation until the development of a properly structured program. Its application in CS1/2, which we have taught in recent years, allowed an increase in approval rating and in the quality of the solutions presented, it also has proved to be adapted to the needs of teaching programming with different imperative programming languages. In this work we illustrate the approach with a simple example. We also present an evaluation of the methodology done with a population of 130 students at introductory courses using C and Java languages.

1. Introduction
On a great number of computer science degrees, teaching programming is done in CS1/2 courses. Usually these courses follow an incremental process, starting with the implementation of small programs where only the basic construction mechanisms of a programming language are used. This is then followed by the implementation of more complex problems, where students must use and implement more elaborated algorithms and data structures. Throughout this process it is fundamental that students increase their capacity to propose structured solutions for a given problem and to apply their knowledge effectively. To achieve the goal of building a structured solution to a given problem, it is fundamental to provide students with tools to: (1) analyze a problem; (2) design a structured solution to the problem; and (3) know when and how to use the different techniques of the programming language (implement the program). The biggest obstacles faced by students in achieving a solution to a given problem concern analyze and understand of the problem, and the lack of simple methods to help them to propose solutions [1]. In our introductory courses, a large number of students have problems on how to start the development process ("blank page trauma"), and also on how to use abstraction
This work was supported by the FCT/MCTES, PEst-OE/EEI/UI0527/2011, CITI/FCT/UNL organization. Carmen Morgado, Fernanda Barbosa ([c.p.m,f.b]

skills to reach a structured solution. Reaching a structured solution involves a complex process, requiring several skills, one of which is the ability to identify and understand the problem [2]. That's why more than teach a programming language, it is important that the students are able to understand problems and the steps that must be followed to solve them. The preliminary steps needed to enable the student to reach a structured solution are often ignored in many text books, because they are focused essentially on the programming languages and on their mechanisms. But, as is evidenced in [3], in programming the most difficult issue in programming is understanding how to design and structure a program to solve a given problem, and not so much on understanding the basic instructions of programming. Although most students understand these basic programming issues, the problem is on how to apply them correctly on the problem solution. In more advance computer courses, the students learn some object-oriented methods, including Booch, Rumbaugh and Shlaer-Mellor, to software development. But, in our opinion, a structured approach in the first courses helps a lot in structuring the development of programs to solve problems. The use of a programming language of high level, such as Java or C++, is no guarantee of obtaining a properly structured solution. One of the problems is that these object-oriented languages involve more than just the modeling of real world objects, and have complex issues, which can hinder the learning process of students [4]. Moreover, as noted on [3], the programming language used did not affect significantly the learning situations of programming. In order to improve students skills on solving problems, in our classrooms we use an approach that helps them to understand a problem and develop a structured program. In order to guide/structure the student mental process, we incorporate a set of rules/principles related to problem presentation, and a natural and intuitive way to identify, model and implement the problem components (named concepts in our approach), without having to use, for instance, an object oriented programming approach. Moreover, our approach is language independent and has been used in courses that use different imperative languages. In this paper we present the approach that we used in our classes, illustrating it with a simple example, and its evaluation in introductory courses, using C and Java languages.


International Journal of Advanced Computer Science, Vol. 3, No. 7, Pp. 355-362, Jul., 2013.

2. Related Work
The problem of teaching programming has become the object of study of many researchers [5]. The more traditional strategies in teaching programming try to cover the foundations of programming languages, rather then generate interpretation and formalization skills in students [6]. Many authors believe that the solution to teaching programming problems lies in choosing the most appropriate programming language [7, 8, 9, 10]. At the top of list, of the most popular languages for teaching programming, are the leading representatives of object-oriented paradigm languages: Java and C++ [11, 9]. Some authors in alternative to those propose multimedia language like ActionScript [12] or Web languages [13]. But, as defended in [3], the programming language used did not affect significantly the programming learning process. It is necessary to choose the appropriate teaching methodology and tools that will facilitate students to understand the basic programming concepts, and how to apply them in solving the problem. Choosing the most appropriate teaching method in the field of information and computer science was the subject of research of a large number of authors [14, 15, 16, 17]. While some works use specific methods for some types of problems [18], for the languages used [19, 9, 20] or even for some part of the solution development process [21, 22], others use tools that support the program development, like mini-languages [23] and visualization tools [24, 25]. All of these methods have a positive impact on students learning [26, 27], because they facilitate students to understand the basic programming concepts. But, the Blank page trauma and the bad solutions developed by students persist [5]. However there aren't, as far as we know, approaches to help students through all the stages of solving a problem. This approach should be independent of the programming language used, and its main goal should be to guide/structure the mental process of students, on their development of a solution to a problem. Due to these reasons, we decided to use our approach for teaching programming. In our opinion, this approach incorporates several features of the methods listed in [16]. As software technology-oriented method, this approach does not touch upon concrete programming language knowledge, but deals only with the software development technology. As task-oriented method, the elements of the programming language used are introduced because they are needed in the process of problem solving. As action-oriented method, this approach allows students to visualize what happens when the statements are being executed, through the use of prototype application that should be provided by teachers, for all presented problems.

This approach is defined by a sequence of steps, each one with a set of rules that must be followed during the development of a program. The rules are based on the abstraction, hiding, modularization and location principles, in order to develop a program that is reliable, understandable and easily modifiable. Moreover, the students practice problem solving techniques and express the solution in a way that could easily be adapted to any high level programming language. This approach helps the student to automate the activities in order to: Minimize the "blank page trauma": students have a better understanding of the problem; Increase the quality of the developed programs: the programs developed by students are more structured and separate the user interaction from the problem solution. There are three main steps in our approach, which are briefly described next. A. Problem Presentation Although the discussion of a diversity of forms in presenting a problem could be an advantage, it may be a problem to the understanding of the problem by the students, particularly for the CS1 courses, where the students present greatest difficulties on logical reasoning and structuring. So, the option was to choose a strict method for writing the problem presentation document, in order to facilitate and guide the student interpretation and analysis of the problem. The problem presentation should focus on three key aspects of the desired solution: the main objectives, the concepts (data types) involved and the user interaction. Additionally, the students have a prototype application, supplied by the teachers that allow students to test all the user interaction possibilities. For more details concerning problem presentation see [28]. B. Problem Analysis When developing a problem solution, there are two distinct components that must be identified and processed separately: the problem solution and the application interactions with the user. The problem solution should be concerned with problem concepts (components) organization, and should be independent of how the user interacts with the application (program). In our approach, a concept is an abstract data type, defined by a type and a set of operations (concept interface) to manage it. In Java language, the concept is an interface, and its implementation is a class that implements this interface. In C language, the concept is modeled in: (1) a header file, where a type (a pointer to a data structure) and operations are defined; and (2) a source file, where data structure and operations are implemented. In the problem solution, there is a problem concept, called top concept, which represents the problem as a black box. This is the concept that usually interacts with all the other concepts of the problem.
International Journal Publishers Group (IJPG)

3. Programming Approach
In all the problems presented in our classrooms, we use this approach to analyze the problem, and to develop a structured solution/program.

Morgado et al.: A Structured Approach to Problem Solving in CS1/2.


The application interaction is modeled as a sequence of actions over the top concept. In Java and C languages, this is the main function of the developed application. At this step, the students should have: Identify and define the top concept, Build the application interaction algorithm. C. Problem Design The main goal of this step is the final implementation of all the concepts of the problem solution. We follow a top-down approach guided by the top concept. Thus the process begins with the implementation of the top concept. This mean: (1) describe the attributes (build the type) and (2) implement all the concept operations (concept interface). During the modeling process, new concepts are introduced in progressive manner, guided by the need to perform the problem requirements. At the end, students should have a program composed by: A main program, that represents the user interaction model; A set of problem concepts that represents the problem solution concepts, including the top concept.

Problem solution Students need to identify the top concept, where the solution is seen as a black box. In order to identify the top concept is necessary to answer the following questions: The problem is about what? What do we want to solve or manage? The students need to answer these questions with a sentence that summarize the problem. This sentence should identify the overall goal without elaborating too much. Some examples of sentences made by students, to the problem under study, may be: Managing cultivations done by farm on a farmer. Managing cash, seeds and skills of the farmer in his farm. Managing a farm.

4. An Example
The example under study is based on the application "Farmville" available on Facebook. This example is an exercise solved by students in a lab session of CS1 courses, using C or Java languages. Until this session, the students have made simple programs, where they exercise the basics elements of a programming language (basic data types, arrays, structures, i/o instructions, conditional and iterative instructions), using the notion of function to structure programs. Next, we present the main steps of the programming approach that was applied on this study case. In all figures in this section, we use a pseudo code to build the solution (program), although, in the classroom, students can use the programming language in question (C or Java). A. Problem Presentation At this step, students are given a prototype application and a document describing the problem. Fig. 1 presents the document that was given to students. Here, we only present one interaction scenario, although some more scenarios were presented to the students. Students also have access to a prototype application, supplied by the teachers, allowing them to test other interaction possibilities. B. Problem Analysis At this step it is important for the student to realize that, when solving a problem, there are two distinct components that must be identified and processed separately: the problem solution and the application interaction with the user.
International Journal Publishers Group (IJPG)

Fig. 1 MyFarm - problem presentation.

All sentences presented, describe the problem. However some (1-2 sentences) detail certain features of the problem, forgetting other. For this reason, it is essential to get a sentence like "Managing something" (sentence 3), where "something" (must be a substantive) is the key concept in the problem domain. If you can make a statement like that, then the top concept is "something", in this case was the "farm". In the other cases, students are instructed to list all


International Journal of Advanced Computer Science, Vol. 3, No. 7, Pp. 355-362, Jul., 2013.

the nouns in their sentence, which may be strong candidates to be concepts of problem. The top concept should be one of the identified nous, which best represents the problem as a whole. In the sentences 1-2, for the nouns "cultivation", "farmer", farm, "cash", "seeds", and "skills", the concept more representative of the problem is undoubtedly "farm". All other nouns only make sense in the context of a farm; they do not exist by per se alone in the problem context. Once identified the top concept, the students can begin to define the concept in the programming language. Create an interface Farm, in Java, or have a header file farm.h, with the definition of the type Farmer, in C. Application interaction The application interaction is modeled on the main function as a sequence of actions on the problem solution, represented by the variable "myFarm" of type Farm (top concept). Note that, in our introductory courses, usually we assume that the input data is always correct; this means that we do not treat user errors. In this activity, the students should read more carefully the section "interactions description" of problem presentation, and use the prototype provided, in order to understand in detail the interactions with the user. It is essential to transmit to the students the idea that, any interaction is a data exchange between the user and the problem solution ("top" concept previously identified). For each interaction, the students must define the data needed (input, output and auxiliary), and identify which operations must be performed in the variable "myFarm" in order to fulfill with the problem requirements. Then students should build an algorithm for the main program, based on identified needs. In this process, students may discover new problem concepts, like cultivation in this example (required as output data of some user interactions). Fig. 2 and Fig. 3 illustrate the results, obtained by students, related with data and behavior of the application interaction.

file in case C). Fig 4 and Fig 5 illustrate the identified concepts.

Fig. 3 Behaviour of application interaction (algorithm of main function).

Fig. 4 Definition of concept Farm (top concept).

Fig. 5 Definition of concept Cultivation.

Fig. 2 Data of application interaction.

Note that, students must use concepts (Farm and Cultivation) through the use of their interface operations, without going into great detail on how these concepts carry out their functionalities. The operations identified for concepts must be defined in the concepts Farm and Cultivation, respectively (interface in case Java; header

A. Problem Design The solution development must be guided by the top concept. So the process begins by implementing the top concept "farm" (in Fig. 6 see: attribute section and behavior section, for each functionality). This implementation includes: Defining the data structure: describe the attributes of a farm. This data structure has to be chosen based on what the concept is and how it behaves; Implementing the operations: describe the behavior of a farm, identified by students in the previous step. The main reason for using a top-down approach at this stage is due to the fact that students have little experience in problem solving. Therefore it is difficult to characterize concepts without taking into account the requirements. When implementing concepts, new concepts and operations are introduced in a progressive manner, guided by the need to fulfil the problem requirements. For example, in the farm attributes, new concepts - "Farmer" and "Seed", were introduced, as well as the required operations for these concepts. For example, in the concept Cultivation, new
International Journal Publishers Group (IJPG)

Morgado et al.: A Structured Approach to Problem Solving in CS1/2.


operations are introduced, when students implement the Farmer concept.

Fig. 6 Concept Farm (top concept final version).

Fig. 8 Concept Cultivation.

Fig. 7 Concept Farmer.

These new concepts, as well as the concept Cultivation, must be added to the solution, by including their definition and implementation (see Fig. 7, Fig. 8 and Fig. 9).

Fig. 9 Concept Seed.

At the end of this step, all the problem solution concepts should have been properly identified and implemented. The

International Journal Publishers Group (IJPG)


International Journal of Advanced Computer Science, Vol. 3, No. 7, Pp. 355-362, Jul., 2013.

final result should be a structured program that solves the problem.

5. Evaluation
This programming approach has been employed in laboratory classes of CS1/2 courses in computer science, electrical and physical engineering, where Java and C languages are used. These lab classes have about 30 students, and the results have been "good". In C lab classes, the approval rate increased by 25% and the dropout rate decreased by 40%, in courses with approximately 130 students (5 lab classes), as illustrated in Fig 10. In Java lab classes, the approval rate increased by 20% and the dropout rate decreased by 35%, in courses with approximately 160 students (6 lab classes), as illustrated in Fig 11.

have a minimum of 1, 4 and 3 problem concepts, respectively. The majority of students (98%, in C classes and 96%, in Java classes) understood the problems and were able to arrive at a solution. At each example, only two or five students did not present a solution, in C and Java classes, respectively. According to the components separation between user interaction and problem solution, the number of students that identified the top concept, was very high, as illustrated in Fig. 12 and Fig. 13. Note that, almost all students who understood the problems correctly have identified the top concepts. The difficulty faced by students when using concepts of abstraction and location, has been the most difficult problem to tackle in the teaching of programming. However, using this approach and applying it to many examples presented in classroom, has helped the understanding and the application of these principles.

Fig. 10 Programming approach results in C lab classes Fig. 12 Programming approach results in C lab classes

Fig. 11 Programming approach results in Java lab classes

Moreover, it was observed that the "blank page trauma" effect disappeared in most of the students, and the quality of the solutions has improved. These facts are evidenced in the evaluation performed in lab classes of the course of 2010, based on three problems: Tiles; MyFarm and Competitive Swimming. The first problem is a simple example related to the coverage of a classroom floor with square tiles. The second one is the example presented on the previous section, and the last one is an example related to the manipulation of a swimming event, since the registration of individual athletes until their competition. The presented examples

Fig. 13 Programming approach results in C lab classes

This fact is illustrated in Fig. 12 and Fig. 13, where the values show that a very high percentage of students have presented a "good" solution for the proposed problem (in C classes: 128, 100 and 93 respectively; in Java classes: 156, 109 and 115 respectively). These solutions have the required concepts, and some of them have more concepts, which, in our opinion, are correct. One example of these concepts was "seedBank" in the myFarm problem. However
International Journal Publishers Group (IJPG)

Morgado et al.: A Structured Approach to Problem Solving in CS1/2.


there are still some students with difficulties in presenting a structured solution (students with only the top concept or without it). As can be seen by the results, this programming approach helped regardless of the programming language used.


6. Conclusion
The use of this programming approach allows students to increase their ability to solve problems, independently of the programming language used. This conclusion is based in our evaluation in C and Java classes, which reveals: Students have a better understand of the problem, so it reduces the problem of "blank page", which is a discouraging aspect both for students and teachers; Students present solutions with a "better" quality, according to the solution organization, and the separation between the application interaction and problem solution. In addition, this approach improved the approval rate, decreased the dropout rate, and another important factor is that the students liked it. The use of prototypes for the understanding of the problem is a tool that all students point out as the strength of the approach. The weakness is the absence of a graphical tool to assist the program development. In our CS1 course using Java, we use the BlueJ, which is important to the learning process. But in C classes, we have no graphical tool to support the approach. For this reason, in the immediate future, we aim to develop tools for supporting this approach in all solution development process, regardless of the programming language used.










[19] [1] A. Whitfield, S. Blakeway, G. Herterich & C. Beaumont, Programming disciplines and methods adopted at Liverpool Hope University, (2007) ITALICS, 6(4). T. Jenkins, "On the Difficulty of Learning to Program." (2002) 3rd Annual Conference of the LTSN Center for Information and Computer Sciences, pp 47-39. L. Essi, A. Kirsti & J. Hannu-Matti, "A study of the difficulties of novice programmers." (2005) Annual Conference on Innovation and technology in Computer Science Education ITICSE, USA, pp. 14-18. P. Burton & R. Bruhn, "Teaching Programming in the OOP era." (2003) SIGCSE Bull, 35, pp. 111-114. M. Guzdial, "From Science to engineering," (2011) Commum ACM, 54(2), pp. 37-39. A. Elliot & M. Guzdial, "Developing a validated assesment of fundamental CS1 concepts", (2010) Annual Conference on Innovation and technology in Computer Science Education ITICSE, USA, pp. 97-101. J. Adams, Object-centered design: a five-phase introduction to object-oriented programming in CS1-2, (1996), 27th SIGCSE technical symposium on Computer science education, pp 78-82. A. Robins, J. Rountree & N. Rountree, Learning and [20]





[4] [5] [6]






Teaching Programming: A review and Discussion, (2003) Computer Science Education, 13(2), pp 137-172 H. Zhu & M. Zhou, Methodology first and language second: a way to teach object-oriented programming, (2003) 18th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pp 140-147. J. Giangrande, CS1 programming language options, (2007) Journal of Computing Sciences in Colleges, 22(3) pp 153-160. C. Schulte & J. Bennedsen, What do teachers teach in introductory programming?, (2006) 2nd workshop on Computing education research, pp 17-28. S. Crawford & E. Boese, ActionScript: a gentle introduction to programming, (2006) Journal of Computing Sciences in Colleges, 21(3) pp 156-168. S. Schaub, Teaching CS1 with web applications and test-driven development, (2009) ACM SIGCSE Bulletin, 41(2), pp 113-117. C. Kelleher & R. Pausch, Lowering the barriers to programming: A taxonomy of programming environments and languages for novice programmers, (2005) ACM Computing Surveys, 37(2), pp 83-137. A. Matthiasdottir, How to teach programming languages to novice students? Lecturing or not., (2006) International Conference on Computer Systems and Technologies (CompSysTech). P. Szlavi & L. Zsako, Methods of teaching programming, (2003) Teaching Mathematics and Computer Science. M. Ulloa, Teaching and learning computer programming: a survey of students problems, teaching methods, and automated instructional tools, (1980) ACM SIGCSE Bulletin, 12(2), pp 48-64. T. Rao & S. Mitra, An early software wngineering approach to teaching cs1, cs2 and ai, (2008) 39th SIGCSE technical symposium on Computer science education, pp 143-147. J. Adams & J. Frens, Object centered design for Java: teaching OOD in CS-1, (2003) 34th SIGCSE technical symposium on Computer science education, pp 273-277 D. Radosevic, A. Lovrencic & T. Orehovacki, New Approaches and Tools in Teaching Programming (2009) Central European Conference on Information and Intelligent Systems (CECIIS). L. Soh, Incorporating an intelligent tutoring system into CS1, (2006) 37th SIGCSE technical symposium on Computer science education, pp 486-490. A. Radenski, Digital support for abductive learning in introductory computing courses, (2007) 38th SIGCSE technical symposium on Computer science education, pp 14-18. P. Brusilovsky, E. Calabrese, J. Hvorecky, A. Kouchnirenko & P. Miller, Mini-languages: A Way to Learn Programming Principles, (1997) Education and Information Technologies, 2(1), pp 65-83. M. Esteves & A. Mendes, OOP-Anim, a System to Support Learning of Basic Object Oriented Programming Concepts, (2003) International Conference on Computer Systems and Technologies (CompSysTech). W. Dann, S. Cooper & R. Pausch, Learning to Program with Alice, (2011) 3rd Prentice hall Press., USA.

International Journal Publishers Group (IJPG)


International Journal of Advanced Computer Science, Vol. 3, No. 7, Pp. 355-362, Jul., 2013.

[26] A. Lawrence, Empirically Evaluating the Use of Animations to Teach Algorithms (1994) IEEE Symposium on Visual Languages, pp 48-54. [27] S. Nevalainen & J. Sajaniemi, An Experiment on Short-term Effects of Animated versus Static Visualization of Operation on Program Perception (2006) 2nd international workshop on Computing education research, pp 7-16. [28] C. Morgado & F. Barbosa, "Presentation Problem in CS1 courses" (2012) 17th Annual Conference on Innovation and technology in Computer Science Education, Israel, pp. 399-399.

Carmen Morgado is currently an Assistant Professor at Universidade Nova de Lisboa (Computer Science Dept., FCT). She received her PhD at Computer Sciences at Universidade Nova de Lisboa in 2009 and her MSc in 1999. Her current research activities are mainly on interactive learning environments and on social software and the studies related to modeling social interactions using group communications models. Fernanda Barbosa is currently an Assistant Professor at Universidade Nova de Lisboa (Computer Science Dept., FCT). She received her PhD at Computer Sciences at Universidade Nova de Lisboa in 2004 and her MSc in 1995. Her current research activities are mainly on applied computing for education: collaborative learning and interactive learning environments.

International Journal Publishers Group (IJPG)