Ray Wenderlich Functions and Types Course - CONSOLIDATION ENTRY!

Not wasting a moment since completing the functions and types course, time to review Catie's course in its entirety. To do so I'll be looking through my previous entries to make sense of the knowledge, rather than watching the videos again. Let's go!

Start Time - 15:45

Entry 1 - 8/1/20

A general intro followed by functions. With the review of these, I generally had no issues. Recap of return type, default values...all good!

Overloading - this means creating different functions with the same name. Each function with the same name needs to be unique.

Stride function - new feature in Swift -

for i in stride(from: 10, to: 2, by: -2) {
    print(i)
}
So good for number sequences basically. 


Entry 2 - 11/1/20

Advanced parameters as the main focus here. 

Variadic parameters - use of ... so there can be multiple values. 

Inout parameters - used if the value of the parameter could change. The ampersand used. Works on variables. 

Functions as parameters - more complex now.  Known as higher order functions. Using the signature to put in as an input parameter. Type alias can be used here to save putting in a complex signature each time! Functions also known as compound types as they can use mixed types of data.

Closures - something I've always found hard! Closures do NOT need argument labels - parameter names only needed in the closure body. No default values allowed...a few differences to functions.


Entry 3 - 14/1/20

Closure syntax - the example of going from more complex to simpler with the dollar signs.

When you call the closure, no argument labels!

forEach and map. forEach is new and is an alternative for x in .... etc. 

Map is specifically for arrays and is a type of closure. It transforms the collection. Map is generally better than a for loop.


Entry 4 - 19/1/20

Different types of map. Compact - used for optionals; iterates over the values and returns the ones not nil. Flat is for combining multiple arrays into 1!

Shorter entry this one - not much else here to report.


Entry 5 - 25/1/20

*Gaps between entries getting bigger here, which was a shame.

More on map. Use of filter within the closure body to make a condition e.g. size, beginning with a certain letter etc.

Reduce - a way of changing the value of each item in a dictionary, or array in fact. Can be used for building empty array/dict too. 

Use of sort and sorted - other in-built Swift functions to organise data.

You can give a label to a value within a closure (not with the type like parameters) so then you can do more with it - calculations/computation etc. Or you can use dot syntax at the end of the curly bracket and use the $0 and $1.


Entry 6 - 26/1/20

Enums - recap mostly. 

Raw value types to put in - Xcode figures out these after 1 is done.

Use of filter and all cases. CaseIterable - the protocol that you need to include in order to access all cases and other functionality. 


Entry 7 - 1/2/20

Switch statements. Used with enum data within a function. Syntax for ranges etc. 

Value binding - use of let and where. You can put in specific conditions here to make the range of values clearer. 

You can also use switch statements outside a function.

Doing it with a tuple too - coordinate example.

In a challenge - use of switch within a for loop. To look at each case. But a reduce closure could have been used instead to be fair.

Associated values - putting the type in brackets or using label names with the type too. 


Entry 8 - 3/2/20

Stored properties and use of property observers. willSet and didSet. Automatic use of newValue and oldValue can be accessed.

Type properties - using static keyword. So access is within the type rather than an instance of the type.

Computed properties - some sort of computation required. You can use get/set or get. Not just set!

Lazy - not used until the first time you actually use it. So good for saving memory etc.


Entry 9 - 8/2/20

CaseIterable - protocol mentioned before. Use on enums so you can access all cases etc.

Lots of complex stuff here - around this point was when I started losing the thread. 

Use of mutating func as the value of the parameter is going to change. 

Question about when to use method and when computed property. Properties are better for when holding values; methods for doing work. 


Entry 10 - 11/2/20

Inheritance. All good here - use of class and subclass etc. 

Polymorphism - subclasses will be treated as the superclass when put with them in an array.

Casting - use of as keyword (can be as? as! depending). 


Entry 11 - 14/2/20

Inits - getting used to the required, convenience, what designated etc. means. 

Two phase init - first init stored properties from bottom of hierarchy upwards; then use anything that use of self.

Designated init need to call super.init. 

Convenience must call within the same class. Easier ways of creating objects with default values. 

Protocols (brief bit on this) - this is about the requirements like a contract. It's to show behaviour - what is required. 

Entry 12 - 16/2/20

And here we are! Today it was more on protocols and also extensions. 

Extensions are useful so you don't put so much crowded code for a class or whatever in at once. You can separate it into files and keep those bits separate. Makes more sense now!

Use of structs with protocol (Shape).

Finally, a bit about value vs reference types. I didn't realise that technically objects come from classes, and values come from structs. That was a revelation!

Lots of situations for when to subclass - each class to have a single concern each. Also, it it's to do with identity, use class and use protocol for specific behaviour - what the object can do. 


And that's it!

Looking over all of this, I've learned a hell of a lot. I feel more confident with class, struct, protocol, extensions, inheritance, init.... most of the content!

I need to keep working on closures to get more used to these. But overall, a very, very positive course. 

Now time to look at the next rw.com course! 

Finish Time - 16:28 (43 minutes)

Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)