Spring '25 Week 3
Resources
Edited Transcript
Hello and welcome to the week three announcements video for CC410 in spring 2025. So you should have already wrapped up the second module which is on object oriented programming. We do a small example on object oriented programming where you make a few data classes and then you worked on the first big restaurant milestone where you made object oriented programming classes for each of the menu items in that restaurant itself. So this week we’re going to move ahead by talking about some things around documentation, unit testing and UML to actually diagram your program. We’ll do a documentation and testing example. And then for your second restaurant milestone, you’re going to write unit tests to actually review the code that you wrote in the previous milestone and make sure it’s correct.
So for the second milestone, you’re going to be writing unit tests. The number of unit tests that you write may vary. My model solution has around 400 unit tests, but it may be a little bit overkill. So in the range of three to 400, I think is what’s appropriate. You’ll have documentation comments that you’ll add to all your code. You’ll add a UML class diagram for your project. In total, this project should take between three and eight hours as long as you work pretty diligently about duplicating unit tests carefully between the different classes. You’ll find that most classes have very similar unit tests. So this one may be between 3500 and 4000 total lines of code, but a lot of that again is repeated and copied. And as always, feedback is very welcome.
So some big hints for the second milestone. Do not look at the source code for your solution to milestone one. For example, the mistake that a lot of people make when writing unit tests is they pull up the code for the class they’re going to test and then right next to it, they write a unit test to test that code. That leads to tests that are bad. What we want to do is we want to write tests that confirm that the code works correctly, not that the code works like it is written. So for example, if you’re checking the price of an item, you should go back to the original menu from the milestone one description and look at the menu price for that object and code that into a unit test. You shouldn’t look at the source code to figure out what that price is because if the price is wrong in the source code, your unit test will then test for the wrong price. A lot of students have made this mistake. One thing you can do is you can use global attributes at the top of your test for things like the price and the number of ingredients and the toppings and things like that. You could just have some global attributes at the top and then write the unit test so that they just read those attributes. In that way, you can just copy paste all the unit tests between the classes and change those global level attributes to represent the different classes. There’s a lot of different ways you can do it. You should also look at parameterized tests across enums to check all the different values. For example, if you’re not sure how to do that, here is some examples of generalized tests using global variables in both Java and Python. For example, this Java one, I have a price and a calories at the top. And then when I check for the correct price, the correct calories, I just reference that global variable. So instead of having to change those values down in my code, I can just change them at the top of the class and then copy paste all these unit tests in between the multiple classes to check the price and check the calories.
Beyond that, I really want to encourage you to think about this class in terms of a growth mindset. The milestones in this class are challenging. They’re meant to be challenging. The only way that you’re going to grow and get better as a programmer is by being challenged a little bit. And so when the milestones don’t feel like they’re easy, that’s because they aren’t. We want you to learn. So I want you to take some time, make sure you’re reading very carefully. If something doesn’t make sense, ask for clarification. And then, of course, start early, work methodically, and commit your work often to Git. For example, the milestone that’s do this next week, you should be starting on it right now and starting to work through that code a little bit at a time, instead of saying, oh, I’ll just do everything on Sunday. When you try and work eight hours in a block, that’s really, really hard to do. So if you do a little bit at a time, that helps you figure out if you run in any errors, if you need any assistance, things like that.
So looking ahead after this week, we’ve got milestone four. Next week is going to talk about inheritance and polymorphism. Then we’ll spend a module on debugging and logging. Then you’ll have your second final project check in toward the end of February. Then we’ll switch over to do design patterns and test doubles, which I think are the two really cool things we cover in this class. And then after that, we’ll talk about graphical user interfaces, web interfaces, et cetera. So hopefully things are going well. You’re going to write an awful lot of tests this week, but it’s really, really good practice to get used to writing unit tests for your code. It’s something that you do a lot if you write professional software. As always, if you have any questions at all, feel free to let me know. Otherwise best of luck, and I will see you again next week.