Spring '24 Week 3

YouTube Video

Resources

Edited Transcript

Hello and welcome to the week three announcements video for CC410 in spring 2024. This week, you should be wrapping up module two, which is all on object -oriented programming. You will have done a quick example of doing object -oriented programming in a smaller scale, and then you should be working on the first actual restaurant milestone where we’re going to build out the object -oriented classes for all of the items on the menu. This week, we’re going to spend some more time working on object -oriented programming. Specifically, we’re going to take the time to add some documentation to our code. We’re going to add a lot of unit testing to our code, and we’re also going to learn how to make a simple UML class diagram that represents our code in a graphical way so we can understand how it works. You’ll also start working on the second restaurant milestone, which is all about adding documentation and testing to your existing restaurant project.

So the second milestone is adding about unit tests. There are approximately 400 unit tests that you’re going to add. It could be more or less depending on how you implement them, but in my model solution, I’m around 400. You’ll also be adding documentation comments to your code and a class diagram. This milestone, I estimate, will take anywhere between three to eight hours, and it will involve anywhere between 3 ,000 and 4 ,000 lines of code. A lot of those lines of code are in unit tests and documentation comments that are very structured, so you can copy -paste a lot of that, but you’ll still have to be careful and make sure that everything is correct and looks right, and all the unit tests are actually testing the right thing. Finally, as always, as you work on these milestones, if anything is unclear or you feel like something is not described well, feel free to shoot me an email and send me feedback and let me know. I’m always working on refining these so that the requirements are clear and so that it’s easy to understand what you’re supposed to do so that you can spend time working on it very quickly.

Some quick hints for the second milestone. First and foremost, do not look at the source code for the first milestone. What I mean by that is when you’re writing a unit test, don’t go back to your source code to write the unit test, but go back to the initial documentation. For example, if you misinterpreted the documentation and had the price wrong in your source code, and then you used that source code to write the unit test that checks the price, you’re never actually going to test the unit test. find the error that your price was wrong. So instead, you should go back and look at the first milestone and see what the price should be, and write a unit test that confirms that it’s correct based on the documentation, not based on your source code. Hopefully, that makes sense. Another thing you can do is in your unit test files, you can use global attributes to generalize things. And so I’ll show you an example of that here on a later slide in this announcement. And so you can kind of generalize some of the things, but don’t try and generalize the individual ingredients of an item. So for example, if you’ve got a sandwich that has ham and cheese and pepperoni, those things you can’t generalize, but the toppings, because they’re in an enum, you can generalize those. And so you can look at some parameterized tests to generalize across the enums.

So when I talk about generalized tests, here’s what I mean. Here’s a quick example in both Java and Python, where I put the price and the calories as global variables at the top of the class. And then the unit test basically checks to see the price of the item is the price that I put at the top of the class. The reason I do it this way is I can actually copy paste this entire file, change the value of the variables at the top, and then do a control F for the Riker and change the Riker to whatever other item, and that will cover a lot of the unit tests right away. So it allows you to generalize some of your code so that you can do some unit testing and copy paste the code very quickly. It’s all about working a little bit smarter and not necessarily typing everything from scratch, which I know is going to be a change compared to how you did some of the previous computational core courses.

So looking ahead after this milestone, we’ve got modules four and five, introduce inheritance, and debugging into our project, and then we’ll have the second final project milestone toward the end of February, where we’ll actually get to talk a little bit more about final project ideas and maybe have you start doing some design work on your final project. After that, we’re going to go into a couple of modules that are relatively new. They’ve been here for a couple of years, but I still mark them as new modules because they’re kind of a redesign of this course from a year ago, where we’ll spend some time on design patterns and test doubles before we get into user interfaces and web, etc. This milestone is all about writing unit test for your code. I hope that works really well.

I apologize for missing the announcements last week. Some of you may have met with me and realized that I fell and fractured my elbow in my right arm on Monday, and so I wasn’t able to do a whole lot on Monday last week. So I ended up missing this announcement, and I apologize for that. But everything’s going well now. If you have any questions at all, please let me know. My goal today and tomorrow is to get a lot of grading done. So I’ll get caught up on the grading for the first milestone, as well as the Hello World project, and get everybody back up to speed. So if you have any questions, let me know. Otherwise, good luck this week, and I will hopefully see you again next week.

Subsections of Spring '24 Week 3