Abstract
This article describes experiences of teaching object-oriented programming to undergraduate Electrical Engineering students. The proposed project-based methodology increased the interest of students in programming. The project focuses on the development of a small C++ class that allows students to build geometric models by manipulating a three-dimensional matrix. The class methods (C++ member functions) can draw complex scenes by using combinations of them. Students can improve their programming skills according to the points of view of a class developer and a class user. In addition, students try to create beautiful models to present to each other, making the learning experience pleasant and motivating.
Introduction
Computer programming is usually a mandatory subject in the first year of most engineering courses. Current curricula suggest object-oriented programming (OOP) as one of the primary paradigms in teaching programming. 1 Many programmable devices support OOP for software development and interfacing. Applications for cell phones running operating systems such as Android or iOS, for example, are made with object-oriented (OO) languages.2,3
In computer programming, game development is the most common choice to motivate students with different profiles to a common subject of interest. 4
However, an alternative project-based learning (PBL)
a
approach is presented in this article, mixing introductory concepts of computer graphics, C++ programming, and geometric modeling that can be easily learned by freshmen. They are expected to develop, with a reduced number of lines of code, a C++ class and a
The learning goal is to know the fundamentals of the C++ programming language through a project that stimulates the student through art.
The general idea is to develop a C++ class, called
Within the

UML class diagram.
To create a sculpture using the

