Posts


Jan. 7, 2023

Classes in JavaScript

futuristic machine making copies of people - midjourney

First lesson with classes today. First of all I was pleased to see they exists since we’ve just been plucking objects out of thing air like:}

const userIan = {name: 'Ian', language: 'Indonesian'}

but with classes we can declare a class and instantiate an object of it:

class User {
    constructor(name, language) {
      this.name = name;
      this.language = language;
    }
}

const ian = new User('Ian', 'Indonesian');
console.log(ian.name);

There’s (at least) single inheritance:

Jan. 6, 2023

Things I love about Swift after a week of JavaScript

Swift logo punching the JavaScript logo - Stable Diffusion

So, a week into JavaScript, what am I missing? The techie in me wants to say things like Automatic Reference Counting, but actually, at my junior level, I don’t run into memory management issues on the day-to-day, so what really do I miss?

Determinism

When I build an iOS app, it’s frozen in time. The functions inside are always going to stay the same. There might be a future version of iOS that won’t run it, but as long as it runs, any pure functions inside it will return the same value. The process of compiling it locks that in. Likewise, any libraries that are complied with it.

Jan. 5, 2023

Second Guessing

young women identical twins enjoying the beach unreal engine - midjourney

In the last post, I was pleased with myself for accidentally anticipating an improvement to a tutorial project which turned out to be the next task, today I’m pleased with myself for discussing the pros and cons of onclick= vs addEventListener() then having that same discussion turn up in the next tutorial. I take it as an indication that I am correctly immersing myself in the subject.

Dec. 23, 2022

99 CSS Layout challenge

In the Zero To Mastery Complete Web Developer course, I’m up to the first practical challenge - to use CSS to layout a reasonably standard looking web page using flex-box and grid to make it responsive.

Frustratingly, both for writing this, and while I was trying to build the page, I’m unable to screenshot the example of the page I was supposed to be building, and instead had to keep opening the video and seeking the two second flash of the completed project, and eventually being reduced to photographing my laptop screen like a boomer relative sending me a meme:

Dec. 21, 2022

HTML 002 - Tags for structure

Young woman at a computer writing html, Impressionistic - Stable Diffusion

I briefly mentioned earlier that our HTML tags should flag WHAT this part of the document is rather than how to display it (we’ll look at how to use CSS for making the content look how we want later). This idea is called semantic HTML. This post will look at some of the tags (often called semantic tags ) we use to convey knowledge of what part of each document an element is.

Dec. 12, 2022

Visual Studio Code

I’ve gone over to the dark side a little. As I think about the sort of apps I want to make, I realise I am going to need to be able to do back-end web development. My apps are going to need a secure REST api to a database. I guess that means node.js. I’m also conscious that my ticket app needs to run on android, and a short cut around all of that might be to make the whole thing a web app from the start, but with the premium experience on iOS.

Dec. 9, 2022

Clean code

young woman cleaning a computer, painting - stable diffusion

I’ve been listening to the latest episode of the Empower Apps podcast, this one with Jill Scott talking about “Humane” development - in the sense of being humane to whoever (probably you) is going to be reading this code in the future. It helped me clarify my thoughts about a couple of things.

None of these ideas are particularly new or groundbreaking, and although I think of them as my personal style, they are very common, and in Swift could be regarded as part of the culture. Some of these concepts support each other, some represent a trade off between two opposing ideas that require us to make a choice.

Dec. 7, 2022

SwiftUI provides

A few hours after I speculated about pausing work on the tickets app because outputting the tickets was too far out of my expertise, a helpful instance of the Baader–Meinhof phenomenon threw up some help in the form of this tweet from @FloWritesCode . It turns out this was an addition in iOS16 announced at WWDC that makes this straightforward.

As soon as I googled around about it I also found good solutions that wrapped the old code to provide similar functionality. So that’s a lesson for me about not assuming something’s hard before I’ve spent some time investigating it. I took that lesson and applied it to rendering to a PDF, and of course, @twostraws has a code example for that from three days ago!

Dec. 6, 2022

Committed

I quite like logging into GitHub and seeing my commit history as the graph with the green dots. Once I get up to a year it would be a great thing to have on a T-Shirt.

I’d expect to be seeing the busy weekends, but Tuesday nights seem to be oddly productive. It could just be a start of the week energy thing - I have some other community obligations on a couple of Monday nights a month.

Dec. 5, 2022

Ticket to ride

superman crashing into a train, cartoon - Stable Diffusion

A couple of days ago I was lauding the learning benefits of writing your own projects over completing tutorial projects - since your own projects push your boundaries further. Of course, its also the case that the project requirements might so completely exceed your current ability that it grinds to a halt. That’s the case with my behaviour ticket app .

