# Tag Info

7

I saw the light at the end of the fiber optic cable as soon as you said that these are students of electronics. There is nothing more modular and encapsulated than that! Software is simply electronics without the hardware part. If you said to them, "What are the building blocks of a simple AM radio receiver?" they would (hopefully) reply something like: ...

6

Instead of an example, use a metaphor. Get yourself a frisbee - ultimate disk and two packs of sticky notes. You are the caller of a function. Another person is the function itself. Write a value on the sticky note and stick it to the frisbee. The pass it to the function (person). The person catches the disk, and replaces the stick note with a new one with a ...

5

One of the interesting things added to java in v8 is functional interfaces. Previously java only matched things up and verified correctness by type (type names). With functional interfaces, java now looks at the structure of code in certain situations. I can add examples to this answer to clarify if anyone asks. One interesting feature you can add is a ...

5

I post solutions after the due date of an assignment. And usually, I'll go over them in class as well. Two birds... Students get to see at least one working solution, although I try to come up with several. Posting the solution serves as a good block to students asking to turn in assignments late. They'll understand pretty well that they can't turn it in ...

5

I have used a similar idea - writing an SHA-1 hash cracker - as a mini-project for students learning Java. These students had previously learned to program in other languages, so they had experience with variables, if/else, loops and functions; the main goal was to get them used to Java's syntax, but some of the specific things they had to do were: Import ...

4

To give or not to give, that is the question There are actually several possibilities that reflect how you want the provided solution to be used. For context, I am an instructor at Colorado State University and I am discussing assignments that students might encounter in the first two to three years (not CS1). Don't ever give the students solutions The ...

4

Create an object that creates a new file and writes in to it over several method invocations (not just one). Assure that the object has been deleted before continuing (Make the object go out of scope on the stack or delete a reference and let the reference go out of scope.) You need to assure that he file was closed. The destructor is the proper place to ...

4

Whether this is a good plan or not depends on some things, most especially the nature of your students. However, it seems a bit too unstructured. If you have a general mix of student ability it could cause problems unless you incorporate the questions from the site(s) more formally into your teaching. There are a lot of questions available, I would guess ...

4

Don't provide code dumps. Provide guides that outline the process of solving the problem. Create a function that squares a number passed to it Don't just give out a fully-coded solution. The answer to this question is not as simple as regurgitating the syntax. It's a process of breaking the question down into smaller steps and taking those steps on one ...

3

Reading an answer is not the same thing as solving a problem. I think different areas of the brain are engaged. Solving the problem yourself is a stronger reinforcement of the ideas certainly. Frustration is a mind killer. Students shouldn't be frustrated when they are trying to learn and as novices they have few tools for problem solving. So, to resolve ...

3

There are 2 good examples of patterns where the destuctor is a key. This way you can teach a couple of useful patterns on the way. RAII - Resource Acquisition Is Initiation Rule of 3/5/0 It's easy to give a RAII assignment, just any C style handle that can be released in the end (Like a File handle, windows handle, etc). If they are more advanced, you ...

3

Classification problems are reasonable candidates. For instance, I wrote a GA that looked at the mushroom dataset taken from the UCI Machine Learning Repository with the goal of classifying an unknown mushroom as safe or poisonous based on its traits. Each candidate solution encoded a series of rules (Red cap means poisonous, blue spores are safe). During ...

3

I think you have left out two essential elements here. Your first two points leave the students passive consumers. The last is about testing. But there is no guarantee of any learning in between. In some ways, the two most important pedagogical ideas are Active Student Constant Feedback You need to ask your students to create things and you need to give ...

3

