Spring '22 Week 3
Resources
Edited Transcript
Hello, and welcome to the week three announcements video for CC 410 in spring 2022. So this week, you should be wrapping up the second module in the class, which is all about object oriented programming. And so if you’re seeing this on Monday, by the end of today, you should have the object oriented programming example done, and you should be submitting the first milestone for your restaurant project. Coming up this week, you’ll be working on module three, which is all about documentation, testing and UML. There’ll be a great example on how to do documentation and testing in your code. And then you’ll be working on the second restaurant milestone, which is all about adding unit tests to your code.
So don’t forget for updates in this class, you can always find me on the discord channel. If you have any quick questions. I’m also responding to the emails, so feel free to use whichever one is most convenient for you. If you don’t get an answer on Discord very quickly, feel free to send me an email after a little while I guarantee answers via email within 24 hours within a working day. So you can always get feedback there. Also, for grading, I just got done grading the first example the Hello real world example. And I believe for everybody, I left a comment on Canvas as well as a code comment in GitHub. So make sure you look in both places to see those comments. They’re very minor. But that way you know what you’re looking for when you see comments on this next milestone. Usually this first milestone, I leave quite a few comments on it. Otherwise, I think things are going well. So far this semester. If you have any comments or concerns, feel free to let me know.
So for the second milestone, you’ll be working on unit tests. By my estimation, you’ll be adding about 400 unit tests to your code, which is a significant amount. You’ll also be working on documentation comments in your code so that everything is documented. Make sure you read the instructions very carefully to know what you should document. But basically, everything should have a documentation comment to go with it. Um, you’ll also build a UML class diagram for this program. And then throughout the semester, you’ll be updating it in bits and pieces. Once again, I estimate that this milestone will take anywhere between three and eight hours depending on your level of experience and how fast you work through it. This one is also significantly larger, by the time you’re done, you should have about 3000 to 4000 lines of code in your project. So this one, you’re really growing the size of your project quite quickly. Again, a lot of it is boilerplate code. If you write a unit test for one class, a lot of times that unit test can be used with very minimal changes in multiple classes. And as always, if anything’s unclear in these milestone descriptions, feedback is always welcome. I’m always refining these a little bit to see if I can make them better.
So some big hints for the second milestone. First and foremost, do not look at your source code while writing the second milestone, go back and look at the original first milestone, look at the second milestone information. But try and write your unit tests without looking at your source code. And the reason you do this is you want to write your unit tests so that they’re checking what your code should be doing, not what your code actually does. And so for example, if you have a typo in the price of a particular item, and you’re just referring to your source code, write the unit test, the unit test will not catch that typo. But if you’re looking at the original menu to figure out what price it should be and write the unit test to verify that, then you’ll actually check that typo. And it’s important because when I wrote this model solution the first time I found about six typos in my code by going through this process, so make sure you try and look at only the stuff that you have, instead of the source code to write these mile write these unit tests. Second thing you can do on your unit test is to use Global attributes to simplify your unit tests. And on the next slide, I’ll show you a little bit of an example of that. Likewise, you can try and generalize some of the unit tests. For example, unit tests to check for toppings that you can add or flavors that you can add things like that those can be generalized using some unit tests that go across the items that make up that particular set of items. But typically, the core ingredients on an item you can’t change. So you can look at parameterized tests across the items to make that a little easier.
So when I’m talking about generalized tests, this is what I’m talking about. This is an example from an earlier semester. But let’s say you’re writing unit tests to verify the price and the calories for a particular item. instead of hard coding that value directly in the unit test at the top of your test class, you could simply have some global attributes that set the price and the calories and things like that. And then by doing so, your unit test code can pretty much be copy pasted with one quick find and replace for the different objects that you’re testing. And that’s all you have to do. So it makes it a little bit easier to maintain some of these files as you go through go through things. I found this to be kind of easy. Hopefully you do too. So feel free to look at this example and see if it makes sense to you.
So that’s all for this week. Looking ahead, the module for the week after this is all about inheritance. Then we’ll spend a module on debugging and lambda expressions and that will your final project check in at the end of February. Then we get into the GUI stuff starting in March. So we’ll do some work with GUI basics event driven programming. And then toward the end of the semester, we’ll work on some web interface stuff as well.
So that’s all for this week. I hope it I hope you enjoyed this milestone. It’s really interesting. For a lot of you this might be the first time you worked with unit tests. So you’ll be writing an awful lot of tests, but hopefully you can start to see how powerful they are in your code. As always, if you have any questions or concerns, let me know and I look forward to seeing you again next week.