Subsections of Fall 2021
CC 310 & 315 Cover
YouTube VideoResources
Edited Transcript
Greetings to students in CC 310 and CC 315. My name is Russell Feldhausen. And I’ll be covering for Emily this week while she is out of the office. My contact information is here Feel free to get in touch with me if you have any questions. Basically, everything should be pretty much the same this week as normal. If you need any help, please email the course email help address that is cc310-help or cc315-help. That goes to me It also goes to your instructor and any other TAs that we have anytime we teach these courses. So please continue to use those email addresses if you have any questions. Just like your normal instructor, Emily, I will try and respond within one business day. Hopefully it should be a lot faster. But I usually guarantee a response within one business day. If you get really stuck and you need more help than I can do via email. I can work with you to schedule some time for us to meet with via Zoom. And then of course once Emily gets back, I will collaborate with her to make sure she is filled in on all of the stuff that we have done while she’s been gone. Probably the one thing I won’t do is answer any grading questions on previous stuff. I will leave that for her to answer. The questions on any projects that you’re currently working on. I’d be happy to help you out. So that’s all I’ve got. I just wanted to introduce myself real quick so you know who you’re talking to this week. If you have any questions please email and let me know otherwise I’m rooting for you, best of luck and I will look forward to working with you this week.
Subsections of CC 310 & 315 Cover
Fall '21 Week 1
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week one announcements video for CC 410 in Fall 2021. My name is Russell Feldhausen. And I’ll be your instructor this semester. My contact information is here on the screen, you can also find it on the syllabus, I’m email is by far my preferred communication method. In this course, there is a special course communication email that’s listed on the syllabus. I prefer that you use that when you contact me. But you can also contact me directly if you have any questions outside of the course. If you email me, I will guarantee a response within one working day. You can also reach me on Discord, I have a Calendly link that allows you to set up one on one office hours with me. So there’s lots of ways that we can get in contact.
So this is a relatively new course this is actually the third semester that we’ve taught it. This semester, I’m going through and doing a lot of work to clean up the content in the course. So the assignments are getting updated, we’re working on moving the textbook out of Codio and into a web platform that’s a little bit easier for us to maintain. I may also rework some of the examples. So the big takeaway from this is things may change, I will try and let you know as changes come. And I really, really welcome your feedback. If you have any thoughts on how I can make the course better or more accessible or more interesting, please let me know I’m always looking for ways to improve all of my courses. And where this is a new course, I’m especially looking for any information you have whatsoever.
So this course the big picture, we’re going to do a lot of advanced programming. This is meant to be a course to give you time to practice your programming skills, and really build from being a beginner programmer knowing some data structures to actually being able to build large useful programs. So in this course, we’re going to spend a lot of time learning about object oriented programming concepts, we’re going to work on building graphical user interfaces. And we’ll spend a little bit of time at the end looking at web interfaces as well. We’ll do lots of interactive examples. The examples all come with hour-long explainer videos where I walk through every step of the code and really talk through how I build it. Hopefully, that’s really useful for you. And then throughout the semester, you’ll do a large restaurant project, we’re going to build a point of sale system for a fictional restaurant. And then you’ll also be able to work on an independent final project to demonstrate your skills and do something of interest to you.
In this class, we’re going to explore a lot of new technologies that you haven’t seen before, we’re going to start off learning Git and using GitHub classroom to manage a lot of our code. We’ll use automation tools such as Gradle, and Tox to handle compilation and running a lot of the tests and things that we want to do in our code. For Python users, we’re going to add in type checking. So if you haven’t done any typing before, in Python, this will be really new to you. For Java users, we’ve been doing this already, so you don’t have to learn anything new here. But for Python, this will be kind of new. We’re also going to do some unit testing so that we can actually write tests to make sure our code is working correctly, we’ll learn how to check for style to make sure that our code is formatted and structured in a proper way. And we’ll learn how to write documentation comments in our code. So a lot of new technologies and ideas that we’re going to cover very, very quickly in this class.
In addition, like I said, there will be a final project, you get to choose the topic, I want you to align it with things you’re interested in. If you’re in the ICS program, you might want to align it with your major. Likewise, if you’re doing the CS certificate, you might want to align it with your outside major as well. I really want you to use your new skills in this class to build this project. But you’ll get to work with me interactively to discuss the scope and get some ideas and get some feedback on where to go. There are four milestones that you work on. And then the fifth milestone is presenting it to the class itself.
So right now we’re on week one week one is pretty simple. There’s just a lot of administrative stuff to go through. And then you’ll start working on the first example project, which is called Hello Real World. It’s a rework of the traditional Hello World project, but done in the style of this class using Git and GitHub, using unit tests and style checking, and all of the things that you really need to write professional code. Outside of that you can learn a lot on the syllabus about my office hours about communication platforms. The one thing I’d like to point out if you’ve gotten started in this class already, I forgot to publish the last assignment I added over the weekend, which is to introduce yourself on Discord. This class has a Discord channel that I’d like you to use. So is one of the assignments just to make sure you’re on Discord, I’ll have you introduce yourself on Discord and ask me a question. Since this is an online class case, the Global Campus really likes us to have communication platforms available. So that’s why we’re kind of making sure this is available for everyone as well.
So once you get past week one, week two, we’ll start working on object oriented programming. This will be the first restaurant milestone in my sample project. When I demoed all of this, it was about 2000 to 2500 lines of code in total. A lot of it is boilerplate. So once you get one of the entrees, or pizzas or sides or whatever taken care of, it’s going to be mostly copy pasting and changing it. But be really thoughtful about your naming and your style, because there’s a lot of things you can do in week two, now, based on what you learn in the Hello real world project to make week three, and week four, a lot simpler.
Week Three, we’re going to go through that unit testing and documentation to your code. This one is probably one of the largest milestones we’ll do in the class, I think I added about 3500 to 4000 lines of code. My last semester, it was about 423 unit tests, I think this semester, you’ll be somewhere in the range of four to 500. But a lot of them are very, very similar code. But this is a great way to catch errors. In my model solution, I found about a half dozen errors just by going through and doing all this unit testing. So it’s a very useful technique.
Then we’re getting to week four, and five, where we will go through and refactor a lot of the code in our object oriented libraries to use inheritance and polymorphism. This one is not as much lines of code, it’s about 1000 lines of code. But it’s a lot of changing, refactoring, simplifying structure. So there’s a lot of code changes, but not a lot of new code added. And then you’ll also be working on the milestones. I forgot to change the dates in here, but there’ll be about toward the end of September. And then beyond that, we’ll start working on graphical user interfaces, external libraries, web library, serialization, libraries, all sorts of stuff like that.
So my big advice for this class, this is a four credit hour course, which means I expect eight or more hours of work each week. I think, for most students that have completed this class, it runs around 12 to 15 hours a week, which is about what you’d expect from a four credit hour course. So I really encourage you to schedule your time very wisely. Start early on these assignments, watch the example videos, work through them and leave time for questions. The one thing it’s really hard to do is work on these projects over a weekend. And then they’re immediately due early that next week. And you may not have a whole lot of time to get questions and feedback before it’s actually due. So start early, leave plenty of time for questions. There is a lot of boilerplate code in here. So as you copy paste code, make sure you do so carefully. Really bad copy paste can mean a lot more work for you, then being careful about what you copy paste and editing it very carefully, a little bit at a time. And then of course, in this class, we’re using Git, so use Git to your advantage - commit to Git frequently. The nice thing about Git is if you commit, and then you do something and it screws things up, it’s very easy to roll back to that previous commit and undo what you did. And then start again. So commit frequently commit early and often. And then of course, in this class, we’re going to be doing a lot of large code. So if you have any online resources that you use to learn particular things, make sure you cite them in your documentation. There are some times where you’ll be pulling code from external libraries or templates or documentation. And I want you to make sure you go through and cite that so that we know where you’re doing that. This is especially important for your final project, but it might also come up on the restaurant project as well.
Beyond that, feel free to keep in touch with me. We’ll have good discussion on Discord throughout the semester. I also host tee time office hours, myself and several faculty. So we’ll be online Tuesdays at 330 and Fridays at 1030. So you can always get a hold of us there. And then I have one on one office hours that you can schedule anytime via Calendly. So make sure you do that if you have any questions. Other than that, good luck this semester. And good luck on this course. I’m looking forward to working with you and hopefully we see each other again soon.
Subsections of Fall '21 Week 1
Fall '21 Week 2
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week two announcements video for CC 410 in Fall 2021, so this week today should be wrapping up module one and the Hello real world project. Those are both due today, make sure the Hello real world project that you get your submission posted on GitHub, and then send me the link for the release tag that you make in GitHub. It’s all explained in that project. So that should be pretty easy to do. Also, this week, I’d like to meet with each of you regarding your final project. So just jump online on my calendly link and schedule a time with me sometime this week. I will warn you that I’m out of the office on Thursday, I’m out doing some stuff around town in Kansas City that day. So I’m not available on Thursday. But I do still have a lot of openings on Friday, so I can meet with you then. I’ve also got times today, Tuesday and Wednesday afternoon.
So this week, you’re going to be starting into module two, which is the object oriented programming module. Here, we’re going to actually start building our long term restaurant project throughout the semester. And we’re going to start by building a lot of objects that make up the items of the menu in that project. So hopefully, this is a really good introduction to object oriented programming, especially if you’ve been doing work in Python, we’re really going to dig deeply into object orientation. It’s also a lot of stuff that’s useful for Java developers.
Some other updates. Don’t forget, we have a discord channel for this class. So you’re more than welcome to chat with me there. You can also send me emails to the cc410-help email address, and I’d be happy to answer those there. As you’re getting your projects graded, you’ll notice for the Hello real world project when I graded over the next couple of days, that there will be some comments left in the rubric on Canvas. But then I’ll also leave a bunch of code comments on GitHub in the feedback pull requests. So I believe when I leave those comments, you’ll get an email to your GitHub account. But if you go to the pull requests and look for the feedback pull request, you should see a whole thread of me going through and leaving code comments on your code. That’s one of the big things I will do throughout the semester. Otherwise, it seems like everything is going really well. I haven’t heard a lot from any of you. So hopefully that means so far, so good. But as always, if you have any questions, let me know.
And then don’t forget this week, you’re going to start working on the first milestone for this class. Each of these project milestones can be kind of lengthy. I’ve seen in previous semesters, students spend anywhere from three to eight hours or more on each of these milestones. So make sure that you’re allocating enough time for them. This first milestone is a lot of boilerplate code, setting up your packages, your classes, methods, attributes, things like that. You can also make things on you easier later by doing some style and documentation. Now, although we’ll spend more time in the next few chapters, talking about specifically how to do good documentation and style, but you can do some things right now to make it easier. In my model solution for last semesters project that was very similar to this one, it was around 1500 to 2500 lines of code depending on how you write your code. So it is a pretty large project. This already is bigger than most of the projects you’ve done up to this point in this program. So make sure you leave yourself enough time to work on this project. And as always, if you have any feedback about this project, or the instructions that you follow to build this project, please let me know it’s a brand new class, I’m always looking for ways to improve it.
But other than that, looking ahead, we’ve got the next few modules already lined out. Module three, we’ll be talking about documentation and unit testing. module four, we’ll talk all about inheritance and how we can refactor our existing code to take better advantage of object oriented programming paradigm. And then module five, we’ll talk about debugging and logging and some other topics. And then module five, you also do the final project second meeting, and that takes us through the end of September and into early October. So that’s where we’re at in this class. As always, if you have any questions, let me know. Otherwise, I wish you good luck this week and I look forward to meeting with you all about your final projects.
Subsections of Fall '21 Week 2
Fall '21 Week 3
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week three announcements video for CC 410 in Fall 2021, so you should be wrapping up at this point, the second module. So we have object oriented programming and the example. And then you also should be submitting the first milestone for the restaurant project. So hopefully that went well, it was a lot of building classes and objects in your code. I’ll be going through over the next day or so and doing a deep dive into all of your code, giving you some feedback on GitHub, as well as feedback in Canvas on ways that you can improve the code and get better. Also, please refer to the syllabus it does talk a little bit about the grading in this class. The big thing is once I grade it and give you feedback, you won’t be able to resubmit it for more points on that project. But you should try and improve any of those things that I point out for your next milestones. Although generally, I don’t hold you under double jeopardy, where if I take off in one milestone, I won’t take off again in a future milestone for the same problem unless it impacts what you’re doing in that milestone as well. So kind of keep that in mind. But hopefully, you should be able to take this feedback and use it to improve your code, your style and your structure as you go forward.
So this week, we’re working on Module Three, talking all about documentation, testing, and UML diagrams. We’ll have an example around documentation and unit testing. And then the second restaurant milestone is all about adding unit tests to your project. So for updates in this class, don’t forget, you can join our discord channel, there’s a great chance to have discussions there. Hopefully you’re on that channel. But if not, feel free to join. Also on grading, don’t forget that I’ll leave both comments on Canvas with the rubric. But also leave comments in GitHub. And if you have trouble finding the GitHub comments there in the feedback pull request. So in your GitHub repo, you click the pull requests at the top, and then go to the feedback pull request, and it will tell you all about my code comments. Otherwise, hopefully, things are going well. If you have any questions on finding any of these comments, please let me know.
For the second milestone, you’re going to be working on unit tests. Last semester, in the previous milestone, it was around 423 unit tests, I think this one’s going to be similar. So you should be in the range of about 400 to 500 unit tests in total. You’ll also be adding documentation comments to your code. So you can generate the documentation using javadoc or pdoc. You’ll also create a UML class diagram for your project. So a lot of this is not necessarily changing the code, but adding tests and documentation to the code. This one can take anywhere from three to eight hours to complete or maybe even longer, depending on your comfort level. And it’s rather large. When I did this last semester for the project, it was around 3500 to 4000 lines of new code, a lot of that is going to be either in unit tests or documentation comments that can be copy pasted, so it seems like a lot, but if you work your way through it, it makes a lot of sense. As with the previous milestone, I highly recommend going through and doing one of the large restaurant items first. For example, I think the He Man is the pizza that has almost everything on it. So do that one first, get the unit tests for it working. And then you should be able to use a lot of those unit tests to fill out the rest of the pizzas, and so on. Also, please feel free to give me any feedback on these milestones. I try and make the milestone assignments pretty clear what I’m trying to get to without giving you a lot of hints of how to get there. So if anything is unclear, please feel free to send me feedback. I’m always working on ways that I can improve these milestones to make them easier for you to work with and understand.
Some other hints for milestone two, the biggest hint that I will give you is do not look at the source code for your original classes when you’re writing unit tests. I know that that may sound a little counterproductive on the surface. But here’s what I mean. For example, if a pizza is supposed to be $10.95, don’t get that number from your source code, go back to the original menu in milestone one and get the number there and write your unit test using that number. Likewise, if a pizza is supposed to have certain ingredients and toppings, make sure you get that list from the original assignment not from your source code. Otherwise, you’re simply testing that your source code says what it says instead of saying what it should say, I think I’m a pretty decent programmer. But I had over a half dozen errors in my source code for this project the first time I did this. So it’s really worth your effort now to make sure your unit tests are checking and fixing a lot of those errors. Another thing you can do is use global attributes in your code and generalize some of your projects. So I’ll take a look at that. And also, don’t be afraid to generalize some of your unit tests you should be able to parameterize your unit tests across the crusts and sizes. But you won’t be able to do the individual ingredient toppings on the pizza itself. You can do the vegetable toppings, but not some of the meat toppings. So you can look at the enum parameterized tests as ways that you can do that.
When I talk about generalized tests, here’s a quick, kind of a piece of the solution from last semester. For example, if you want to test the price and the calories in a particular item, instead of hard coding those into the test itself, you could create some private variables at the top of your test class and fill in that data there. And so that way, you can actually just copy paste the test methods and change little bits like you can do a global Find and Replace for the Riker to be whatever class. But then when you duplicate this class, all you have to do is change the variables at the top to match the actual price and calories. This can make it a little bit easier to copy paste code between all the different classes. Hopefully, this makes sense if it doesn’t start working on your unit tests, and then come back to this. And I think it will start to make a lot more sense what I’m talking about here.
So looking ahead from this point, the next few modules will talk about inheritance and object oriented programming, which is really big topic. We’ll spend some time in module five talking about debugging. And we’ll also do a quick final project update. Module six, we’ll switch over to do graphical user interfaces, and we’ll talk about Event Driven Programming and etc. And we’ll kind of go from there.
So that’s all we’ve got for this module. It’s a lot of testing your code. Hopefully this is really useful. One of the things I hear a lot from people in industry that have come out of our department is they wish they would have learned more unit testing. And so that’s one of the big reasons we’re focusing a lot on unit testing now in this class and its companion CIS 400 is because it is something really important that you’ll see out in industry. So I wish you the best of luck on this mod– on this milestone. If you have any questions, let me know and otherwise, I will see you next week.
Subsections of Fall '21 Week 3
Fall '21 Week 4
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week 4 announcements for CC 410 in Fall 2021. So this week, you should be wrapping up the second restaurant milestone, which is all about documentation, unit testing and using UML diagrams to show us the structure of your program. Hopefully, that’s all going well, it’s all due tonight. So make sure you get that submitted online. As always, I’ll try and go through and grade it sometime tomorrow and give you really good feedback on canvas and GitHub. And hopefully you can use that to work towards your next restaurant milestone.
So this week, we’re going to be discussing inheritance and polymorphism. It’s one of the most important topics in object oriented programming. And we’re going to look at how we can use use inheritance to improve the structure of our programs by taking advantage of shared attributes and methods between classes that are related. Also, this week, I’d like you to fill out a quick survey called a start, stop continue survey. It’s completely anonymous, it doesn’t track anything about you. It’s in Qualtrics. Basically just asks you if there’s something you’d like me to start doing as your instructor, something you’d like me to consider stopping doing, or something that you see that I do that you’d like me to make sure I continue to do, I try and use this as kind of an informal tea Val at about a third of the way through the semester just to see if there’s anything I should change or do differently in my projects. And this week, you also get some time to start thinking about and working on your final project. And also the next restaurant milestone, which is actually due not next Monday, but the Monday after that.
So the following week, you’ll be working on debugging and logging, and lambda expressions, and all of those different things. And that’s when your third restaurant milestone will be due on September the 27th. So you’ve got two weeks to work on the upcoming milestone, where we’re going to do a lot of refactoring of your code. Also, that week, I’d like you to schedule your final project presentation. The second final project meeting with me. So it’s really important that you take some time over these next couple of weeks to think not only about your restaurant project, but your final project. So for the third restaurant milestone, this is where we will enforce all of the general requirements. So your code needs to have documentation it needs to have unit testing, it needs to have passed the style checker. For Python developers, it also needs to pass all of the type checking as well. So make sure you get that all in there. You’re going to be adding inheritance to your classes, we’re going to add a couple of new classes and refactor a lot of our existing classes to take advantage of those inheritance… relationships, you’ll also add some new unit tests, you’ll update your diagram. The nice thing is this is really only about a 1500 new lines of code. But there’s a lot of code that’s going to be changed and updated. And so this one is much more thinking about the structure of your program than actually writing tons of code. And then of course, as always, the feedback is always welcome on these restaurant milestones. If you have any questions or anything that’s unclear in the restaurant design itself.
So some hints for this milestone, big thing is to work in small chunks, try not to make all of the changes at once. But make a small change, like change one class, get all of the classes that should inherit that class changed, and then see if that works. You’re using Git, so make sure you keep that in mind. You can commit early, you can commit often. And if you make a mistake, you can always roll back to an earlier commit. There’s some really good guides online for how to do that. This time, you could also try test driven development. Now that you know how to use unit tests, you can write some unit tests of things that your code should do, and then refactor your code and see if you can pass those unit tests. The other big hint I give is, in this milestone, we’ll create an order item class. I really encourage you to inherit that on your base classes, not the individual entree and side and drink item classes. It’ll make sense when you get into it. But I really encourage you to do it that way. And then don’t be afraid to ask questions on syntax, especially when we start working on inheritance and polymorphism. There are some strange syntax that you might run into.
In the next module you’ll also learn about lambda expressions which have some strange syntax, so don’t be afraid to ask questions if you’re unsure. Looking ahead from here, module four, we’ll start we’re talking about inheritance this time. The next module Next week, we’ll talk about debugging lambda expressions. And you’ll also have a final project milestone due. Then we’ll get into the graphical user interfaces, we’ll spend a couple of modules talking about GUIs and Event Driven Programming, and how we can build a graphical user interface for our program. And then towards the end of the end of the semester, we’ll talk a little bit about web and web API’s and how we can build a web interface for our program as well.
One quick announcement I want to give you that’s important to this class. I will be going on vacation the first week of October so I leave on Friday, October the first and I’ll get back Saturday October the ninth. During that time, I may have some times where I have limited email and discord access, especially during the day as we’re traveling. So because of that if you have questions, please use the cc410-help email address that goes to me and it can also be forwarded to any of our other faculty that might be helping me out especially while I’m out on the road. I will be watching email and discord, I will try and respond, it will probably be very late in the evenings most days when I get to respond to you, but I will do my best to keep up. And so because I’m going to be out of the office, your responses may be delayed a little bit, I may not reach my 24 hour, or my one business day response time. And because of that, if there are a lot of questions on these projects, I may shift some due dates around to give you enough time and give me enough time to make sure that we’ve got everything covered. I don’t think this will be a big problem. That’s the week we’re introducing GUIs. And that project is generally pretty easy to follow based on the example project I give you. So I’m not anticipating a bunch of questions that week, but we’ll see how things go.
So other than that, hopefully your code is not on fire at this point. And hopefully it doesn’t get any worse as you’re trying to do all this refactoring with inheritance and polymorphism. But as always, good luck on this restaurant milestone. If you have any questions, let me know and otherwise you’ll hear from me again next week.
Subsections of Fall '21 Week 4
Fall '21 Week 5
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week five video for CC 410 in Fall 2021. So this week, you should be wrapping up the third module, which is all on inheritance and polymorphism. And starting to work on refactoring your code to take advantage of some of that. So right now, the chapter on inheritance and polymorphism is due. And the example is due. The next milestone, which is milestone three is not due until next week, so you’ve got an extra week to work on that. But things I’d like you to work on is, make sure you fill out the start, stop, continue survey, and also start thinking about your final project a little bit, it might be still too early to start working on the code. But hopefully, you can start thinking about ideas and looking at the class structure we built for the restaurant project, and thinking about how that class structure might adapt to whatever final project you’re interested in doing.
This week, you should be working on debugging and logging, which is a really important concept. We’re also going to talk a little bit about lambda expressions, which are really important for some of the unit testing that you’ll need to be doing. So for next week, you’ll be working on a debugging logging example. And you’ll be working on the third restaurant milestone which is refactoring your code to take advantage of inheritance and polymorphism. Also, on October 1, you’ll have the second final project meeting that should be scheduled. However, in just a second, I’m going to talk about some scheduling that might impact exactly when you want to get that done.
So for milestone three, this is the first milestone that we require all the general requirements. So make sure you have your code unit tested, have your documentation. And this time we’ll be enforcing the style guide. So make sure that your code passes the style checker completely. There shouldn’t be any issues in your code. As far as the style checker is concerned. You’ll be adding some new unit tests, you’ll be updating your UML diagram. Thankfully, since this is mostly refactoring, you should only be working on about a 1500 lines of code, it’ll be a little bit smaller than your previous milestones. But it will be a lot more in depth the work that you’re actually doing to update this milestone.
So some big hints for this milestone, just like every other milestone, try and work in small chunks, get a short little bit working; commit early commit often. Remember that you can use GitHub to roll back. This is also the first milestone where you could try test driven development. As you’re working on code, you could try writing your unit tests first, and then building the code so that it will actually beat those unit tests that will actually fulfill them. I also have a hint that it’s not in the assignment. But it’s a big hint that you can actually inherit the order item interface on your base classes. So pizza drink and side, instead of inheriting it directly in all of the subclasses of that. It’s a little bit different infrastructure, but I think it actually works better. And also this, this particular milestone your work on some new and improved syntax. So if you have any questions on syntax, especially in Python, but maybe also in Java, feel free to let me know and ask those questions. And I’d be happy to answer ways to do that. This especially comes in with a style checker. Sometimes making the style checker in Python happy requires some weird syntax to wrap your lines. So make sure you keep that in mind.
An update on the schedule. I will be on vacation from October 1 to October the 10th. So that is a week from Friday through the following weekend. During that time, I’ll be on the road a lot. So I will have limited access to email and Discord. I will try and check in about once a day and answer what I can. But I may not be as quick at answering. Because of that the grading for milestone four might be delayed. Milestone four is still due the Monday that I’m gone. But it might take me a little bit time to get to that. Thankfully, it’s mostly just getting your GUI up and running. So there’s not a whole lot of code there. It’s mostly just building your GUI, so you kind of know if it works or doesn’t. Based on previous semesters, with that milestone, I expect minimal questions. But if there’s a lot of questions or a lot of confusion, I may adjust the due dates on either milestone four or five, if needed, just to give me enough time to answer those questions. So we’ll kind of play it by ear, I’ll do the best I can to stay in contact while I’m on the road. But if things happen, I will do my best to make sure that it’s fair and equitable for everybody involved.
So looking ahead from there, after this milestone, we’ll start switching over to graphical user interfaces. So we’ll spend some modules learning about GUIs, Event Driven Programming, we’ll spend a lot of time talking about design patterns and how we can use that to implement combos and orders in our system. And then we’ll start talking about external libraries and then get into things like web API’s.
So hopefully, this is a really good week. It’s hopefully the last warm week of the summer. So if you’re starting to feel the heat, I’m hoping that by the end of today, it’ll start getting a little cooler outside it’ll start feeling more like fall. As always, if you have any questions on your work as you work on these milestones, feel free to let me know I’m always available. You can catch me on discord by email or at tea time or you can schedule one on one office hours with me using calendly. Otherwise, I look forward to seeing your code and good luck this week.
Subsections of Fall '21 Week 5
Update to Example 5 Python
It appears that I missed an interesting error when developing Example 5 for Python. It is a bit complex, so I’m relying on the advanced formatting of this webpage to help explain it better than I can via email or in a short post to the class. I’ll start with a short version, and then include a longer discussion of the problem and how I came to a solution that I feel is very helpful reading for anyone learning to program and solve these issues in their own work.
tl;dr - The Short Version
Currently pytest has a bug that causes errors when logging to sys.stderr
when running code inside of pytest
.
As best I can tell, pytest
tries to capture all output being printed to sys.stderr
by redirecting it to a buffer (a virtual file) when running the tests. Once it is done, it will close the buffer and redirect output back to sys.stderr
. Unfortunately, our logger does not realize this, and it may continue to try and write data to the buffer that is now closed, resulting in the ValueError: I/O operation on closed file
error message seen in the output.
There are several methods to determine if code is running under pytest
and disable logging in that case.
I recommend this method:
import sys
# get the root logger
logger = logging.getLogger()
# disable if pytest is running
if "pytest" in sys.modules:
logger.disabled = True
You will need to add this code to any file that you add logging to, in order to prevent errors from pytest
. Alternatively, you can disable the handler that prints to sys.stderr
and instead just use a file handler.
The Long Version
Since this is an advanced programming course, I figure that it is worth a bit of a “deep dive” into this situation so you can understand what I found, the efforts I went through to solve it, and how things are really working behind the scenes.
This is a bit of cognitive apprenticeship, where I attempt to show you my thought processes and how I go about solving a problem like this. My hope is that you’ll be able to learn from this process and possibly use this knowledge to help you solve your own problems in the future.
Unfortunately, in the world of higher education, we spend way too much time focusing on narrowly-scoped, previously-solved problems, to allow you to learn in an environment where we know a solution is possible in a set amount of time. In the real world, however, you’ll be constantly presented with broadly-scoped, open-ended problems like this one, where you’ll have to do some exploration to find possible causes and solutions, and then use your own background and knowledge to determine what solutions, if any, are available.
So, here goes.
The Error
When you run pytest
in Example 5 after adding some logging code as directed in the video, you will see many pages of errors printed to the terminal. In my testing, the terminal in Codio printed errors for several minutes before finally stopping. A screenshot of a small portion of those errors is below.
When this happens, you may be able to use CTRL + C to stop the output, but in many cases I simply had to close the terminal tab in Codio.
What Happened
When I developed this example, I focused on the debugging portion first, and then later added the logging code. However, I neglected to run pytest
after adding the logging code to my model solution, and did not encounter this error in my initial testing. That was an oversight on my part.
As you work on this project, you may end up adding the logging code first while still working on debugging the errors in the project. In that case, you will most likely run tox
or pytest
to run the unit tests contained in the project with the logging code in place. That will cause the error to appear. As soon as I ran tox
in my existing model solution, my code presented this error.
How I solved the problem
The process of finding a solution for this problem went in three phases.
Phase 1 - Searching
First, I attempted to Google some of the error message and a few things that I suspected were at play. I already had a hunch that the error itself was coming from the logging code, since I had added that to my model solution last. After reproducing the bug in my solution, I set out to solve it. Some Google search phrases I used:
pytest logging stderr write to closed file
- Including keywordspytest
andlogging
as well as thestderr
stream and a bit of the error message.pytest stream.write(msg) I/O operation on closed file
- adding more details such as the line of code causing the error and the exact error messages."pytest" stream.write(msg) I/O operation on closed file
- putting"pytest"
in quotes will find results that always include that keyword
There were others, but this was the most fruitful.
Phase 2 - Isolate the Error
In several of those searches, I came across a few bug reports on GitHub, specifically within the pytest
project’s repository. Bug reports and discussions on GitHub are usually very fruitful when looking for technical errors that include code and error messages, so I looked into a few of them.
- ValueError: I/O Operation on closed file (#14) - this was the first one I found. However, I quickly ruled it out, as it was first posted in 2010 and mainly seemed to use Python 2 instead of Python 3. After scrolling through the discussion, nothing really seemed to fit the situation I was in, so I ignored it and moved on. However, it did reference the next issue…
- Improve error message when tests use closed stdout/stderr (capture) (#5743) - this one felt like it was a bit closer. In this report, they discuss the fact that pytest will redirect and close system streams such as
sys.stderr
as part of the test. It was also much more recent, and some of the error messages they were running into were similar to what I was seeing. - pytest 4.5 floods the output with logging errors when logging from atexit handlers (#5282) - similar to the one above, this one was getting closer to the issue I was seeing, though it wasn’t an exact match. By reading these three thread, I was starting to get a feel for the crux of the error - if our logger is trying to write to any of the output streams, like
sys.stderr
orsys.stdout
, then most likelypytest
would interfere with that and cause this error. Thankfully, the last two issues both referenced this issue… - pytest capture logging error still happening (#5502) - this report had a lot of discussion on it, but pretty much sealed the deal for me. One of the core
pytest
developers posted a message that included this text:
What I believe is happening is:
- pytest changes
sys.stdout
andsys.stderr
to a buffer while importing test modules.- If there’s user code setting up logging and/or creating a
logging.StreamHandler
at the import level, it will attach itself to pytest’s buffer.- When pytest is about to finish the test session, it will restore
sys.stdout
andsys.stderr
to the original values, and close the “capture” buffer.- Here the problem happens: if any message is emitted at this point, the
StreamHandler
will try to attach itself to the buffer, hence the error.
So, we’ve now found what we suspect is the error. All we have to do is figure out how to resolve it.
Phase 3 - The Fix
Unfortunately, issue #5502 is still open as of this writing, so we needed a way to get around this error. With some quick testing, I was able to confirm the error went away if I removed the StreamHandler
from the existing logging code. So, I decided that the best way to deal with this was to find some way to disable logging while the code is running as part of a unit test. This is a somewhat common, though discouraged, trick in programming. Ideally you don’t want to hide any code from the unit tests, but in some instances you want to make sure that the unit tests don’t actually change live data, such as the actual database used by this program. So, you can “protect” the code that connects to the database and make sure it cannot run as part of a unit test.
A quick Google search for determine if code is running under pytest python
quickly lead me to a StackOverflow post discussing this very issue. Great! I had quickly found a pretty good resource that might lead me to a solution.
Within the discussion, there are a few solutions suggested, and helpfully ranked by the upvotes from other users.
- Solution 1 - simply check
if "pytest" in sys.modules:
since thepytest
application will always be loaded when running a test. This solution seemed pretty simple and didn’t have many obvious side effects, provided your application didn’t loadpytest
as part of its normal execution. - Solution 2 - a solution that points to a section of the pytest Manual that shows the preferred way of doing this. In short, we place some code in the
conftest.py
file, which is only executed as part of a unit test, to update a value in our code, and then check that value where needed. This looks promising, and is probably the correct answer that would work in all cases, but also requires significantly more code and adds a structural dependency between our code and theconftest.py
file. - Solution 3 - a third solution suggests checking for the existence of the
PYTEST_CURRENT_TEST
environment variable, which is set when pytest is running. This may also work, but has the side effect of being outside of our control - any other application on our system could also set that variable, including another instance ofpytest
, so it may not work as reliably as the other two.
In the end, I chose Solution 1, and updated the code at the top of my main()
method in TicTacToe.py
to the following:
import sys
# get the root logger
logger = logging.getLogger()
# disable if pytest is running
if "pytest" in sys.modules:
logger.disabled = True
That code will simply load the logger, and immediately check if the "pytest"
module is loaded. If so, it will disable the logger globally in my program.
An alternative solution would be to just disable the StreamHandler
and allow the FileHandler
to remain enabled, but I felt that logging from unit tests is not helpful and chose to disable it entirely.
Summary
I hope this discussion is helpful - I’ve found that sometimes the best opportunities for cognitive apprenticeship happen directly as a result of the class, so I wanted to take this chance and share a bit of my own problem solving process here.
If you have any follow up questions about this, please let me know!
Fall '21 Week 6
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week six announcements video for cc 410 in Fall 2021. So this week you should be wrapping up the last part of the first chunk of the class, which is all about debugging and logging, lambda expressions. And you’re working on the third restaurant milestone which covers inheritance and polymorphism. So all of that is due later today. I’ll get that graded here in the next couple of days. Typically, restaurant milestone three is one of the ones where I try and spend a lot of time reading through your code considering the structure of your code and how you implemented the inheritance and polymorphism parts. And I try and give you a good code feedback on style. It’s also the first milestone where we enforce all of the basic requirements we introduced in hello world. So things like your style checker is going to be something that will really look into as well, as well as make sure you’re… making sure your unit tests achieve 100% code coverage and things like that. Also, this week, you should be scheduling your second final project meeting, please make sure you try and get that in before Thursday if you can, because I go on the road on Friday. This is just a quick chance for us to chat about the final project, maybe talk about some possible project topics you’ve been considering. You don’t really need to have much else done for your final project at this point. But hopefully you’re thinking of final project topics that you might want to take on and thinking about some of the classes and the structure of those classes that you might need to build that project.
So this week is pretty simple. We’re just shifting gears talking about graphical user interfaces, or GUIs. This week, and then you’ll be working on the fourth restaurant milestone, which is all about building a basic user interface for our programs. So the fourth milestone, it’s all about GUI basics, I basically what you’re going to do is create the overall structure of your GUI, all the different panels and frames that you need to manage a graphical user interface for this program, we don’t worry much about functionality other than the buttons you need to switch between the frames so that you can see them all. I’ll give you one example of how to build this in the example project. And then you can either adapt that example for this or you can kind of go your own way a little bit. This is a chance for you to get really creative on these projects. There’s lots of different ways you can build these GUIs. As long as they meet the minimum requirements, you’re good to go. Don’t forget to read the helpful hints in the assignment I try and give some hints of different coding patterns that I have found are really important and useful for me when building a graphical user interface. So hopefully some of that information is useful to you as well.
Looking ahead after that, the next module will do Event Driven Programming, where we talk about how we can actually make a GUI functional using events. Module eight, we’ll spend some time on design patterns and use that to build combos and orders for our program. If there’s one big takeaway from this part of the class, besides learning how to build GUIs, it is the use of design patterns. That’s something that you use an awful lot in industrial programming today. So that’s something that’s really important that we’ll focus on. And then after that, we’ll talk about libraries, releases, web API’s, etc.
So quick reminder, I go on vacation this Friday, October the first and I’ll be gone through the next week I get back on Sunday, October the 10th. During that time, I’ll have limited access to email and discord while I’m on the road, I’ll still be reading emails, paying attention to discord, but my responses may be a little slow and they may not be as verbose as they normally would be. Because of that, even though milestone four is due next Monday. grading of that milestone will be delayed for a week until I get back. I don’t expect any issues with that, that milestone is mainly just whether you built the frames and the panels and everything for your GUI. That’s really all we look at for that one. So you kind of know if you got it working or not. Based on previous semesters, I expect minimal questions on these next couple of milestones, they’re pretty straightforward to follow. But if there are tons of questions, or there’s things that I can’t handle easily remotely, I’m more than willing to adjust due dates if needed, and push things back a little bit just to give me some more time. I’m also going to work with another faculty member here at K-State so that they will officially be covering these courses and can provide a little backup to me as well. But most of the time, I’ll still be the one actually fielding questions and things like that even while I’m on the road. So feel free to ask questions, but be a little flexible and we’ll adjust due dates as needed.
Other than that, I think we’re really strumming along good this semester. Everything looks really good. I look forward to seeing your restaurant milestones and chatting with you about your final projects. And then hopefully these next couple of milestones building out a graphical user interface go well, but as always, feel free to let me know if you have any questions and I look forward to seeing you over the next couple weeks.
Subsections of Fall '21 Week 6
Fall '21 Week 9
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week nine announcements video for CC 410 in Fall 2021. So we’re on week nine, I apologize for missing the last couple of weeks. I was on vacation two weeks ago. And then last week, I was busy getting caught up with everything, but we’re back on track and you should see announcements videos for most of the rest of the semester.
So we’ve taken a couple of milestones and split them over two weeks. So this week, you should be finishing up the sixth milestone on the restaurant project. This one is all about design patterns and using mock objects in your unit tests. You should also have your third final project milestone meeting with me sometime this week or next week. This is the point in the semester where you should start working on your final project. So make sure you get that started soon. We’re about halfway through that. Well, we’re over halfway through the semester at this point. So for your final project, if you haven’t already, load up that Codio project, get the base project built in there just like we did for the hello real world project. And then you can start working on code for your final project and get going there.
So next week, we’ve got another split milestone over the following week. So next week, we’ll introduce external libraries, and you’ll start learning how to use those. And then the following week after that, we’ll talk about releases. And you’ll be working on the seventh milestone, which is the checkout milestone. Checkout is one of the other trickier milestones in this semester. So I gave two weeks for that one, make sure you use your time very wisely. And then after that milestone will start doing some stuff with web interfaces. And you’ll have a lot more time to work on your final project as we get further into November.
So the milestone you’re working on today, milestone six is all about orders and combos, we’ve added those new classes to our code. And then we’re using some design patterns such as the factory method, builder pattern, singleton pattern and the iterator pattern. To use those design patterns to make orders and combos work really well in your system. We’re also writing unit tests with test doubles or mock objects in there. So that’ll be something really cool that you haven’t used. But there shouldn’t be very many GUI changes this week, the only real GUI changes are to handle the combos themselves. And it should be pretty minimal compared to what you’ve done in the past. But hopefully you start to see the use of design patterns in your code and how it’s really useful to reuse these common structures so that other people can understand your code quickly and easily.
The other thing we’ve run into with this milestone is the testing issues. Running tests, especially with these large objects and large GUI things really can take a lot of time. And Codio boxes have limited memory, I believe Codio right now limits them to 512 megabytes. And because of that every once in a while the tests will crash in Codio. There are a couple of ways to fix this. In Java. If your tests crash and you need to stop a running Gradle project you can do “gradle –stop” on the terminal that will stop any running Gradle instances, then in Codio you go to the project menu and choose restart box that will restart the code your box your code is running on. And then once that’s done, you refresh your browser page. And then you should be able to run the tests again, that should work. So if you ever have trouble with Gradle hanging on any of your tests, that’s the way to fix it. In Python, we’re simply going to run the tests in batches. And so in the code, I give you some examples of how you can change your tox configuration to run those tests in batches You may have to tweak it just a little bit to make sure that it fits with your unique setup. But that should work for that.
So looking ahead after the next few weeks, we’re going to switch to doing some stuff with web interfaces. those milestones are meant to be a little bit smaller, a little bit more straightforward. And that will give you some more project time to work on the project over the last four weeks of the class. So keep that in mind. We’re almost over the difficult part of the class and into some of the easier stuff toward the end.
So as you can tell week nine we’re finally over the halfway mark on the semester. So you’ve only got about seven weeks worth of content left. So make sure you keep plugging away at it that you’re doing well if you have any questions, let me know and otherwise I will see you next week.
Subsections of Fall '21 Week 9
Fall '21 Week 10
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week 10 Announcements video for CC 410 in Fall 2021. So this week you’re working on milestone seven, which is the checkout milestone, you’ll have two weeks to work on that. This week, you’re also doing an example on external libraries, which is really interesting. And then next week, you’ll work on actually creating a packaged and installable release of your software.
Milestone seven is actually best split into two parts. And so you can work on both parts kind of independently, I recommend on working them in order just to make everything work. The first part is editing the graphical user interface so that you can edit combos. You’ll need to probably go through and update a lot of other GUI panels. But hopefully, a lot of this should be just wiring stuff together copy pasting code to build the combo GUI and getting some of the dropdowns figured out. Hopefully, it’s pretty simple, especially with some of the examples I show. But if you need any help with that, let me know this is one of the trickier parts.
The second part is to use the external library I give you to build a checkout system. So there’s a library that mimics a cash register that you can either do a cash exchange or do a credit card. The credit card is very simple actually show you how to do that in the examples. So that should be pretty easy to build. The cash part is a little tricky, there’s a lot of different ways you could build the cash user interface. And then of course, you have to handle how to make change. And make sure you read this very carefully, the library should only be instantiated once. And so making change, you’ll have to make sure that if you run out of a particular coin, you can borrow them from the next highest, you can take $1 and get four quarters, for example. And so as long as the amount in the change drawer stays the same, you can make change however you need. And then finally, you’ll print out a receipt. And so there’s a little library that you’ll have to read. The library has good documentation, the code is open source, so you can read the code as well. So take a look at that library, see if you can understand how I built it and how it works. And then use it within your program yourself.
So beyond that, after this, this milestone we’ll start working on the web. So maybe not in five minutes, but in a couple of weeks will switch over to do web frameworks. Also, bear in mind that we’re getting toward the end of the semester, you got a little over a month and a half to work on your final projects. So now’s the time to start thinking about getting code written for your final project. After this milestone the restaurant milestones will be a lot smaller for the last four. So that shouldn’t be so bad. But make sure you keep in mind you got to start working on your final project soon so you have enough time to get it working. You should also have a final project meeting with be here in the next couple of weeks. So as always, if you have any questions, let me know otherwise. Good luck this week and next week on milestone seven and I look forward to hearing from you soon
Subsections of Fall '21 Week 10
Fall '21 Week 12
YouTube VideoResources
Edited Transcript
Hello, and welcome to the week 12 Announcements video for CC 410 in fall 2021. So this week, we’ll be pivoting from working on our graphical user interfaces to starting working on the web. And so the example this week, we’ll introduce you to web frameworks and how you can build data driven websites using the same set of code that we’ve been using throughout this semester. So we’ll do a quick example on that. And then you’ll actually implement a website in your project itself. This first project will just work on setting up the routes following the web MVC kind of RESTful architecture. And then from here on out, we’ll add some features to that. So you can add custom menu items via the web. At this point, we’re also getting down to the last four weeks of the semester. So you should definitely start working on your final project if you haven’t already. And this is really the time to start getting a lot of the code done. We’ve got two weeks to do, we have Thanksgiving, and then we have two weeks. And that’s pretty much it. So keep that in mind that things are going to move pretty quickly from here on out.
So like I said, for this restaurant milestone, you’ll install a web framework into your project, you’ll set up some routes in the controller, you’ll also learn a little bit about templating, and how you can set a master template and some route templates. And really, the goal is to build a website menu that is data driven based on all of the data that we have in our class. A quick little aside on this in an actual practical website, you would probably use a database to store all the data about your menu instead of classes and objects like we’re using so far. However, databases are really outside of the scope of what I’m going to cover in this class. So we’ll learn how to do it using the existing objects and everything that we have. But understand that in actuality, you would probably use a database for this in the real world. And so those of you that are in the ICS program, you’ll go on to take our databases course. And you’ll learn how you can actually add a database to this, you can also take our web development course, which actually teaches you how to build data driven websites using a real database. So this is kind of a primer to some of that, but it doesn’t actually get you the full experience.
Looking ahead, we’re going to talk a little bit more about form data and filtering and how we can build web forms to collect data from the users. We’ll also talk a little bit about serialization. The big thing to know is from here on out, the milestones will be much smaller, about half the size of the earlier milestones about a quarter of the size of the last two milestones. And the whole idea is to give you more time to work on your final project for these last few weeks. Also, keep in mind that the last restaurant milestone will be due on December 13. That’s the Monday of finals week, although you’ll have until the Friday of finals week to get everything wrapped up and turned in on this class before the end of the semester. So that’s where we’re at at week 12. Hopefully you’re getting ready to pivot to working with the World Wide Web. As always, if you have any questions let me know and I look forward to hearing from you soon.