You could have a hierarchy based on an abstract class or interface Car, with implementations/subclasses for ElectricCar, HybridCar, GasBurningCar, etc. This illustrates that there can be very different implementations for an interface. Each class would have different additional members. For example, a GasBurningCar could have a maximum amount of gas (in ...

3

A famous example is Strassen's matrix multiplication algorithm, whose running time satisfies the recurrence $T(n) = 7T(n/2) + O(n^2)$. A similar example is Karatsuba's algorithm for fast integer multiplication, whose running time satisfies the recurrence $T(n) = 3T(n/2) + O(n)$. Other algorithms for multiplying matrices or integers supply even more examples ...

2

I have used an example of a machine which has a serial number and a state. It can be turned on and off, it can be told to give out its serial number. A bMachine can be powercycled (inheritance from machine). There is a machinedesk which contains machines. They can self check. I worked through a whole range of 'things' that the objects could do to ...

2

One example that isn't necessarily exciting but would allow for a lot of class design is a Shape interface. From there let's say you have Quadrilateral, Ellipse, and Triangle as classes which implement Shape. You could do some really cool things by including as methods formulas for area and perimeter. Additionally, within Quadrilateral, you could further ...

2

One extremely handy macro is creating names ranges. Start recording Select the range you want to name Press the "create named range" in the "formulas" tab give name stop recording. Voila. This has many uses in real life Another one might be creating a table with headers. Record Select the table detect the headers with "format as table" and check "my ...

2

I'll start by adding the exercises I'm currently using, but please don't let this stop you from posting more! Create a macro that inserts a header row. (Story: "Every day I download a csv file. Always the same structure, but it is missing the header row. I want a macro that inserts a formatted header above my data.") Number formatting macro (Story: "I ...

2

I think the most critical thing about lambda functions is that they enable the convenient use of map and filter functions on collections and streams. Exercises in using these (and their equivalents in Optional, which is perhaps just as important, allowing us to get rid of null as it does) are probably the best way of showing what you can achieve with lambda ...

2

One idea might be to borrow SQL-related exercises -- find problems asking the reader to come up with some sort of SQL query to find information, and rephrase the problem and ask students to come up with an equivalent query using only Java's functional interface and lambda expressions. (I wouldn't bother telling students these questions were originally about ...

2

Design patterns covers a broad area. I'm going to assume that your students are beginners, more or less. Elementary Patterns A few people have developed some interesting elementary patterns for things as simple as loops and selection: http://www.cs.uni.edu/~wallingf/patterns/elementary/ These patterns help students program at the lowest level and, after ...

2

As well as what you have already mentioned: Provide working code, and have them modify it (top down as opposed to bottom up). I also see an opportunity to reduce time between students actions and receiving feedback. Automated feedback (this is not a substitute for teacher or peer feedback) Use a visual language, such as scratch or snap. This reduces ...

2

I think this answer is a little different, please remand me if not - I provide an algorithm with my coding assignments, and I almost always have code I can point to in their notes or previous assignments that is exactly what they need to fill in the algorithm. First I give a general description of the problem: Create a Windows forms application named ...

2

Can I craft an exercise ... that would give a dramatically wrong output, e.g. cause the screen to "blow" up if the function print-ed instead of return-ed... [my emphasis] Early in my python classes I do (something like) this: >>> def foo(x): ... print(2*x + 3) ... >>> def bar(x): ... return (2*x + 3) ... >>> foo(4) ...

1

I don't think you're going to find a good data set that contains what you're looking for. The reason is, teaching and learning are very subjective. I don't think there's any one definition of what makes a "good" explanation. An explanation that I think is helpful might not be very useful for you, and vice-versa. For example, maybe one person just wants to ...

1

I like to think about pure function as a transmutation of inputs. Just like in Alchemy you connect Fire and Water to get Steam. Fire and Water are inputs, Steam is output. Or treat function as an assembly machine -- it takes resources, and converts those into another resource. After that try posing a question: given two integer numbers as an input, what ...

1

Sorry this is a half answer because I haven't concrete examples right now. Besides, the answer with the electronic analogies is already so great. But one point attracts me. At the level where I imagine your students are, they do not need the modularity effectiveness that can be obtained with well structured functions. Indeed, you report from them mistakes ...

1

Let's see if I can answer the questions head on here. Should I provide answers to the exercises? Yes. programming is not like mathematics, although they are closely related. They are multiple ways to achieve the same results. Some students appreciate when they are provided with the expected answer. If so should I include them as a part of the document ...

1

I'm not a native of C++, but it seems to me that a Conway's Game of Life simulator, with cells as immutable objects, would be a great way to show the need for a destructor. Without one, your program would quickly run out of memory. And, of course, it's not a bad approach to the problem. All you'd have to do to demonstrate why such an approach is ...

Only top voted, non community-wiki answers of a minimum length are eligible