Consolidation Day 2

by | February 21, 2019

Consolidation Day 2

Jeff Summers

February 21, 2019

Today marks the second of three Consolidation Days during the 100 Days of Swift challenge. As I wrote yesterday, I am seeing tremendous value in this learning concept of reviewing the foundational concepts of the Swift programming language again before moving on to more advanced topics. Yesterday was simplistic enough reviewing things such as variables and constants. Many potential programmers might be able to skip this if they have experience with other programming languages. It becomes more a review of semantics rather than new information.

Day 2 of the review was slightly more important. Today started with a review of functions which are extremely important to developing efficient code. These are again similar to other languages so students may be tempted to skip this or go through it at a more rapid pace. You could probably get away with that but make sure you are clear about how things are called and named within functions otherwise you will find yourself troubleshooting things that should have been second nature.

The second half of Day 2 was in my opinion was warranted and should be carefully reviewed to make sure you have a solid understanding of the concepts. This latter half of the review consisted of several terms including Optionals, Optional Chaining, Structures and Classes.

These are all incredibly important and often times misunderstood or misrepresented by programmers. Optionals should be thought of as a safety harness for programmers where Swift makes sure that your code or in particular the modification of variables or results of functions contain the type of data you and the application expected so that it doesn’t crash.

In a simplistic sense, an optional allows a program to return an expected result or if there is no valid result return a nil. If left to their own devices, programmers sometimes forget about things not in the “happy path” where most errors or data deficiencies present themselves. An optional is Swift’s way of saying “I will give you a result but you probably should make sure it is accurate before you go assuming everything is working perfectly and check the data to make sure”.

When I first began learning about Optionals, it was frustrating. It almost felt as though Swift wasn’t trusting me. There were additional steps necessary to use the data coming back from a function (which is referred to as unwrapping the optional). I just wanted to get the data and move forward. But after working further with the language and seeing my share of code that didn’t always return what I thought it would; I have gained a new appreciation of the power of these constructs.

Structures and Classes are likewise extremely important allowing programmers to properly define objects and follow a more structured object-oriented approach to developing applications. So many who claim to be developers who profess mastery of these concepts end up only partially following the rules of object orientation. A review of how these are implemented within Swift is very useful and a great reminder that no matter what our level of experience, there are always things that you can learn to make you and your code better.

Share this Article

Posted by Jeff Summers

Author, technologist, and baseball aficionado specializing in information technology and developing new and creative ways to interact with the world around us. My goal is to extend the boundaries of what is possible and find ways to make the world a better place while having fun.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Stay Connected

Search

More Articles

Pace Layered Architecture Categorization

Change is inevitable. Today’s computing environments are constantly in flux from internal and external forces that put demands on the systems and necessitate changes to maintain its value stream. Technology currency is a constant struggle that organizations must...

TBM, Another Holy Grail?

Technology Business Management or TBM as a term was coined around 2012 although many of the concepts making up this framework have been around for almost as long as there has been IT. In its simplest form, TBM represents the integration of business, technology, and...

Visionary or Dreamer?

Thinking back over your life you’ve met and worked with countless personality types. You have been a part of teams that struggled to complete simple tasks and the work felt meaningless. Perhaps your goal in these times was to just trudge through the mud hoping the...

Archives