Homeschooling & Learning to Code


Remember back at the start of this journey that I said I would be happy if everyone was still alive and wearing clean pants by the end of the 16 weeks?!  Now homeschooling has been thrown into the mix too!  Thankfully my kids are 10 and 12 AND this is second time around so they pretty much know what they're doing.  It has meant a wee tweak to the 'schedule' here and there, I'm doing batch cooking for the week as much as I can on a Sunday so the time I would usually spend cooking first thing in the morning can be spent checking that they both know what they're working on that day.  And the time making the dinner in the evening can be spent checking that work!  Codeclan have also be great in adapting to the new routines that many of us have.  All classes are now being recorded so we can look back over any bit that we may have missed if we had to dive out and sort out technology failures/urgent questions/look at my picture mum..!  There is also a parents channel on slack now so that we can share tips and resources. So far I can report, at the end of week 1, all is well (the laundry may be piling up though.....)






Inheritance


This week is more theory as we continue to work our way through the SOLID principles and 4 Pillars of OOP. (For those new to my blog (where have you been?!) I have included the charts from last week that show these)  Onto the L in the SOLID principles, which ties in with one of the four pillars - Inheritance. But Inheritance starts with an 'I' I hear you say!  Yes it does!  The L in SOLID actually stands for Liskov's Substitution Principle.  Which is what exactly?!  Well this is the definition from wikipedia:


"Substitutability is a principle in object-oriented programming stating that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any of the desirable properties of the program."

Still as clear as mud?!  In very basic terms inheritance means that you get Parent properties and functionality within a Child class of that Parent (Inheritance) and Liskov's Substitution Principle says you should be able to swap the Parent Object for the Child Object and our code will still work.


Method Overriding


This is a great tool.  We know that Child classes inherit the properties and functionality of the Parent class, but what if we want one of the methods in the Parent class to have slightly different functionality in the Child class?  We use method overriding!  It means that we write the method in the Child class and 'Override' the Parent method to add extra functionality or return something different.


Interfaces


I am really enjoying getting to grips with all the new tools that Java gives us.  One of these is interfaces and they really help make our code flexible.  You can use an interface where there is common behaviour between two completely unrelated classes.  To copy the instructors example, a duck and a human don't really have any common properties but they can both swim and therefore both implement the ISwim interface.  This gives your code the flexibility to group elements together by their shared interface where you may have struggled to group them before.  It also helps us to write dry code.  Interface Segregation is the I in the SOLID principles.


Polymorphism


Polymorphism is one of the 4 Pillars of Object Oriented Programming, so what exactly is it? Polymorphism means that we can use the same variable in different forms at different times in our programme.  For example when we implement an interface on a class (See above!) The class then has it's own behaviours associated with the class as well as the behaviours associated with the interface and we can use them at different times in the programme depending on what function we want it to perform.

Using Polymorphism also helps us to ensure that that we meet the Open/Closed Principle (the O in SOLID).  The Open/closed principle tells us that a class should be open for extension but closed for modification.  This means that our code will be easily scalable as we can add more classes and functionality (open for extension) without having to change any of the existing code (closed for modification).

I read a blog this week that was called "Starting a Software Testing Blog: Why bother?" by Sowmya Ramesh.  It really resonated with me.  Starting this blog 12 weeks ago was a bit of a scary prospect.  It's something that I've never done before and I was worried that no-one would find my 'story' interesting.  The blog that I read highlighted a number of good reasons/benefits of blogging and one of them was sharing your story as you never know what impact it may have on others.  Writing this blog has led to (virtual) connections with people who I would not otherwise have crossed paths with and being able to exchange advice and experiences is always a lovely thing.  The other huge personal benefit for me in writing this blog is that it really helps me to consolidate what I have learned over the week and cement that knowledge by explaining it here (hopefully correctly!). So my advice to anyone contemplating writing a blog - Go For It! I promise you won't regret it.

Comments

Popular posts from this blog