Dataflow showing the sculpture construction and visualization process.
Each voxel in the 3D matrix has a Boolean attribute
When all forms are included, the 3D matrix of voxels can be saved to a file, following the specification of a standard format for defining geometry in files. Each voxel is a small cube and is represented in the file by its six faces. The result is an ASCII file that can be visualized using any software that recognizes the adopted file format.
The PBL approach presented in this article was applied for two and a half years with five instances of an OOP course offered for Electrical Engineering (EE) students at the Federal University of Rio Grande do Norte (UFRN), Brazil, making a total of 135 students within this period.
Next section “Related work” describes previous successful projects on teaching OOP using different curricula. The sections “Description of the project” and “Programming aspects” present the proposed framework and some programming aspects of the approach. The results, including grade assessment, are presented in the “Results” section. Finally, the sections “Qualitative discussion” and “Concluding remarks” qualitatively discuss and conclusively summarize the proposal.
Related work
PBL approaches have been successfully used to teach computer languages, even for freshmen. 6 An interesting approach proposed by Goulding 7 was to implement the ENIGMA encryption system in C. The motivation was provided by the history of the ENIGMA machine in Second World War and by the challenge of replicating its operation with software.
After searching the current literature on teaching OOP, two main aspects were noticeable: OO languages have been preferred for developing practical and large-scale software, 8 and using computer games or graphics has been successfully applied to several curricula. 9
Overmars, 10 for example, introduces GameMaker as an interactive tool for creating games. Jordine et al. 11 propose a tower defense game in which the programmer has to define Java classes to create towers and solve a level. Sung and Snyder 12 describe another game-based PBL approach in which students are required to develop games using the C# language and XNA. Yan 13 explores the Greenfoot 14 environment for teaching OO programming with Java, by building games, simulations, and other graphical programs using a mix of graphic design and text programming.
Creating computer games is a fun way to learn and practice programming, object modeling, and design patterns. 9 However, in many non-computer-oriented engineering curricula, there are few or even only one mandatory course on OOP. So, considering those time constraints, it is difficult to present students even a simple game development framework and demand the creation of a fully functional game. On the other hand, text-based games are not impressive and are usually considered boring by students.
The adopted PBL approach to address time limitations while maintaining motivation is a mix of console programming with some computer graphics to generate 3D objects.
The main difference between this approach and others found in the literature lies in the ability to prompt a
Description of the project
The EE curriculum at UFRN has three mandatory courses focused on computer programming:
The project described in this article is applied in the Advanced Programming course, which mainly explores OOP. It is taught in the second semester of the five-year engineering formation. It has a total of 60 h over 18 weeks, with two weekly meetings (each lasting 100 min) in a laboratory. About 70% of the meetings are dedicated to presenting subjects that are assigned to this course (pointers, C++ fundamentals, OOP, data structures, etc.). The other 30% of the meetings are dedicated to tracking project development with students in the lab.
Considering these time constraints, a project-based OOP learning methodology that could achieve the following objectives is sought:
Students should be presented with the main fundamentals of OOP using a self-motivating strategy. Students should practice OOP from both the point of view of a Time restrictions should be considered. Students should experience challenges that are common in software development for engineering. Students should be able to propose new functionalities that are beyond the minimum project requirements.
The first step was to find a common subject that could increase interest among students. While searching for game approaches, Minecraft 16 drew special attention. In short, the game inserts the user into a virtual world where they are able to build complex structures simply by inserting or deleting blocks into a 3D matrix-like style. Following the Minecraft approach, the idea was to conceive a project that allows students to use simple functions to build complex structures placed in a 3D virtual environment.
The simplest way to address this problem was to create a 3D matrix allocated into the computer memory and set up some properties for each matrix element, hereinafter called
Voxel representation
Five fields (or attributes) represent each voxel, as described by the UML representation in Figure 1:
The size of the 3D matrix is defined by the user according to the width, height, and depth properties of the model. The spatial coordinates of each voxel (
To better illustrate the idea, consider a very small 3D matrix of
Example of 3D voxel matrix and its properties.
Irrelevant value.
The sculpture associated with the matrix in Table 1 is presented in Figure 3. Each voxel that belongs to the sculpture is represented as a cube centered at the corresponding voxel coordinates and filled with its color. For this example, the voxels that do not belong to the sculpture (

Simple sculpture enclosed in a matrix of size
Once the voxel properties of a given matrix are defined, its corresponding 3D model should be generated. The simplest approach is to create a polyhedral model consisting of several cubes such as the ones presented in Figure 3.
Several alternatives for representing 3D models are available in the literature such as VRML, 3Ds, PLY, Wavefront OBJ, and X3D. Perhaps the simplest method is the Object Oriented Graphics Library, 18 a set of file formats that are supported by Geomview 18 and other visualization software.
The OFF file format
OFF files represent collections of planar polygons with possibly shared vertices 19 and it is well suited to represent a sculpture entirely represented by cubes facets. The OFF file is based on an American Standard Code for Information Interchange (ASCII) format, 19 so it is easy to be understood by the students.
Moreover, numerous free software such as Geomview 18 or Meshlab20,21 are able to display OFF files on Windows, Linux, and Mac. Once the students build models using the class methods proposed in this article, they store the models into OFF files using a class method and visualize the files using their preferred tool.
An OFF file is usually written in ASCII format c which allows storing polyhedra data whose faces have some properties, such as normals, colors, and texture coordinates. The syntax of an OFF file 18 is presented in Figure 4.

OFF file format syntax.
An OFF file starts with the mandatory
The following
The list of faces follows the list of vertices. Each line defines a face that is composed of a sequence of
The simple structure of the OFF file format allows a student to create a class method that evaluates the matrix of voxels and writes the corresponding OFF file.
Once the OFF file concepts have been presented to students, a set of resources are required to be implemented in C++. Such resources will allow the user to draw into the 3D matrix using a small set of simple methods.
Methods for drawing into the matrix
To build their digital sculpture, students have to implement a class for drawing into the matrix of voxels. This class is called
The proposed class and its use are discussed in the following section.
Programming aspects
Class description
The C++ header file contains common prototypes for a structure named
The
The
Programming issues explored in the project
Some of the
The
The other methods,
One of the mistakes frequently made by students occurs when the coordinates are generated and the required tests are not included in the code. Students usually create sets of loops to generate matrix indices, as in lines 1–3, Listing 3. These loops can create indices outside the valid range of the volumetric matrix. Bad indices are a very dangerous source of errors in engineering software and they can be easily prevented by proper range checking (lines 4–5).
Other common mistakes come from integer divisions. For example, to decide whether or not a voxel belongs to an ellipsoid, the program must test if
Incorrect handling of data types when implementing this equation can create errors, such as integer divisions expected to produce float results, but actually generating values equal to zero. These mistakes can be easily avoided by simple type castings, as in lines 6–8 of Listing 3.
The
The
Using the Sculptor class
The functionalities of the
Line 4 creates a sculptor object “ Line 5 sets the current color to fully opaque red, i.e. Line 6 draws a box spanning the entire available space in the sculptor matrix. This will set all voxels to red. In line 7, a box that is two voxels thinner than the previous one is removed, hollowing the red box. Line 8 sets the current color to fully opaque blue, i.e. In line 9, a sphere centered at Finally, line 10 saves the model to file

Model of a red box with a blue sphere inside of it.
As shown in Figure 5, more complex solids can be constructed using a combination of simpler methods.
Results
This project has been presented to 135 students over five semesters. The project is expected to be fulfilled within approximately five weeks, including the development of class methods and the production of a 3D sculpture. Students usually take two weeks to develop the class and another two weeks to finish the model.
Evaluation
Grades are assigned according to two criteria:
Technical (50%): The student’s
The technical grade is the average of the scores assigned to the result of using the student’s class to compile each of the predefined programs:
○ 100% if the expected sculpture is produced, with the correct number of voxels to represent it. ○ 50% if the expected sculpture is produced but with a larger number of voxels than necessary. ○ 0% if the produced sculpture is incorrect or if there are compilation or execution errors. Artistic (50%): Students must present the creation process and the final result of their sculptures to the colleagues.
They also subjectively group all other sculptures into three sets of equal size, according to the artistic quality and the degree of difficulty: the best (value 3), intermediate (2) and worst (1) sculptures. The average of all values attributed to each sculpture is calculated and used to assign the artistic grade.
Even the artistic grade being based on subjective impressions, the classification of the sculptures into three groups is relatively consistent in an inter-rater reliability test using Krippendorff’s alpha coefficient.23,24 For example, grades from the last three semesters generate statistical measures of agreement of 0.514, 0.564, and 0.856 on a scale of 0 to 1, where 0–0.20 indicates no/poor agreement; 0.21–0.40, fair agreement; 0.41–0.60, moderate agreement; 0.61–0.80, substantial agreement; and 0.81–1.00 indicates near perfect/perfect agreement. 25
Grades were evaluated over the course of four years for eight instances of the OOP course, within the range [0,10]. The mean and standard variation for these eight instances are presented in Figure 6. The red marks are the grades before this approach was started. The blue marks are the grades when this project was adopted, with a noticeable increase over the previous approach.

Students’ grade evolution.
Produced sculptures
Another way to illustrate the results of the digital sculptor project is by presenting a representative set of the produced 3D sculptures. Most students try to model objects that are meaningful to them: characters and objects of games, comics and cartoons, technological gadgets, hobbies, and so on.
The iPhone 5 was one of the first models developed in this project. It is presented in Figure 7, and it was designed by a group of two students using only the methods presented in the “Methods for drawing into the matrix” section. The model is composed of 56,224 vertices and 42,168 faces, featuring only two shades of gray.

iPhone5.
Less skilled students sometimes create sculptures using only a few instances of the predefined required methods, such as the Pokémon Luxury Ball in Figure 8. Even these students, however, acquire a reasonable understanding of the fundamental OOP concepts and are proud of producing a 3D “object” they were not capable of before the course.

Pokémon Luxury Ball.
The Guitar sculpture presented in Figure 9 was constructed using additional methods other than those required. Since they are not allowed to modify the

Guitar.
The snow effect in Figure 10 was modeled by changing the color of random voxels to white. Although simple, the effect is beautiful when visualized with Geomview.

Snow.
Figure 11 is an attempt to recreate the “Arena das Dunas” Stadium.
e
It was the most complex sculpture submitted in this project. It depicts the stadium with a large amount of details and a “creeper” Minecraft character watching it. The students decided to subclass the

Arena das Dunas Stadium.
Qualitative discussion
An examination of the literature used in this article5,26–30 reveals that some non-traditional educational approaches can have a significant impact on increasing student performance. 26 Much of the research indicates that passive learning modes are much less effective than modes where students are involved in active learning. 26 Also, peer interaction is particularly effective for promoting learning. 26
The main objective of this proposal is to increase the interest and motivation of freshmen students in learning OOP. For that, a project-based methodology was chosen, since it has been reported that students prefer to learn through carrying out a real project because they feel it provides them with more motivation to learn. 27 Also, previous analyses suggest that a problem-based learning methodology offers significant benefits when compared to a more traditional didactic method. 28
Our approach is strongly influenced by problem-based learning, defined as “a learner-centered approach that empowers learners to conduct research, integrate theory and practice, and apply knowledge and skills to develop a viable solution to a defined problem”. 5 However, we adopt a hybrid form of PBL, which combines learning through projects with delivering essential knowledge via lectures and assignments. Previous works report that this mixed strategy is more effective at delivering all expected learning outcomes in an advanced technical course than pure PBL. 29
Some general characteristics are commonly associated with the use of active learning strategies in the classroom
30
:
Students are involved in more than listening. Less emphasis is placed on transmission of information and more on developing students’ skills. Students are involved in higher order thinking (analysis, synthesis, evaluation). Students are engaged in activities (e.g. reading, discussing, writing). Greater emphasis is placed on students’ exploration of their own attitudes and values.
This proposal attempts to incorporate these characteristics in the following ways:
During the development of the project, there are no classical lectures. Students remain in pairs throughout the class time, working on the development of their The teacher has the role of an itinerant consultant, circulating among the groups to answer questions and provide suggestions. Technical OOP knowledge has to be combined with the ability to mentally visualize abstractly described 3D objects with artistic considerations. In the end, students have to orally present their work and emphasize its qualities to the colleagues, in order to achieve a good peer-assigned “artistic” grade.
To assess if the goal of increasing student motivation in learning OOP was achieved, it is difficult to calculate a quantitative measure. However, a qualitative evaluation can be achieved, based on previous experience of the teachers and student feedback. Feedback was obtained using an anonymous faculty student feedback survey, which is applied by UFRN to all students at the end of each semester as a mandatory procedure of their academic life.
The acceptance by students has been very good. They are usually grateful for the opportunity to learn C++ programming using this method. There is no need to encourage students to develop their projects. They develop the class methods to start building their sculptures as soon as possible. Once these methods are created, they focus on model building, improving their spatial referencing capabilities to insert structures in the 3D sculptor.
The instructors
f
observed some interesting aspects:
Students improved their understanding of the fundamental concepts of OOP. The choice of this programming paradigm is well accepted by students, since it is easy to realize the difference between the overall sculptor (the class), the piece of software that endows the sculptor with another skill (a method) and the combination of class methods (the Students are so focused on creating methods and sculptures that they learn C++ almost without realizing it, associating learning with fun. Students’ spatial orientation capabilities are improved since they must position 3D objects into the sculpture. Most of the programming issues presented in the “Methods for drawing into the matrix” section are experienced by all of the students. They learn from these issues just by observing the effects on their 3D models. Some students do not feel satisfied using only the mandatory class methods. In addition to the mandatory methods, students develop their own subclasses to perform specific tasks. Students always suggest that the project should be included in the following semesters of the C++ programming course. Nice sculptures that are produced by students from one semester serve as a stimulus for the next students.
Concluding remarks
This article describes a PBL approach for teaching OOP for students in the early years of an engineering course. Its main characteristics and differences in relation to other proposals are as follows:
Few requirements. This educational tool can be used with freshmen, with only introductory previous knowledge of computer programming. The proposal can be adopted for different engineering curricula, not only in computer-oriented courses. The project does not require any specific software or dedicated development environment, and can be completed using only any C++ compiler. Finally, the project does not require a significant amount of time to be executed, in such a way that it can be included within a larger course. Motivation. Students usually report to instructors that they enrolled in the course for the opportunity to create a 3D sculptor project. This is an interesting aspect, since the project itself is not mentioned in the course syllabus. Students tell each other about the project and show their 3D models to colleagues. Personalized learning. A common issue in programming courses for engineers is that students are not equally previously prepared for the course. With this project, even the less prepared students are able to achieve the minimum requirements. Students with deeper previous knowledge are free to create more advanced structures. Sculpture exposition. At the end of the course, students are required to present their sculptures and discuss their creation process. It is a very important moment since students have the opportunity to express how the project helped them learn OOP and the tricks used to create their model. Limitations. This learning tool was specially conceived to increase motivation in freshman engineering students during their first or only course on OOP. Due to this characteristic, it does not address so thoroughly all aspects of OOP. Thus, if other concepts (polymorphism, for instance) should also be deeply covered, perhaps another approach would be more suitable, replacing or complementing this project.
Footnotes
Acknowledgements
The authors would like to thank all the students who helped to create and improve this project.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
