Posts

Showing posts with the label LearntoCodeinSwift4

Unit Testing Your Code

So, once again I've managed to leave a huge gap between these blogs! The good news is that the Summer Holidays are approaching and there will DEFINITELY be time to code then! So, between now and then, I need regular entries so I can learn what is left in 'Learn to Code in Swift 4', then make a new plan for how to take my knowledge forward. Anyway, the next chapter is all about 'Unit Testing', which sounds interesting! The three facets of a successful app are: well designed, stable and easily adaptable to change. Apparently, many app developers do not test their code properly; the most effective approach is to test one line at a time, after writing. That makes sense! So 'Unit Testing' is a method to test individual 'units' - usually methods. Having read over the next few pages, a lot of this seems unnecessary at present; I'm still getting used to writing codes let alone testing and debugging! This is something that I can revisit when I have ha...

Creating Custom Classes

I know that I promised to make my entry much sooner than this but, once again, life got in the way! So here we are, a couple of weeks later than planned. Anyway, it's the first time in months that I'm actually doing this blog alongside some coding. So it's a step in the right direction! Moving forward, after working through this book, I plan to do this book alongside another course or text, so hopefully the 'live' recording of it will be useful and purposeful.  This chapter is all about creating custom classes. Now I know, more or less, what a class is. From what I recall, a class bundles together data e.g. variables, constants, functions...all to then create specific objects or instances. We'll see what this chapter brings...! So the task in this chapter is to create a functioning calculator - able to add, subtract etc. class Calculator {      } This is how to set up the class. The syntax is have a capital letter - different to variables, func...

Creating Objects from Classes

Well, it's been a little while! The last time I blogged about using Swift, I was on my Christmas Break from work. Predictably, the first few weeks of term have been busy so there has been little to no time to open up my mac and do anything coding related. So today is the first time for over a month. Too long! I remember this feeling when trying to write regularly into a diary or journal years ago. There would always be the associated guilt of not updating it often enough. It would've been tempting today to have abandoned the idea of doing anything Swift based and go for the cliched 'I'll do it another time'. But as I've mentioned in previous blogs, I'm determined not to undo and unlearn all the knowledge that I had steadily built up in my sojourn from work recently.  Anyway, onwards and upwards. The next chapter I'm tackling is all about 'Creating Objects from Classes' (Chapter 6 - pages 83 to 94) . As before, I'll do a 'live' blo...

Calling Methods

So, starting from my previous post on 'Optionals',  I'm focusing on one area/challenge of Swift at a time, with my immediate reactions and reflections on them written in this blog. As I've mentioned before, the purpose of this is to help me make sense of what I am learning, not revel in my lack of knowledge! Also, as before, the source material I am using to learn about Swift is from the same Ebook as before: 'Learn Code in Swift 4' by Kevin McNeish. This time I will also supplement with this from other courses I have used in the past, e.g. Treehouse to help me understand the information in context. Calling Methods So the purpose of this chapter in the Ebook is to do with appending. So, first of all, what is a method? A  method groups together one or two more lines of code that are then executed as a unit. I've always thought of these as a function put into context. E.g. 'print' is a method, or is it a function? As with any element of Swift, ther...

What I know about Swift - Part Three

This is likely to be the last post about my understanding of Swift - at this point in my journey. After this, thoughts and reflections will be "live", in the sense that they will be specifically about what I have just discovered, am trying to make clearer to me, or feel compelled to share. As before, I am not claiming that ANY of this information is technically correct or accurate; it is what I understand about Swift, at present! Enumerations and Switch I've lumped these together on the premise that Switch statements can be used within Enumerations; both use cases so there is a link there. Switch could actually have been part of the Conditionals - if/else etc. var score = 54 var comment: String = "" switch score {      case 0 ... 20 :     comment = "Good score!"      case 21 ... 50 :     comment = "Great score!"      case 50...100 :     comment = "Excellent score!" ...

How I learned Swift and what I know about Swift - Part 1

Following on from my 'Brief History' post, this other retrospective is to help me make sense of what I know about Swift so far and to summarise the journey I've been on with it. Subsequent posts in this blog will involve up-to-date thoughts and reflections on my current learning of Swift. Here is how I went about learning Swift: In April 2015, I started off learning Swift with several Udemy courses, including one by Rob Percival, which was very popular and highly-rated. At first, I had the naive assumption that it would all be very straightforward and easy to pick up. It wasn't! Rob's course was great if you were confident with the language, but the halfway point I was lost. The tasks seemed to be impossible to figure out without some insider knowledge. Anyway, I supplemented that course with several others on Udemy, which helped me to learn what the basics were. From there, I found a useful site: 'WeHeartSwift', which were useful in carrying out cha...