Hey y'all!
Week 6 of class has come to the end and it is time for me to write yet another delightful post. I hope all of you had a wonderful Valentine's Day! I for one went to see a light hearted play about zombies at Hart House. It was fantastic, if you were wondering.
This week is all about object oriented programming!!! Woot! (*searches on Google to find an exact definition of said topic*) ...Ok I'm back! So object oriented programming! It's something we've all seen before when we first learned how to make classes, with an added bonus of making subclasses with inheritance.
The premise is quite simple; you want to create a general class for whatever you would like to code, and then when you want to make a specific version of it you'll make a subclass. The subclass should logically be able to have whatever cool features you've made for that class (called inheritance).
Let me give an example: so let's say you would like to create a general class shirts. This general class will create the instance of a shirt, and you would be able to use the methods within it to choose a size and a colour. But then, you'd like to make specific types of shirts that will have special details in them. You want to make a class that does a similar thing for t-shirts, blouses, and tank tops, all with their own special set of details you can add to them, but you don't want to have to copy out all of the information that was stored in the shirt class. Well, the solution is simple! Create subclasses of shirts, and have them inherit the features of the shirts class. All the subclasses that inherit the features of shirts will now have the methods for assigning a size and a colour but without you needed to have the code physically typed into the class. Now any time you want to create a new type of shirt, you can create a subclass of shirts and not have to worry about the basic details and just worry about the important things like if you want frilly sleeves or a bedazzled collar.
This is a pretty big concept and you really need to try it out a few times to get the feel for it. I urge you all to try it out for yourselves!
Have a stupendous week folks!
Lana :)
Week 6 of class has come to the end and it is time for me to write yet another delightful post. I hope all of you had a wonderful Valentine's Day! I for one went to see a light hearted play about zombies at Hart House. It was fantastic, if you were wondering.
This week is all about object oriented programming!!! Woot! (*searches on Google to find an exact definition of said topic*) ...Ok I'm back! So object oriented programming! It's something we've all seen before when we first learned how to make classes, with an added bonus of making subclasses with inheritance.
The premise is quite simple; you want to create a general class for whatever you would like to code, and then when you want to make a specific version of it you'll make a subclass. The subclass should logically be able to have whatever cool features you've made for that class (called inheritance).
Let me give an example: so let's say you would like to create a general class shirts. This general class will create the instance of a shirt, and you would be able to use the methods within it to choose a size and a colour. But then, you'd like to make specific types of shirts that will have special details in them. You want to make a class that does a similar thing for t-shirts, blouses, and tank tops, all with their own special set of details you can add to them, but you don't want to have to copy out all of the information that was stored in the shirt class. Well, the solution is simple! Create subclasses of shirts, and have them inherit the features of the shirts class. All the subclasses that inherit the features of shirts will now have the methods for assigning a size and a colour but without you needed to have the code physically typed into the class. Now any time you want to create a new type of shirt, you can create a subclass of shirts and not have to worry about the basic details and just worry about the important things like if you want frilly sleeves or a bedazzled collar.
This is a pretty big concept and you really need to try it out a few times to get the feel for it. I urge you all to try it out for yourselves!
Have a stupendous week folks!
Lana :)
Comments
Post a Comment