Starting a new project best coding practices?

Hello Swift Community,

I'm newly into coding with Swift and I have very little previous coding experience with html in my teenage years and some adult years. I've always wanted to be a software engineer but time and money have always been something I wasn't good at managing anyways... my question is kinda simple yet maybe complicated.

In the past when I would code with say html we would simply open up a notepad document type out our code and save the file as .html and essentially it would be an html document you could upload. As I'm learning Swift in Xcode playgrounds following through The Swift Programming Language book I'm learning all types of coding and such but I'm not getting that BUILDING something vibe at all.

When I open Xcode and start say a new project with the templates my screen is filled with pages like ViewController and AppDelegate etc and this makes the idea of creating a new project of my own with what I learned more daunting. I understand all this stuff is neccessary for app development but are there any guides or books you can suggest that essentially explain what all these things are? Or is there a way I can still build apps without knowing what any of this stuff is by essentially using what I learn from the book?

I feel overwhelmed because I know I'm not going to learn everything and just have it memorized from the book but I have very little clue to where I should even start typing first.

Also for The Swift Language guide should I simply just be reading it or should I be typing out the examples and exploring the principles in more detail for myself? I'm thinking that I would feel like I learn more if I could build something and essentially focus on learning what I need to do the job that I need done cause some of this stuff seems like stuff I may never use. Thanks for any insight.

If you're looking for something a bit more interactive, it might be worth trying Apple's Swift Playgrounds app (available on Mac and iPad) - ‎Swift Playgrounds on the Mac App Store

It includes professionally-written, interactive tutorials about learning to program in general and about creating apps for Apple platforms specifically. They're translated in to many languages as well.

And it's free, so no harm in trying it out in addition to other resources.

1 Like

I'd distinguish 3 main directions that in general are similar between languages and platforms.

  1. The language.
  2. The programming.
  3. The Apple's ecosystem (substitute with any framework to generalize).

In order to thrive, you need to cover this three things together, which might feel overwhelming as there are a lot of things to look out for.

You start with the language itself, free from any other entities, such as Xcode and Apple's SDKs. You learn language, write console apps, compile them from the terminal, etc - write as much as possible code, from book, from head, whatever - you need this sensation of what you're reading in the terms of execution. That will give you the feeling of the app, how it starts, how you can control it. Your apps at this point will be limited to standard input & output, but that's OK, core concepts are highly transferable. Your goal at this stage is to get comfortable with the language and its basic concepts - classes & structs (difference between them), protocols, control flows, etc. More advanced topics, like concurrency, generics, and others you also read through, but right now there is no urgency to understand them fluently.

Once the language is more comfortable for you, you start with the Apple's platforms. I suggest as an entry point this tutorials - Introducing SwiftUI | Apple Developer Documentation. In that way, you will start making apps with some visible result, which is important to "fuel up" yourself. These tutorials will give you the basic understanding how to create apps for iOS, allowing to then go into exploration.

Now as you get yourself more confident with foundational ideas, you need to get deeper at them. Choose some project idea (app you'd like to have) and start developing it. You will face tasks you are not yet know how to approach, and to find a solution you'd better advise to the docs (for example, how SwiftUI state management works, or how to work with API requests). That will allow cover more details. At the same time, you will deepen language understanding: you'll face generics and concurrency, for example, and will see that you need to revisit them with more knowledge of the language.

Finally, it is time to go and get to know more purely programming concepts, by

  • Learning algorithms (Grokking Algorithms is one of the best to start with).
  • "Design Patterns" book for common elements in apps.
  • "The Pragmatic Programmer" book for almost everything :slight_smile:

I also highly suggest learning basics of C language. The deal with it is that it, first of all, really simple (not to confuse with easy or shallow), but exposes you to the some concepts, mostly memory-related, that is hidden in many other languages, allowing you to better understand what's going on here. Then, C has a long history and in some way a huge part of languages are compatible with it, including Swift, of course. It also has a lot of open source libraries that might be useful. The last point for learning is that, despite huge drift off the Objective-C, you still can find it useful or required (even though rarely) in development for Apple's platforms, and while there is almost no similarities between ObjC and C in syntax, catching up ObjC is easier when you know C.

4 Likes

Hi -

I feel the same -- even after years!

One simplification for learning to be a software engineer is to focus on writing Swift packages and stay away from UI frameworks; that increases the ratio of coding to complying.

Otherwise, for practice, focus on Apple sample code: it takes a working happy path to some achievable but interesting goal.

For perspective, Apple's Books app has free books for teaching Swift (with separate teaching guides).

The Swift Language Guide has to be read once to see the language and issues, but then used mainly as a reference. For a locally readable/searchable form, get https://github.com/apple/swift-book

Apple materials are minimal and polished; they err on the side of leaving out complications (to avoid negative feedback at scale). Don't be surprised to stumble when off the happy path, and to have big gaps between the big picture and the problem at hand.

Into these gaps flows a ton of community materials and practices that vary in quality and incentives but most of all in their topology -- in what they assume you know -- making it hard to find a good match. So if you can describe specifically the problem, usually searching will give an answer. Otherwise, to master a sub-domain, take one of the more ordered paths from a well-regarded author, e.g., from Paul Hudson's series HackingWithSwift.

In any case, for each example, aim to understand it loosely inside-out:

  • The code: how it works, and how to change it to tweak behavior
  • The component: who calls it when and why
  • The product: what bits are produced and packaged where

"Loosely": I make the most progress by summarizing the main lessons and outstanding (deferred) questions for each example. Otherwise I won't realize the point of the example, or I keep investigating side-issues without guidance, and then stall.

All that said, I'd recommend Java over Swift as a first programming language.

Both Apple and Swift are much more ambitious in the variety of contexts and use-cases they address. Swift has a number of subtle but pervasive aspects that are unique to the language (value types, specialized generics, protocols, discriminated unions, concurrency, ownership). "Progressive disclosure" holds out hope that new developers can ignore the hard stuff for a time, but somehow you always feel the dragon's breath. Layer on that the variety of Apple devices, Swift's reach into Linux and embedded, and the iron cage of Xcode, and you end up where it's the experts who know best how little they know. And because (for the most part) you can't do in Java or Python or Javascript all the magic you can in Swift on Apple, your hard-earned wisdom is not transferable.

2 Likes

Thank you for the response but my entire goal is strictly to develop for Apple platforms. I'm not looking for anything transferrable just looking to specialize in one aspect completely.

Anyways I recently had a mental breakthrough after a few days off. I woke up one day and my brain just started seeing the world as "code able" I can look at something like a bottle of water and start to formulate the ideas around how I would create that object with code language. So I'm feeling less overwhelmed and more excited to start creating my ideas. I'm going to grind out reading the language guide and start developing ideas from there.

1 Like

That approach won’t get you any far from the starting point. The importance of learning fundamental knowledge, which is transferable, is what will help you to thrive in any specialization you may choose. Understanding of fundamentals give you deep insight on how things works and allow to progress faster in the long run, compared to shallow learning of a framework.

Aside from that, Apple platforms don’t leave in isolation, so developing iOS app includes a lot of other activities, such as communications with other developers (server side, for instance), or adopting some library written in C, or using an algorithm to make a feature possible to implement, and so on.

Currently, where ChatGPT/Copilot can (almost) make all boring work of writing some SwiftUI code, you as a developer have to be able to offer more than that, which is what fundamentals are for.

1 Like

See also the recent "pathways", at https://developer.apple.com/pathways/