00:00.00 jamesmontemagno Frank I don't know about you but I often get questions about storing data. You know data like put it in a cloud or on a file or in a database data. 00:11.63 Frank Oh yeah, as long as it's an exclusive or you don't want to put in both places because then you have to oh my God synchronize that data and that is the absolute worst that is the hardest part of programming for forget cash and validation. This is cash and validation on steroids. 00:27.56 jamesmontemagno Yes, we've talked in the past about all sorts of different ways of storing data. Obviously you are synonymously known with sqlite net one of the ways of of having an orm over sqlite and as we know sqlite is pretty much everywhere. But ah what I did at 1 point in my life was I created monkey cash which has many ways of storing simple key value pairs. There's been akavash in the past there's been azure mobile app online offline stuff. There's Couchbase. There's um, all sorts of crazy. Awesome packages that are cross-platform or build into these native platforms for windowsmaciosandroid. However, both Google and Apple they actually have their own libraries built in to those frameworks android and ios to handle data. 01:16.32 Frank Is it. 01:24.66 jamesmontemagno Did did you know that frank. 01:27.60 Frank Um, yeah I tend to avoid first party data things I don't know why I don't I should just give up and give in and just do whatever big corpse tell me that is the right way to store data. You know it's funny I think my whole career I've been I've always had trouble storing data I think I'm not uncommon either I was at a conference once and I was talking to um, ah a young junior programmer a kid I don't want call my kid and ah he was like you know I've been doing a lot of programming and I like writing programs but like. How do you get data out of the program like how do you like when you bring the program back up. How do you How do you have it resume its state and I'm like oh brother now you're beginning the rest of your career like it's so easy to and not so easy. But you know writing a program's not so hard. But it's. 02:11.75 jamesmontemagno Ah. 02:18.70 Frank Talking to servers synchronizing data uploading data downloading Data. It's all complicated and so I've always hated and that's why I created sqlite dashnet because I hate it and so I wanted a very simple way to access a database wrote that library people liked it. But um, yeah to get back to what you were saying. I Knew The first parties had it but I didn't use them for whatever reason. 02:43.30 jamesmontemagno Yeah I specifically really didn't use anything on Android because Android didn't really have anything besides just like Sql lite and like the sort of built-in kind of like base base database. Um. Ah, what do they call them. They kind of like you're paging through data I have like a weird api for Android I never really really liked it too much. Cursors. Thank you? Yeah, you're cursoring through data really wasn't my jam per se and um so I never really went on that Ros I always went on the sql light route. However. 03:01.92 Frank Begger Yeah cursors. Yeah. 03:18.53 jamesmontemagno Um, the ios one? Well Android I should say they they they now have ah something Newark I think it's called door I think it's called door right door database. Um I'm looking enough room not door room room you get gotta get. 03:24.21 Frank Door Oh that That's new for me I've never heard of it database. Oh hello. 03:37.34 jamesmontemagno In the room. Ah yes, so accessing data through ah room is pretty cool actually um so I want to give a shout out here to to this really nice. Um Api because it has these really cool ways of annotating. And doing queries directly as little attributes especially in Kotlin but even in in Java as well. But basically little attributes on top of the data objects. So let's say you have a user you can have a um you could say that is your data object. They called ddaos which is a. 04:13.81 Frank Are. 04:16.57 jamesmontemagno Data access object. Yep a dao and then what you can do is you have a little like interface and you say insert all delete and then get all and you can say at insert at delete at query and then you can give it the query that that function is going to return from said database which is. Ah, pretty cool and you can even do things like on conflict. What's your strategy that you want um you can have different like you know, um, different um arguments for updating and things like that. So so all sorts of really cool queries. It comes down to like actually knowing you know Sql. 04:38.40 Frank Um, and. 04:52.82 jamesmontemagno Commands basically because you're like select first name last name from user right? Not not the best like we have in sqlite dash net. But I think it is a really minimal way of just creating a lightweight database access layer into into getting into the room which has the data. 04:54.61 Frank Yeah. 05:10.30 Frank Yeah, it ah can can I show my age. Um Ruby called these active records remember when those first came out like um. 05:12.90 jamesmontemagno Room as a data now. 05:20.69 Frank Ruby I think is the first one that's like hey accessing the database could be easy instead. Let's not make it so hard. Let's make it easy to access the database they're trying to sell the Orm problem. Um I think that it's a little bit of a debate how you want to deal with your direct. Database layer. How how you create your business objects is almost a little bit separate from this. We're just kind of talking the data layer and cte um dash net. My little orm does not do active record and what I mean by that is it doesn't keep. Ah. Pointer back to the open database so you can't just like call a function on one of these objects to query the database or anything like that you can't just call dot save on it to hit the database. You need to manage the pointer to the database yourself. They're kind of just dumb objects going in and out of the database. Whereas a more sophisticated data system actually has like entity ideas and they enforce it. So if you query 2 person objects and they have the same ids on them. They could come back hopefully as the same actual objects in source in in. Running executable memory with a pointer back to the database so you can do all your easy stuff I actually started adding that ah to seek a light that net and Miguel Ding said Frank Stop it no one wants this keep it stupid. 06:47.55 jamesmontemagno Ding. 06:51.76 Frank Ah, so he convinced me but I've always been um, influenced by the beauty of the active record system where the data objects keep a pointer back to the database and and all the querying stuff tracks which entities it's given back to you so that there is only 1 entity for each. Data object. But um I was going to say but um, were you ever drawn to that kind of system or were you were you were fine with the your old school you you're used to managing the database yourself right. 07:13.92 jamesmontemagno Um, yeah, that's yeah, it's pretty cool. It's like um. 07:29.84 jamesmontemagno Yeah, you know I'm um, just a classic relational database type of guy that's really you know I understand it I get it I did it at Canon after canon continue to do it and I I definitely did understand it I never really got into the no sql trend. You know with just having these big globs to I think I just sort of understood more of the primary key other stuff I have this database I'm accessing and I'm doing this stuff here. Although I mean I guess in general there could be some nice niceties to it the the problem I've always had with you know. Setting up and and managing things in sqlite dash ne is is mostly the one to many or many to many relationships with having to handle. You know? Oh okay, my you know it's it's not too bad for like a 1 to 1 relationship. So like oh my user has. 1 you know address? Oh okay, cool I'll go get the address thing and then but pull that up right? But when it's like oh they have multiple addresses you know, kind of that one to many relationship you're like oh that's that's interesting or imagine you have a playlist and the playlists have songs. So now each song could probably be in. You know playlist has multiple songs but then the song could also be in multiple playlists and you know oh geez like you know it's all kind of kind of all over the play. So that's ah, an interesting one. But I think even this room implementation still handles. Um, basically those joins effectively. 08:50.47 Frank Again. 09:00.96 jamesmontemagno The same like they set up a cross reference where it says oh there's the playlist Id in the song Id and then we're just going to keep a bunch of tracks of you have another your and you know entity which is basically just a key value pair back and forth. You know, ah in that and that in that regard. So I don't think that that even really, you know. 09:16.80 Frank Yeah, it's funny. We're both dot Net programmers. So we shouldn't mention the elfin and room Entity Framework It's it's there Everyone it comes up by default when you create a website and all that stuff I just haven't really used it on mobile. But. 09:19.64 jamesmontemagno Solves this thing in general. 09:33.30 Frank That That's more the active record system. Also where um, they they manage the instances of objects for the most part and it it has the benefits. Ah I apologize everyone for not handling one to many many to one many to many very well in single eye Dashnet I get frustrated with it too. Um I should really improve that somehow but I will say ah there are limitations because I'm doing the dumb record approach. Um because I don't have a pointer back to the database I have to be careful about how things query um, a big one that people always wanted was if I have a virtual method. Ah,, there's a person object and you want to query children give me the children of the person object. Ah, it'd be nice if that was just a property on the object but I can't do that because you knew up the object and I can't Override. Ah. 10:22.70 jamesmontemagno Um, ah. 10:27.29 Frank Ah, new instance of an object I just can't I have to manage the creation of the object in order to be able to do that and even then you can't really do that on Ios nowadays you can but in the old days you really couldn't ah code generate to do that kind of stuff I guess and c sharp nowadays you can to do it that way. All these wonderful options of ways to store your data. So can I tell you? um I I do like the old style but I I did kind of force myself into trying one of the more modern ones core data from Apple the one we were talking about earlier. 11:01.84 jamesmontemagno Here. 11:05.63 Frank I avoided it in the past because I don't know I guess I just heard bad things and it seemed kind of complicated but I was trying it recently and it brought back a lot of good old memories of um, creating entity maps and entity framework and drawing database diagrams I used to love. Drawing database diagrams and relationships and all that kind of stuff I used to really love Microsoft Access I think everyone should start programming in Microsoft Access and I started using core data and it's it's the heavy active record style where you design your relationships all that kind of stuff and I have to admit. Even though I am old school it was kind of fun to use a modern framework and I thought it'd be fun to talk about that. 11:49.38 jamesmontemagno Yeah, let's do it I have had some friends. In fact I know Heather not even just a friend but my wife has been talking recently about core data recently and different migrations and how things end up happening. So I'm I'm relatively. 11:55.94 Frank Is a city. 12:06.93 jamesmontemagno Ah, interested to hear your exploration of why you went down this path and then also um, what it was like and how far you've gotten and what the complexity is you know at this point. 12:20.14 Frank Yeah, Ah, the why is a little bit silly. Um I had a terrible app idea. Let let me give you the quick pitch I don't want to try to sell you this app because it's a little bit silly. Ah you can have lock screen widgets now on the phone. And I wanted a notes app where the notes show up on the lock Screen. So It's almost like a post it notes app where little widgets show up on the lock screen there you go How? how's that pitch notes app they show up on the lock screen if you want them there We buy it. Great. Love it. 12:48.84 jamesmontemagno Love it I'm I'm in I'm in for two I'm in for 2 copies frank 2 copies. 12:54.63 Frank You're in great. Ah, the problem is ah you you can't do Lockc screen widgets with dot net. Wow said said maybe dot net nine or something like that. We'll be able to do it so I decided it's a very simple app though right? you know it's a notes app manager in the notes show on the lock screen. 13:05.48 jamesmontemagno Is. 13:14.33 Frank Really not complicated. So I decided I would just write it in Swift I don't mind writing stuff in Swift I still much prefer f sharp and c sharp but Swift. It's a language has question marks and guard statements and sometimes squiggly sometimes not squiggles sometimes power signs sometimes not power signs sometimes at signs. When should you put the app when shouldn't you put the app who knows it's all fun I like it vi is a language but um, you know it's it's like I wanted this to be a stupid simple app I didn't want to spend a lot of time um, overthinking it or any or designing my own data. Access layer and the default when you do file new project and swift is ah core data app hello core data. So that's the why How's that go. 14:02.68 jamesmontemagno Um, yeah I like that you mean so you just got it. You know like and here it is. You're welcome. 14:11.41 Frank Yeah, it's funny. Um I like their new app template that they do for Swift. It's um, they have a wonderful entity called item the app pops up and shows a list of items and there's a plus sign and that adds an item. The neat thing is and I want to start by giving a big compliment to core data because it solves one of the hardest problems that we alluded to in the beginning of the show was synchronizing data. Ah so. Core data has always stored its data in a little sqlite data. Not always I shouldn't say always I'm sure there's like providers and everything but it's it's usually just putting its data into a sqlite database. The thing that impressed me about the Swift New project template was if if. 14:47.57 jamesmontemagno And. 15:01.42 Frank Ah, you signed your app and actually put it on a device and things and you were signed into Icloud It would also synchronize data accesses up to Icloud so it was doing the local stuff synchronized up to Icloud. Pretty hot James pretty hot. 15:21.55 jamesmontemagno I'm a fan of that I you know I'm a big fan and fan if ah things want to automatically synchronize back and forth I'm not going to say no to that Frank not gonna happen I'm going to say yeah that sounds good. Let's do that. 15:32.80 Frank Yeah, and in beautiful Apple fashion. It's icloud so it's 90% of your users but you are leaving 10% of people behind for synchronization. It's still going to use sql light down deep in its database internals. 15:46.92 jamesmontemagno Um. 15:51.80 jamesmontemagno Ah, yes, yes, is yes. So so let's be very clear here core data just an or M on top of sqlite at the end of the day. 15:51.94 Frank Which. 15:58.42 Frank Yeah, yeah, if sql lightte dashnet with a little more sophisticated. It could do all most of the tricks that core data is using core data doesn't make you manage database connections instead you manage what they call. A managed object context. So I'm like okay, whatever you know arose by any other name so you you keep that thing around and you can manipulate entity objects. You know, um, change properties called delete on them. And then at the end of the day you just say to the context context save and that will do the local database update and it will then spam the console with 8000 messages because oh my god Apple stop it stop spamming the console. And eventually it will upload that data to cloud kit cloud kit have you done any cloud kitt stuff. 16:56.63 jamesmontemagno I Have not known what is cloudkit. 17:01.43 Frank Cloud kit is Apple's database in the sky database in the cloudde. Um, yeah, it's I actually use it in my apps whenever I want to synchronize data between my apps. 17:06.98 jamesmontemagno Ah, boof. 17:17.82 Frank I Upload that data to cloudkit and what's neat is all your apps can you create a container because of course we can't call it a database. We just can't call it a database you create a container up in the Cloud and in your app Id when you set up your app. You can just. 17:20.80 jamesmontemagno So. 17:35.49 jamesmontemagno Are. 17:37.90 Frank Um, give yourself the entitlement to go access certain containers so you can create all the containers you want. Ah, it's funny how it works ah, people actually pay for their own storage. So you're not paying for the database. That's why I like it um people who use it. The user is actually paying for it. So be nice. Everyone if you decide to use cloudkit. Keep in mind that people are actually paying for that. Don't store too much data up there. Ah it it was Apple's tried so many different ways to store data up in the cloud I think cloudkit's finally the one that's good. It's very simple. You have records which are part of a table it rows and and a table tables have a schema. It's it's basically a database up in the sky querying it. You have to use and as predicates instead of like sql that are a little bit weird I still haven't fully. 18:33.46 jamesmontemagno Um, this. 18:34.55 Frank Learned the syntax I need to write my my own orm over and as predicate because it's very confusing. Um, but otherwise ah cloud kit's very straightforward. You know you do you can do a post to create an object. You can delete objects and you can update objects and it's a database in the sky. But it it takes a lot of work you know and you can't you can't use it as your primary database because again 10% of users are not going to have Icloud or if you have a lot of big data. You're not going to want to put it all up in Icloud and so um, even even though it's so cool. You still need. To solve the synchronization problem a local copy and a cloud copy and I was really pleasantly surprised to see that core data just kind of does that for you and that that's a really neat feature. 19:27.19 jamesmontemagno Oh that's really cool. Yeah I like that um that feature in general of it of just like hooking those things up because you're right? like not everyone's going to have Icloud which is kind of a bar but it's also their fault in a way right? I mean I guess you can run on that fifty megabyte pretty quick i'm. 19:38.47 Frank Yeah, terrible change I meant. 19:44.40 jamesmontemagno Just sorry and um, well and it's hard too because I I go through mine and I definitely look for problematic apps that are like backing up ah too much data. A lot lot of other stuff basically that they shouldn't be doing what you could do right? because you could put things in the wrong folder. You know, like when you think of when I think of Cloud kit. It's not. 19:54.10 Frank Um. 20:04.10 jamesmontemagno Actually anything to do with cloudkit. But for example, Icloud itself. You could just store an image or a file in a folder when you go and ask for a different folder some of those are backed up automatically to to Icloud as part of your app's data. That's there and if you're. 20:16.00 Frank A. 20:22.43 jamesmontemagno A photo app or a video app and you're putting all of your images in there then those would get backed up and that's that's sort of up to you and that's ah problematic if your users are looking to turn off specific things for specific apps at that point. 20:35.45 Frank Yeah, and of course the biggest prompting this is all Apple centric. So if you're doing a cross-platform app but you don't want to do any of this. This is all bad. Go put up your own api. It's not that hard do asp.net new project throw it up on sure. It's fine. 20:41.87 jamesmontemagno Who. 20:53.58 Frank But again I was just trying to keep minimal code here. That's why I'm using the first party thing use the first party database all that kind of stuff I didn't want to manage an additional website and things like that I was trying to keep it nice and small but I have to compliment them because it's it's really come a long way. The part I think I enjoyed the most was and this is something I regret for not offering sq ne entity framework so has this in visual studio but the entity designer you know I'm old school I like designing my entities and creating my oneto many relationships and my many-to- many relationships. 21:20.16 jamesmontemagno A. 21:29.17 Frank Ah, fun thing I I noticed that they do in their designer that I haven't seen other people do is if you do like a 1 to- many relationship from 1 entity to another. They force you to also declare the inverse of that one and that's really clever so that. Ah, no matter what object you have you can move around the graph really easily and it's a synchronous Api which you know you may or may not love depending on all those things especially because it's very unclear what the threading rules are with core data. 22:02.34 jamesmontemagno Is. 22:04.30 Frank So you're kind of like hitting the database on the ui thread. All their examples. Do it. It's not the most beautiful architecture and they don't really tell you how to write a proper multithreaded one so there are downsides but you know what if you just don't care James just. Lower your standards a little bit and access the data layer on the ui thread. It's fine and it's it's a pretty productive development environment terrible. 22:31.90 jamesmontemagno Well I do think that the the nice part about core data though kind of to that point is that there is not only like that persistence layer but it has a bunch of things built in kind of like 2 you're talking about like I'm just doing stuff and like I think it does it because. There's like shake to undo support. You can do things in groups. Ah, there's background tasks like it says you know this says perform potentially ui blocking tasks like parsing Json into objects in the background and then you can cache them and store the results and like and just like you can it'll do it and you know. 23:02.69 Frank Um. 23:06.74 jamesmontemagno The last part they talk about versioning and migration where I'm very interested about I don't know if you got that far I think that's probably where I feel like that's problematic in some way. 23:07.46 Frank There? yeah. 23:15.59 Frank Yeah, versioning in migration's kind of fun how they handle it um in general core data and the way it talks to the sqolite database is it'll just migrate the database much like sqollight Dashnet does. So if it notices you're using a record with a name field it guarantees that there's a name field on that. 23:35.14 jamesmontemagno Is. 23:35.59 Frank On that row I keep sorry they call it records and I keep bouncing between database lingo and Apple lingo but records rows tables bunch of records basics. Ah now I totally forgot where i's going with what were we talking about James. 23:50.46 jamesmontemagno I think most of what we were talking about Frank was the sort of setup that they have of these nicer features that are built in and that how it basically won't mess up your ui you know your ui blocking stuff at at that time. 24:03.19 Frank Yeah again I'm a little bit fuzzy on the rules I am not a professional swift developer I am really good at dot net threading I am less good at Swift threading. Um, yeah, you know I apply the same rules I tell everyone with cqolli dashnet. Make your queries small. You know don't don't fetch a thousand records. Don't try to present a thousand records in the ui it's just not going to work out so write nice tight little queries and things like that. Ah so the fun. The the crazy part of the migration though. Um. Going back to that topic was how they handled the cloud part of the migration because it is using cloudkit and cloudkit has its own migration rules and they're a little bit funny. How I actually really like how Apple did this but it's a little bit funny. Ah. You've done it differently in development when the apps and development. It just kind of automigrates the on. Ah the cloud database. So I mean Sql I doing something the cloud database kind of automigrates and it basically. Allows anything if it sees a new field. It adds the new field. All that kind of stuff when you want to go to production which I learned to includes test flight. So everyone if you're going to send an app out to beta testers take notes here. Ah you have to? ah. 25:25.80 jamesmontemagno This is. 25:32.24 Frank Migrate to production So All your development changes The last snapshot of how it saw that you were working with a database will then get migrated to production and that's where all testify users and app store users within access the database. So That's a fun. It's a workable. Migration path it it lets you make some mistakes during the development process and then only when you're pretty sure you got it right? Upload it all to production. 25:57.77 jamesmontemagno That makes sense. Oh that's really cool. Yeah, so you can really just test it out. But then you have to yeah what happens when if I guess severe users haven't updated yet like what happens in that regard. Do you know. 26:14.33 Frank Ah I don't know other than the classic rule of database when adding a column. It's nullable. Um, so the 1 frustrating part of using core data is even if you declare fields as required. You know like this string is required name is required. 26:21.38 jamesmontemagno Are. 26:32.22 Frank Ah, it can still come back null and so just in the api and so whenever you're accessing the um these kinds of objects you are writing very defensive programming because Swift is pretty strict about if it's declared as nullable. You have to handle both conditions very much like dot net if you turn. 26:47.82 jamesmontemagno Got it. 26:52.50 Frank Warnings on his errors like I do and create pain and torture. 26:56.15 jamesmontemagno Yes, that seems not like fun. Yeah. 27:02.11 Frank Yeah, so noble fields Everyone whenever you're migrating your database just said is optional it. It works though like these are ah like I said my experience was very positive here I don't recall why. 27:07.74 jamesmontemagno Nice. 27:17.30 Frank Poor data got a bad rep in the old days I don't know if I was just ignorant was I listening to the wrong people I don't know what was going on. It's it's been in the background of my life for the last you know 1012 years and I've always ignored it successfully. And so I was happy that the 1 time I decided to try it out. I was pleasantly surprised which is a good pro tip to everyone try new things from time to time you might be surprised. They can be good. 27:45.42 jamesmontemagno Nice I like that that's awesome. Yeah I think that it's always fun to explore. There's a bunch of things in the world of dot net that I've you know, explored a little bit with um Monkey Cash Obviously with like light Db for example or some other orms and I haven't even like. 28:00.92 Frank Um, giving. 28:04.16 jamesmontemagno You know you were time as I haven't really gone down the world of um I really want to of is you know a lot more entity framework and doing a whole bunch of the migrations and things like that and having it just do so much for you. So it's on my list like learn a lot more of because I I just. Don't really come from the web world and necessarily as much where any framework is everywhere for dot ne developers but I know that those aren't the only one there's like tons of other you know things on top of it. So I think it's a good kind of lesson to remember is like hey like you can go out there and there's a bunch of stuff out there. You know that you can try and you know. 28:24.39 Frank Yeah. 28:37.66 Frank Yeah, and I'm sure there's I mean do you remember the early days of mobile development. There were a million cloud databases out there. Not all and not all of them survived. 28:41.00 jamesmontemagno So John with. 28:50.90 jamesmontemagno Um, yeah. 28:50.94 Frank And so I'm sure people are like screaming into their potcatcher of choice right now and they're like well you guys didn and talk about this awesome database. Sorry sorry you can only learn so many databases in your career and you stick with the ones that you like and that work and it's good to know that I I have another one to add to. But it does make me also want to create something something like an Icloud but for cross-platform dot netie apps because I do like the choices they made as apple does they present ah a simple ui but one that works you know 90% of the time. It's it's a good system so I would like to. Take something like you know azure tables or and merge that with sqlite so that you get local syncing with the cloud syncing things like that. But I'm sure this is the point where everyone's screaming that you should try this frank and you should try that 1 frank okay so I'm sure they exist but just saying. 29:39.64 jamesmontemagno So. 29:46.41 Frank Ah, isn't it great when libraries deal with all that for you. 29:49.24 jamesmontemagno Yeah, it is. It's a nice, a nice perk at the end of the day we yeah right into the show. Let us know what things you're using. Are you just using sql lightte dash net for everything. Are you using some other cool framework that we should definitely try out and try to integrate into our applications. Let us know go to merge conflict out I found this contact button over there or better yet. We enabled fourteen day trials on our Patreon if you want bonus behind the scenes podcast episodes fourteen days any of them any any trial you wanted to just 14 you get even binge the backlog of all of our bonus episodes that is ah there's a little button on the merge conflict fm website so give that a go as well. Let us know what you think. 30:14.45 Frank Um, who. 30:28.71 jamesmontemagno Um, that's it. Yeah I'm glad you gave a core data try I should really try it and like I should probably experiment more with some swifty stuff and like take a look at those templates because it sounds pretty cool. 30:35.48 Frank Yeah, yeah, it's fun to break out of your box especially when the results are okay, it can be disastrous too when you get outside your box. 30:42.95 jamesmontemagno 9 I'm gonna do it. Yeah I'll do it all right? Well thanks everyone for tuning in super duper appreciate it. Hope they have the most amazing day in your entire life until next time this has been another merge conflict I'm James Mont Mag now 30:58.90 Frank And I'm Frank Krueger thanks for listening. 31:03.53 jamesmontemagno Peace.