The part of the app for collecting the data is pretty much done and how I imagined it, but the output needs to be pretty tickets that can be printed on paper. I managed to write the ticket data to a CSV file and export that to the files app with a .fileExporter, but really what I wanted is to have one of those share screens where you can chose to AirDrop, Print etc, and for the tickets to have been rendered to a PDF or series of images to be shared. That will have to wait. I’m just up to a bit in the #100Days about writing images so I’ll push on with that for a bit and come back to my app.

Dec. 4, 2022

Pi Server

I have a a couple of Raspberry Pi’s on my home network. One is a radio interface on the AllStar network , and the other is just a toy server - I can’t actually recall why I bought it. Both of them are Model 3B’s - I’d love a 4, but they are scarce and expensive.

This doesn’t have much to do with Swift, although it’s possible to run Swift on a Pi , or even Vapor . Mine is set up as a generic web server that I use as the back end for my tiny projects. It runs Node.js , apache and lighttpd webservers, PHP , MySQL , SQLite , and, when I get to that stage of my programmming, Postgres . I could do all that on my MacBook, but it’s somehow more fun on the Pi.

Dec. 3, 2022

Towards MVVM

young woman swimming in spaghetti, by Hokusai  - Stable Diffusion

On one of the more mediocre episodes of Fireside Swift , McSwiftface and Zach talk about the SOLID principles of class design, although I don’t hold the principles as the article of religious fervour that many interviewers apparently do, they are a useful touchstone for considering class quality. OOP had been in swing (in a commercial way) for a few years by then - I was writing in Delphi and C++. The spaghetti code era was a long way behind us and the idea of separation of responsibilities was well established.

Dec. 2, 2022

Deep Linking

I was listening to an old episode of Fireside Swift today discussing NFC tags. I have a bundle of this tags in a drawer here somewhere - I thought it would be cool to tap one as I came home to turn off the CCTV and some other home automation things. But it turns out my phone (an SE2) has the capability for this, but only inside an app - not just from anywhere, whereas the proper phones can just tap anytime, and if the NFC payload is set up correctly, follow a URL, including by “deep linking” into an app.

Dec. 1, 2022

Project Based Learning

young woman holding a phone outside near a lake, painting - Stable Diffusion

A couple of times in conversations on Fireside Swift and Swift Over Coffee the presenters have talked about the danger of just doing more and more tutorials to learn programming, and the benefit, in contrast, of building your own real app. Although I am very much still benefiting from the 100DaysOfSwiftUI I have been seeing some of the upside of working on a real app in the last day and a half.

Nov. 27, 2022

Tickets on Myself

Way back on Day 47 I wrote a little habit tracking app. It was the challenge at the end of a JSON tutorial, so the persistence is done by writing the JSON to UserDefaults as a string. Basic as it is, it’s installed on my phone and I check it a couple of times a day, and haven’t missed a day of coding, or the weekly bin day since. It’s strangely motivating.

Nov. 21, 2022

Something weird 'append

I’m noodling around making sure I understand how Core Data works. Thought I’d start with a master/detail app with an array of structs, then replicate it in a Core Data implementation. I’m using an array of this struct for my data:

struct Garden {
    var id = UUID()
    var name = ""
    var address = ""
    var plants: [Plant] = []
}

And I thought this code to load up some sample data was pretty sweet.

Nov. 20, 2022

Tough Day

Bad Day at Sea - reddit u/SpaceKen

Day 61 of #100DaysOfSwiftUI is a tough day. It’s the first real big test of Core Data understanding, and I’m finding I didn’t actually understand how the code for Core Data works. For the first time, I’m thinking of going back and redoing the days leading up to it.

To try and get it straight in my mind, here’s how I think Core Data works:

Nov. 18, 2022

iOS Dev Twitter

Twitter logo bird bleeding - stable diffusion

One of Sean Allen’s many pieces of excellent advice was to follow a few Swift/iOS dev people on Twitter. I took that advice, and it is now a source of joy to flick through every couple of days and get a feel for what’s happening, and to discover new things. It’s how I learned iOS Dev Weekly existed, and discovered Meng To , and put faces/ideas to Swift and iOS people that’s I’d heard mentioned or interviewed in podcasts such as Erica Sadun and Sarun W.

Nov. 15, 2022

FriendFace Feedback

After each app, I use my HackingWithSwift+ membership to view Paul’s version of the app as a way to judge my performance. Yesterday’s app was “FriendFace ” - download some JSON of a number of people (including their friends) and display it.

UUID

In my struct, I’d just specified the User.id as a string, Paul uses UUID - this makes no difference to the app as it stands, but is much better if we ever needed to add users.

Nov. 13, 2022

Profile Photo Rabbit Hole

down the rabbit hole, children’s book illustration - stable diffusion

I’m on day 60 of #100Days , and have just wasted most of an evening’s coding time going down a rabit hole I didn’t need to. The app for this challenge is called “FriendFace” and is pretty straightforward: download a heap of JSON which is an array of users. Show it in a list that can be clicked through to see the details of that user.