JSON vs Polymorphism and editable index pages

Michael:

Hey. I'm Michael Dyrynda.

Jake:

And I'm Jake Bennett.

Michael:

Bennett, welcome to episode 157 of the North Meet South Web podcast. Good deal. Hey. Oh, Internet cut. Got went out with with garbage.

Michael:

Are you there? It was on mine.

Jake:

There you are.

Michael:

Hello.

Jake:

Cut off for a second. I don't know. Somebody's if it's back now.

Michael:

Alright.

Jake:

It's crazy to me that this works at all, honestly. The whole, you know, 14 and a half hour thing, it's wild to me. It is absolutely wild to me.

Michael:

What's gonna happen? Which is talk to

Jake:

you real time.

Michael:

Mhmm.

Jake:

In real time with video. Never thought it'd be my reality.

Michael:

And, like, only just a little bit only just a little bit of latency.

Jake:

I mean, hardly hardly any. It's pretty darn close. I mean, you know, pretty good. Pretty good.

Michael:

It is pretty pretty. Pretty.

Jake:

We've, we've been chatting a little bit about some of the issues you've been dealing with at work. Not issues, just challenges, unique challenges. So thought we could chat about that a little bit today.

Michael:

Yeah. I was thinking about

Jake:

And yeah.

Michael:

I was thinking about how we could talk about that in in some kind of kind of exactly what I wanna talk about, but in in the abstract. So that it's not too specific to what I do in my day job. So I'll

Jake:

I'll see how I go about

Michael:

this and if if it makes sense.

Jake:

Okay. I I have one I have one other similar challenge. Like, not not similar challenge, but just a UI sort of, question. And so I

Michael:

can throw that off you at the

Jake:

end of this one too, and, we can start

Michael:

up with

Jake:

that a little bit. Yep. Yeah. Okay. You go first.

Michael:

So we have this notion of, let's call it a referral program, I guess, because that's effectively what it is.

Jake:

It's a referral program.

Michael:

And the affiliate of the referral program has an agreement you so you me as like the intermediary allows you as the downstream user no, as the downstream user.

Jake:

Okay.

Michael:

And let's say David Hemphill as the affiliate. So you 2 have an agreement through me as the intermediary. Now David Hemphill, in setting up this agreement, can set on his, on his, referral account some fees. What he will pay you based on the referrals that you send to him that are successfully closed. Now these referrals, we set a default, so every person, every affiliate that signs up and creates an agreement will have these fees attached to their agreement.

Michael:

It's not a one to many. We're not taking, like, that value and linking it to the agreement as a record. This is a snapshot in time. So today, David Hempel says

Jake:

Can I can I interrupt real quick and just clarify a couple of things real quick? Okay. So let's name your business as widget company. Alright? So your widget company sells widgets, and David Hemphill is signing up as a person who is going to be selling your services, essentially.

Jake:

Right? Yes. So he is a person who is who is got a partnership with you, but now he is going to set up an affiliate program on his side to let me sell services that he provides.

Michael:

Is

Jake:

that the idea? But there it's actually you. Maybe it's like a white label service, so you could think of it like that. Something like that. Okay.

Jake:

Yeah. Because that helps me make a little bit of sense. So you're widget company a. David is signing up as a person who's going to sell products of widget company a. And now I, as a person who signed up, like, under David, am now an affiliate.

Jake:

And David, on his side, can set up a referral program, and there's fees associated with these different, referral programs that he's set up. Is that right?

Michael:

Yep. Yep. That's right.

Jake:

Okay. Okay. Alright.

Michael:

So I'm sorry.

Jake:

Could have multiple different types of referrals program set up. So he could set one up for me. He could set one up for his family where they get more, you know, if he wanted to, for instance, or

Michael:

Yeah.

Jake:

He could set up one that's just a, hey. If we you know, if somebody advertises on their podcast and we get a referral from them, then you get 5% or something like that. Right? So you can have multiple different things set up. Okay.

Jake:

Okay. Got it. I'm on the same page.

Michael:

So this so this, a referrer, David, sets his fees. There are 22 different ways that we can pay that we can pay fees. It's either a fixed amount between a range of things. So from, like, if you sell something between $1,000 I will pay you $100 referral. If it's between a 1,015,000, it's $200.

Michael:

If it's 5,000, whatever. Like, so they bracket the changes.

Jake:

So it's stepped. Yeah. A step Yep.

Michael:

Yep. Stepped or pressure. Okay. Yep. Yep.

Michael:

And then at the end, it could be, like, 50,000 to whatever we'll pay you, like and then we cap it at 500. So and

Jake:

Okay. Okay.

Michael:

So we don't handle the payments. All we're storing is these things so that, you know, based on what you refer to David, this is the payment that you'll be receiving for a successful transaction.

Jake:

Makes sense.

Michael:

Then we also do percentage based. So it's a percentage of the total amount up to some limit, you know, so we could say up to $50,000 So you send $1,000 we'll pay, you know, 2% of 50,000 of that $100,000. So these are the things we have. Now, as I said, we David would configure this in our platform.

Jake:

Okay. Yes.

Michael:

Specifying the ranges, whatever that these then become the defaults for anyone who signs up to his affiliate program.

Jake:

And what do you call these these bracketed or percentage ranges? What's the name for them? Is it fees? Is that what you're calling it?

Michael:

Yeah. So we've basically got, I think it's flat fee and percentage.

Jake:

Okay. And he then attaches a flat fee or a percentage fee to a specific referral program that he set up? Is that Yeah.

Michael:

So you have one program. This is like you this is what it always is. This is the default for anyone that joins. Now on a

Jake:

Okay. Her

Michael:

agreement basis

Jake:

Okay.

Michael:

It could alter that. So for a friend, he might increase it slightly for a podcast agreement. He might decrease.

Jake:

Yeah. Okay. So the referral agreement is what the fee is attached to sort of? Yeah.

Michael:

So so in that situation, we would void would it like, if the they sign up the agreement and it changes, we'll void the original agreement, create a new agreement to be signed, and executed with those values set on that agreement.

Jake:

K.

Michael:

So we we don't have to do any calculations. We don't have we're not responsible for for the payments or tracking, you know, we just say like, this is you'll obviously track payments have happened, but these are the numbers. This goes into a PDF that is sent to you that you signed that you sent back. And then that's the agreement in place. So where my, I guess, complexity comes in is for a referral fee that is attached to my referral account, how am I storing this?

Michael:

Now I've got a few different ways that that it can be done. We don't need to search on any of this stuff. So my first thought was let's just have 2 fields on the referral fees table. So we have obviously the the referrer account or the referral account. We then have a fixed or a flat fee and a percentage.

Michael:

Right? And these these are just JSON arrays. They're arrays of objects of, you know, the bracketed ranges, whatever. Mhmm. And so this was my first thing to do that.

Jake:

Referral when you say referral account, is that an agreement or referral agreement that you're saying?

Michael:

So David has a referral account.

Jake:

Used the word agreement a couple times. I'm trying to understand what agreement is.

Michael:

So David has a referral account, which says that he's a referral. And then the people that he has, affiliations with will have a referral agreement. You. So you will have a referral agreement. Got it.

Michael:

Chris Gmyr will have 1. TJ Miller will will have 1. Yes.

Jake:

Okay. And that

Michael:

will be separate.

Jake:

So David owns the account, and then he signs an agreement with me, the person who's going to be sending him business. Mhmm. Okay. And on that agreement is where you store the fees Mhmm. Or on the account?

Michael:

Yeah. So the account has the default both. Right? Okay. The account has the default values.

Michael:

When the agreement is created, we take the values that are default and we

Jake:

I see. Put them from

Michael:

there and then we so we copy them across, basically.

Jake:

That makes sense.

Michael:

So on the agreement, there is all, on the agreement, we do have another table that's like agreement fees, and we copy from Yes. The agreement Did you from the fees tables Yes. From the defaults to the agreement fees table, and that Makes sense. Together.

Jake:

Yes. That makes sense.

Michael:

Okay. So and then that just gets generated into a PDF one time. It gets saved. It gets attached to the account, and that's it. We don't calculate it.

Michael:

We don't have to do anything with it. It can be displayed in the account. This is your, like, active agreement kind of thing.

Jake:

Okay.

Michael:

But it doesn't change. Unless

Jake:

So once it's yep. Yep. I gotcha.

Michael:

So my my hold up here is how do I store this? And, you know, put it in the database. There there's there's 2 ways that I've thought about it. The first one is just JSON fields, 2 JSON fields on there that we just copy around. And then we pass those collection.

Michael:

Basically, it's an array of objects. So we have a Yeah. I started this out as just like a plain old PHP object, just a renoted class that had, you know, 3 values on it. I ended up rolling all that back and just using Laravel data because it handles all the stuff that I had to write for myself.

Jake:

Okay.

Michael:

So essentially, we have a data collection of flat fee in one field in the flat fee field. And we have a dot and then we just have like a flat object for the percentage. Because the percentage is just and I believe it's much easier.

Jake:

Yeah, right. There's no brackets to it. It's just you'd have the percentage and you have the cap.

Michael:

Yep. Yep. So this was my first thought. My second thought was, okay, we followed the Adam Wadden School of Thinking, we push polymorphism to the database, and we just have like a record that says, you know, this is the thing. And then there's another table that has the ranges, you know, minimum, maximum value, minimum, maximum value, and then and then a second table, which has all the percentage stuff.

Michael:

And then we just reference that those corresponding records in that table. And so we've got the poly so that when we hydrate the eloquent record or the agreement, we're just going to model it.

Jake:

Yeah.

Michael:

Yeah. And then we go out, we need to go create this data object over here. So it's it's basically how do we persist it and what are we comfortable with doing? Mhmm.

Jake:

So, you said that you're never actually gonna need to do any calculations with these. It's just for display purposes.

Michael:

Not calculating, not searching. It's just like we would go Well, then I feel like that makes a lot easier. Yeah.

Jake:

Yeah. That makes it a lot easier because, you know, there's not as much you don't have to, like, be able to pull it into some object object that can do a bunch of calculations and things like that if you throw a number at it. So if it's just for display purposes, as long as you will be able to, keep them the same, like, as as far as, like, what the object would look like over time, then you should be fine. Because if you ended up updating it, so, like, let's say, like, okay, well, now there's a we need to add a new one that's like, well, this is the minimum amount we'll pay out even 4 bracketed ones. Like, we'll pay a minimum of $100 even if you send a a referral that's only $500, like

Michael:

Yeah.

Jake:

Minimum of a 100, maximum of 500. Well, now you have this new minimum one to deal with and you didn't perform. So, but I guess in that case, you could just sort of have your, your view logic say, well, if there's a minimum display, and if there's not, don't worry about it sort of deal. So you could just use conditional logic to make sure you're displaying this. And I feel like that's probably gonna get you every every almost everything you need.

Jake:

And if you did need to change it in the future, you always could. You have the objects there. You could always eject and sort of persist them to another location. So my if it was me doing it, I'd probably just store them right alongside the database records initially. And then if I needed to later on change it out, I I would do that.

Jake:

But I wouldn't even worry about that until I got it started and got it working and make sure that people are using it and get some more insight into how it's being used and make all those other changes that they're gonna ask for before you get into a really, you know, normalized database situation where you might not need it.

Michael:

Right. Because then the the trick is always at that point where you've got, you know, the account, and then you've got the fees, and then the agreements, and then you also got, like, the flat fees and the percentage fees and all. So you've got, like, 5 or 6 models just to do all this stuff.

Jake:

And probably a lot of duplicated data, to be honest. The duplicated records. Like, there's probably gonna be so many, they're gonna be the exact same. Yeah. You know?

Michael:

And the thing is, if you go and change your defaults, when you post that form back to the server, we're not gonna try and, like, modify existing stuff. We're just gonna replace it with whatever you have sent and this is the new set. So it's not like we need to go and send a patch to, you know, slash flat fees slash one slash whatever. It's it's it's just gonna be take whatever was posted in the form, and that is the new canonical set of default values.

Jake:

Yep. And the other thing you could do too is you could put, like, a version number on the agreement if you wanted to. Like, if you wanted to do something radically different, you could say like, okay, well, moving forward, every new agreement that we make is going to be V2. And then our deck or not our decorator, I guess it'd be your decorator possibly could say, okay, we're looking at a v 2. So we know that it's gonna have these sort of types of values, and then you could just change out how you display it.

Jake:

So you could do that too. So, yeah, I think that gets you 95% of what you would want. I mean, I can't really imagine a scenario where that wouldn't work.

Michael:

Yeah. Because there's there's no like, we don't foresee this is how it's always been. It's either a flat fee on a range or it's a percentage up to some some threshold. It's it's never really changed. The thing that's bit us in the past with doing things like this is if the structure of the object changes, you have to be really careful about doing it in a backwards compatible way.

Michael:

So when you're trying to deserialize that JSON back into an object in in PHP. If the things don't line up, you can get into the situation where it's, you know, if you've got if you've got the state stored in the database in one way and you've added a new required field, you know, you have to make sure that that new required field is nullable because the stuff that's already persistent in the database doesn't know about it.

Jake:

Have it. Yep.

Michael:

So that's one. The other thing that's bit us in the past is when we try to move classes around. So they were in one one namespace. We tried to move them to a new namespace. Obviously, everything that was previously persisted with a reference to that specific path was now referencing something that wasn't there.

Michael:

And so it tried to hydrate that object, and that all blew up. So the the Sparsie Laravel data package does have similar to morph maps with eloquent, you can map strings to classes.

Jake:

Nice.

Michael:

Okay. There's some hesitation in in the team, like, do we really want to be putting more JSON in the database? Or like, polymorphism is more I suppose, you know, with separate models and things like that, a more designs like slash structured approach, I think ultimately, you end up at the same destination. In that, you know, you are storing, you're

Jake:

just trading complexity,

Michael:

you're trading complexity, you know, otherwise you end up with, like I said, you know, there's 5 or 6 models, and then there's 5 or 6 tables, and you've got these tables that basically just have 3 columns in them that are just values. I don't think given that this is, you know, 90% display only I don't think it needs to be you know, split out that way.

Jake:

And that's why I would just make the argument to the team to be like, listen, let's just get it shipped. Let's get it out in production with this this simpler version of it. And then if we need to make it more complex, we can. There's nothing holding us back from doing that. But, like, at

Michael:

least think about it.

Jake:

Yeah. Let's ship the simplest version of it. And then if it needs that additional complexity, if it needs that additional, you know, I mean, not type safety, but I kind of, I guess, a little bit, and you can attach some behavior. But, like, the thing is you're serializing, You're gonna cast those things to those objects. Right?

Jake:

When you pull them back out of it. So it's like, I really don't know. I don't know that you gain that much other than saying, like, if you change it in the future, you're gonna have maybe a little bit, you feel a little bit better about it because there's just sort of a loose structure right now. But I don't know. It seems it seems like it seems like shipping it just in the database and that same table is gonna give you what you need.

Michael:

Yeah. I like I I get the, like, you know, this has bit us in the past. I don't think like, what we did in the past was kind of gnarly because we had like really big objects that we were serializing in into the database. And we only only move things once and moving at once was enough of a problem for us that that's where we put the, you know, the map in. So we can always change what object is hydrated based on the the string, which is which is fine, but the complication is, you know, versioning that thing and making sure that you're not introducing, I know that Stripe does, you know, the version of their API.

Michael:

So they kind of like transform the thing through the different versions as you go up. Yeah. Yeah. Which is, you know, it is a level of complication that we probably don't need to introduce. I think if we were to just go, you know, everything that that is done has to be additive.

Michael:

You know, we can't remove fields. We need to add fields that are nullable by default, because there may be things in the database that don't support that structure. You know, being mindful of that is probably better than, you know, tying ourselves to database, like, you know, extra tables.

Jake:

Or Yep. Yeah. There is a way. There is a way. I don't remember.

Jake:

Aaron Francis talked about it at one time where there is a way to set up something that will enforce JSON schema. Yeah. Yeah. Virtual calls, but there was a way to enforce JSON schema inside of the meet MySQL database so you can ensure that the schema stays the same. So it basically gives you a little more confidence.

Michael:

Column. Yeah. Yeah. I know someone someone that submitted to speak at Laracon this year, and I said, there's no way you were doing this. But they suggested like putting SQLite databases inside of

Jake:

my SQL.

Michael:

Inside of MySQL columns.

Jake:

I mean, that's literally here's the crazy thing. What's old is new again. I mean, we have this at work. The legacy database that we're working on is called universe database, and it's multivalued columns. And so you have columns inside of columns.

Jake:

So you have like table, you know, you have the debtor table with attribute 15, because they don't have names. They just have numbers. Yeah. Yeah. Attribute 15 multi multi value 3.

Jake:

So it's like, it's a 3-dimensional table. It's not like a 2 dimensional like we're used to. So, you know, yeah, it's the same. It's so funny. And so when I, when I talk about when I talk to the old graybeards there about, like, you know, NoSQL stuff, they're like, oh, you kids are just reinventing what we've already had for years.

Jake:

We do what

Michael:

we're doing. Yeah.

Jake:

Yeah.

Michael:

But this this talk came through, and I messaged it. I'm, like, I can't be responsible for you putting this out into the world. Just

Jake:

It's funny.

Michael:

We we're not doing it.

Jake:

But I so, like, I say that because, like, if the if the fear is, oh, they're gonna be inconsistencies or whatever, like, you can get around that. There is a way to enforce to enforce to make sure that the JSON schemas is, isn't enforced on that on that column. The other thing you could do if they're really if they're really sensitive about it or really worried about it is you could just store along with that, that particular thing. You could store a version number and then you could have when you deserialize it, or, you know, cast it in the database, you could have it automatically look at the version and then and then do a different casting or a different version of the DTO based on that. So Yeah.

Michael:

And there's, like we don't even have to put a version number in there now. If it becomes problematic, we can put it in there and figure out how to make that work later. Like, if there is no version field on this DTO, then we can just say, well, we don't don't need to worry about it. That's like version 1. And then everything after that, then, you know, if we do need to change the structure, then

Jake:

to have a version.

Michael:

Yeah. Yeah. But I think, you know, through the we'll do the testing, you know, and build out this first version and just say like this is version 1, we'll figure out pretty quickly if it's problematic or not. We've done it in the past, making them these light Laravel data objects means that we can type type them, which means when they go back to the front end, which is built in React, they have,

Jake:

oh, okay.

Michael:

Yeah. Type safety and all of the completions.

Jake:

We did that all the

Michael:

way through. So you

Jake:

guys have got to generate the time

Michael:

to back

Jake:

to the TypeScript object. Nice.

Michael:

Yeah.

Jake:

That's pretty cool, actually.

Michael:

So I don't have any understanding or comprehension or even wants to know what the heck is going on in the front end. So I have to say that I just need to attach some attributes to these data objects, and then then they get what they need on the front end. And then I just back into the shop. Off. Yeah.

Jake:

Well, cool. That makes a lot more sense to me now that you explained it that way. Yeah. I think attaching, like, the personas to the different, you know, parties in the system helps make a little bit more sense of it. So

Michael:

Very good. Yeah.

Jake:

It was, when you were talking about it the other day, it was, semi clear. Yeah. But it makes more sense

Michael:

to not I was actually in the in those one way kind of things as easily. So Yeah.

Jake:

Yeah. I was actually I

Michael:

just sit in the middle I just sit in the middle and hold all the database records. Right? And then it's people come through me.

Jake:

Yep. Yeah. Exactly. So I was when you were asking that question on, on Telegram the other day, I was taking Harrison out fishing. And so he's been on a big fishing kick recently.

Jake:

There is a pond by our house, and there is a spot right by the edge of this pond where a tree overhangs the water. And so it's a shaded spot. And I think there are like ants and bugs, like in this tree that will drop off the tree into the water there.

Michael:

Yeah.

Jake:

And so there is just a bunch of fish. Yeah. A bunch of fish there. And so it's not even real fishing. I mean, I take him there

Michael:

and I'm not kidding. He's not hotter.

Jake:

I'm not kidding. He literally puts a hot dog on because I found out hot dogs are much easier to let a kid bait than worms because they don't like the, you know yeah. Whatever.

Michael:

It's not like a worm. No. It's just a hot dog. Exactly.

Jake:

It's just a hot dog. And so he will barely even drop the hot dog in the water, and he doesn't even cast it. He literally puts the pole in the puts

Michael:

it in the water.

Jake:

The bobbers there, and he literally just he doesn't reel. He just pulls them up. And it's crazy how fast they catch them. He catches these things. And so he just wants to go fishing all the time because he just catches them one right after the other.

Jake:

But he's learned how to put the bait on now, and he's learned how to take the fish off by himself. Hold it, you know, put, put the spikes down on it, you know, the fins down and, you know, the dorsal fin or whatever. And, and so he's got all that figured out and he caught a bass the other day, which he was really excited about. But, the little lesson that I learned also while I was there is I've been drinking liquid death recently. So I gave up soda for the year.

Jake:

You know what liquid death is? Have you ever heard of it? No. Okay. So it looks like it looks like a tall boy, like beer.

Jake:

It looks like a big Right. Beer can. Okay. You know, those tall Yeah.

Michael:

Yeah. Can. Yep.

Jake:

Yep. Yep. And so,

Michael:

a can or a bottle?

Jake:

It's a can. Hold on. You want me to show you? Okay.

Michael:

You want me to show you what it looks like? Yeah. Yeah. Show show the show the viewers.

Jake:

Hold on one second. I'll be right back. Okay.

Michael:

Riveting podcasting, by the way.

Jake:

So this is what it looks like.

Michael:

Right. Okay. So yeah. Yeah. Gotcha.

Jake:

So it looks like it looks like beer is what it looks like.

Michael:

A billion here.

Jake:

It's just water.

Michael:

Right.

Jake:

It says murder your thirst. That's, like, their thing. And they had to name this one. This one used to be called armless Palmer instead of Arnold Palmer, lemonade

Michael:

of tea.

Jake:

But Arizona tea threatened to sue them if they didn't change the name. So, like, screw you. We're calling it dead billionaire then. And so Arnold Arnold Palmer was a golfer, you know, whatever, dead billionaire. That was funny.

Jake:

But, anyway, I took this I took this with me fishing the other day when there was people walking by or whatever, and Harrison was taking drinks of my water. And I think people have thought that he was drinking a beer because one of the kids walked by and he's like, hey. Can I move your dad's beer? And he was like, oh, that's not Harrison's like, that's not beer. He's like, it's just water.

Jake:

He's just like, oh. Mhmm. I'm pretty sure they thought that I was just letting my kid drink my my 7 year old drink a beer.

Michael:

That's pretty funny.

Jake:

So, anyway, I'm having to be more careful about where I take this stuff. It's super good. I've I've been drinking a lot of it recently, but, that was funny. Anyway, yes. Okay.

Jake:

So we can get to, my thing.

Michael:

So I don't know if I wanna

Jake:

I don't know if I wanna, like, blow the top off this. There is a thing that Xangle created a while ago.

Michael:

Mhmm.

Jake:

And they didn't actually create it. I requested early access to it, but it's called my user dot guide. And it's not like a secret. It's out there on the web. It looks really cool.

Jake:

It's basically team profiles for your teams. Right? So just like Mhmm. They can, you know, it's a very, very simple it has like, hey, here's my fit. Here's my social profiles.

Jake:

Here's a little info thing about me. Here's what team that I'm a part of. Here's some questions that I answered. Here's some personality profiles that go along with me. If you use, like, the Enneagram or use widget or you use the disc or whatever.

Jake:

So different companies use different things sometimes. Right. And so there's been recently this this push by our, people resources team to add some things like, so we've done done these personality tests, and they're like, you know, we've we've spent a lot of time teaching on this. We'd really like for people to be able to see, other people on their team, their their personality profile stuff. And I'm like, okay.

Jake:

Well, there's no great way to do that in teams, and we don't really have, like, a profile thing for our people. And so I was like, let's just build this. Let's just actually build it. Because I reached out to, Jesse Schutte about this, like, years ago. And he was like, yeah.

Jake:

We sort of put it on the back burner. We're not really doing anything with it. So that, like, literally, it was probably 4 years ago, 3 or 4 years ago. And so I'm like, screw it. So I just gave it to my guys internally.

Jake:

I was like, hey. Make this. Like, do this. And so we're working on it. But if you go to, like, the if you go to I could send you the picture.

Jake:

There is a part that has a questions library public profile. You can see the public profile. So what you'll see is, like, on the left hand side, there's, like, their picture and stuff, and a column on the left, like, a 1 third column on the left has, like, their picture, their socials, and then the little the little about me. On the right hand side, 2 thirds column on the top, it has, like, any personality profiles that you've filled out that they've filled out for them. And then underneath that, you have answered questions.

Jake:

Okay?

Michael:

Mhmm.

Jake:

So this is the challenge. How do you allow the person to edit their profile, and the questions? Right? So with the profile, it's easy. You just allow them to edit their social links, edit their location, edit their about, maybe a website if they have one.

Jake:

That's it for the profile part.

Michael:

Yeah.

Jake:

But like, do they edit that separate from the questions that they answer? Like, are those 2 separate things? You know? Because the questions are not questions that you just make up about yourself. Mhmm.

Jake:

They're like, you know, you could add new questions. You know? So it's probably like a a database that has here's the questions. Right? And then you have a relationship between the questions and the user and an answers table.

Michael:

Mhmm.

Jake:

Right? So question user in the middle, you have answers. Right? So it's the answer to that question. It's a pivot table, basically.

Michael:

And so creating the questions, are they, like, is it standard questions?

Jake:

Okay. That we create.

Michael:

So it's like, yeah. So you create is the 10 questions or something, and people can Yes. Answer them.

Jake:

Go answer them.

Michael:

So that would only display if you have an answer for answers. Yeah.

Jake:

Yes. That's right. Right. And if you wanted to answer more of them, you you could probably answer as many as you want, like, up to, like, you know, you could either limit it and say, like, pick your top 5 or pick 10, or if you've answered all 10, then you can display all 10. But I'm just trying to think about, like, the actual user flow from being on their profile page, which is what they're probably gonna see when they hit their default home page.

Jake:

It's gonna say, like, here's your profile. Yeah. Or it might show their team dashboard or something. I don't know. But then in case, when they wanna edit their profile, they're probably gonna go to their profile and they're gonna click edit somewhere.

Jake:

Right? So in my brain, I'm thinking like edit profile is just those pieces, like my socials, my about me, my location. And then questions is probably something separate. Like, over on the bottom right hand side where they're displaying the questions, you'd probably just have, like, answer questions or something like that.

Michael:

Yeah. Like, it depends on what you call them, like, my profile or my questions or my answers, really.

Jake:

Mhmm. Right. It is my answers. Yeah.

Michael:

Or about me, you know, what whatever you you call that. I'd probably put it as a like, a separate tab or a separate page that they can get to. Mhmm. And then that really is just a form of, I guess, you know, all of the questions with a text area underneath that, you know, they put their answer in. And if there is an answer, then you display it.

Michael:

And if not, it's just an empty text box. And then when you save it, you just, you know, filter out wherever the answers are and create the records or update the records.

Jake:

Yeah. I sent you a picture here. So, like, you can see kinda how the profile looks, and we can throw this in the show notes too. Mhmm. But you can see kinda, like, how the answers are on the bottom right hand side of the page there.

Jake:

So they have, like, answered questions. So, like, what I'm wondering is, like, do I put an edit button up by answered questions and say, like, edit your answers or something like that, edit answers, and then it would show you, hey. Here's the ones that you've answered so far. Here's the ones you haven't answered. Right?

Jake:

Maybe, like, answered questions and then, like, questions to answer. You know, something like that, like, sort of separate them. So, like, if they click answer more questions, it would show, like, a question library or something like that for them.

Michael:

Yeah. I'd I'd certainly, like, order it so that the questions they have answered are first

Jake:

At the top.

Michael:

And then anything else is at the bottom. Mhmm.

Jake:

I feel like it would be better for me, like, if I was the person wanting to see it, I wouldn't wanna have to go and answer each question individually. I wanna be able to just, like, on that page, fill out any of them. Like, see any of the answers that I have just sort of in line, and then just have blank text boxes for any of the ones that I don't yet have.

Michael:

I mean, is this the where we bring back, like, click to edit for each one?

Jake:

Actually, yeah. I mean, right? I mean, you could Which

Michael:

is something I could just make this a live way. Yeah. I've been in Salesforce lately. And when you, like, double click on any field, it changes the whole thing into an editable field. Like, the whole page, the whole form becomes an editable field, and then it converts all of the, you know, the the text, the spans or whatever into text areas with the same stuff or inputs with the same stuff.

Michael:

So you could just, yeah, double click on it, and that would convert the the text to a, to a text area. I think the trick will be with the questions that have not been answered yet. Like, do you just always display a text area for those ones?

Jake:

Right.

Michael:

With a placeholder of, like, you know, tell us what you think about this or, you know Yeah.

Jake:

To be honest with you, I I feel like I'd almost I feel like I could almost do something, like, just show the questions and any answer that they have. Like, if they have an answer, show it in a text area.

Michael:

Yeah. And then when they press save

Jake:

on the page, it just saves whatever questions they've answered and removes any that they haven't.

Michael:

Yeah. I mean, if it's a live way thing, you could just, you know, unblurb or an update that that field.

Jake:

Totally.

Michael:

It it may be a case, right, that you when you create the profile, it just goes and inserts all of those answers as empty.

Jake:

Yes.

Michael:

And then you filter, you know, you filter only the answered questions to display all of it like the public profile. But if, you know, if it's if it's the user that's logged in and going to okay, just show all as text areas, and then when they blur, you know, whether it's a a form with all of the things in it, or they're their own individual forms. I don't know. It's 1 half and it doesn't, you know, flip flip the coin as it were. Yeah.

Michael:

Yeah. If you if you're viewing your own page, maybe it just makes sense to make everything your text area, especially if you pre create the answer records

Jake:

Yeah.

Michael:

When you create the profile.

Jake:

Right.

Michael:

Otherwise you otherwise, you have, like, this murky thing where it's, like, okay. This top section is the questions that you have answered. If you want to edit the answer, you've got to click on it, and then it changes it to a text area. You've got to, like, save it, or you're gonna have an edit button or something like that. And then you've got all of these text areas at the bottom.

Michael:

So it's a disjointed user experience.

Jake:

Yeah. I'd feel weird. Uh-huh.

Michael:

So, yeah, it's either everything's a text area for a logged in user so they can go and sit, you know, edit their stuff, or it's just the text if it's a, you know, and then or the alternative is that it's all just text. And then, know, below the fold or wherever it is, you know, you have 5 unanswered questions, and you click edit, and it turns the whole thing into an editable form.

Jake:

Yep. Yep. Edit answers, and then and then at that point, it just shows them. Yeah. Yeah.

Jake:

I think I like that. I think I want yeah, because I wanna keep it just super simple. So I have my I have my brand new junior developer working on this, and I think he's really needing some clarity on exactly what direction to go because I just sort of threw it at him. Like, hey. There's some designs for this.

Jake:

Just go make this. Yeah. And so it's crud. It's very crud. You know?

Jake:

There's not a whole lot to it, but I think he's struggling with, like, the structure. Like, how do I do this UI? So right now, what he's got is he's got a different page for each question to answer. You know?

Michael:

Yeah. Definitely wouldn't do that.

Jake:

No. I don't think

Michael:

that like wizard or whatever. I think it's all on the same page.

Jake:

I agree. I agree.

Michael:

And like I said, if it's light white components, you know, the component the component can just be, like, you know, on the mount, it takes the question and the answer. Yes. Exactly. And then yeah. So you just got, like, 30 of these on the page.

Michael:

And then when you blur or whatever, you just I I think that will be the trick, is how do you save it if they're individual components. Because someone might type something in there and then, like, just go away from the page and it doesn't save. And that Yeah.

Jake:

You'd wanna would

Michael:

not be ideal. That

Jake:

So You don't wanna, like, you don't wanna, like, save it in the middle of them typing either. Like, you don't wanna, like, debounce it and then save it because they're not you know, they're halfway through an answer in public. It's all of a sudden the public profile or Yeah.

Michael:

Where they're just kind of, like, putting their thoughts down, and they haven't saved it yet. And then, you know, they press enter on action, it saves

Jake:

it or something. Like, you'd wanna So I think it

Michael:

probably needs to be explicit and explicit save. But then you've gotta figure out where you know, you're gonna have effectively 10 form forms on the page that have all

Jake:

been done. I think

Michael:

what I'd do then I think what I would do is I

Jake:

would probably have on each question, if they've answered it, I would show their answer, and I would I would have an edit button. But the edit button would just do basically change it into a text area, and then you'd it would become a save button, something like that, or you'd have a save underneath it. Yeah. Yeah. I think that's what I'd do.

Michael:

Yeah. So I think

Jake:

They can expose the edit and show them all at the same time. If they wanna edit them, they can just click edit.

Michael:

Yeah. Yeah. I think for consistency of of experience, when you create the profile, create all of the questions, create or create all of the answers with nothing in them. And then when they go to this page, they can edit on that page and it just gives you the text area. If there's text there, it'll show it.

Michael:

If there's no text there type, and then everyone gets their own little save button. So it's an explicit, okay, I'm ready to say if I finish my thought. Go. Yep. Kind of thing.

Jake:

Yep. Yeah. I think that works well. That. So I'm actually pretty excited about it because I think it'll we've wanted to do some of this stuff for a while where, like, we have people who have been here for quite a while, and they'll go through different departments.

Jake:

Like they'll go from, you know, the support team to, you know, they'll go from like our subrogation support team to, like, our claims examiner team. And then they'll go from there to, like, a production role where they'll be, like, in our core team, and then they'll graduate to, like, a frontline adjuster, and then they'll make it a full budget adjuster. Like so it's like it would be really cool to be able to, like, see their progression through the company, but we have nowhere to store any of that information. We have nowhere we're keeping track of any of that either. And so

Michael:

HRIS.

Jake:

I don't know what

Michael:

resources information system.

Jake:

Ah, there you go. Yeah. Well, I suppose they do keep track of it. They do have some of that, actually. Yeah.

Jake:

But, we just recently got the the API working for that thing. That was a freaking nightmare. Dude, I spent half a day trying to figure out why I could not get authenticated with their API. And then there was some obscure spot where, like, oh, here's the API token, but you have to put the word bearer in front of your API token in order for it to work. Like, you're kidding me.

Michael:

Yeah. Authorization has has to be bearer space token.

Jake:

Yeah. Yeah. Which I use for, like, if I'm doing a Laravel way you know, in Laravel and but it's like, this one, it's like you're literally using their demo page where they're like, hey. Try out our APIs. And then it's like, put your API key in.

Jake:

It's like, oh, okay. I'll put my API key in here.

Michael:

They're like, well, you have to

Jake:

put the word bearer in front of it. It's like, why? You know I'm putting my API token in. Yeah.

Michael:

Why don't you check

Jake:

and see if I have the word bearer?

Michael:

That's right. Look. There is a bearer space. If not, then just just stick on the

Jake:

front. Exactly. So anyway

Michael:

I mean Well,

Jake:

this has been helpful. I appreciate it. Yeah. I'll keep you updated, and, shout out to those guys at Xangle. If they do end up creating this, I will probably be a customer.

Jake:

I've already requested early access a long time ago. So not trying to rip you guys off. Promise. I just really love your design and love the idea. So we're

Michael:

Worst case, we're not selling it. Out to Jesse and and Phil.

Jake:

Be like, hey. We've got something started here. Yeah.

Michael:

We built this thing.

Jake:

Should we have it?

Michael:

Should we just, like can we put this up here?

Jake:

Yeah. Yeah. Yeah. Because it's not gonna be public either. It's really only gonna be internal.

Jake:

And, like, I have a, it's cool. Like, I'm actually going to have internal DNS of wilber.me/thenameoftheperson.

Michael:

So I

Jake:

think that'll be pretty cool. So wilber.me/jakebennettorilber.me/michael Durinder or whatever. You know? Mhmm. And so, it's you know, nobody on the outside will be able to resolve it because wilber.me doesn't

Michael:

I don't know if that's

Jake:

a we I certainly don't own it. No. So anyway You know,

Michael:

if you you own the internal DNS for everyone, then sure.

Jake:

Right. Which we do. Yep.

Michael:

When it all at 10 dot 1 dot 1 dot 4 or whatever, and off you go.

Jake:

Yeah. Yeah. And you're set to go. Amazing. Alright, dude.

Jake:

Well, why don't we wrap this one up? 157.

Michael:

Is that

Jake:

what this one was? Thanks, everybody, for hanging out with us. Episode 157. Shownotes for this can be found at northmeetsouth.audio/157. Hit us up on Twitter at Jacob Bennett at Michael Drinder or at North South Audio.

Jake:

And as always, rate us up in your project. Catch our choice. 5 stars would be amazing. Till next time, my friends.

Michael:

We'll see you later.

Creators and Guests

Jake Bennett
Host
Jake Bennett
Christ follower, web dev designer @wilbergroup and @laravelphp fanboi. Co-host of @northsouthaudio and @laravelnews with @michaeldyrynda
Michael Dyrynda
Host
Michael Dyrynda
Dad. @laravelphp Artisan. @LaraconAU organiser. Co-host of @northsouthaudio, @laravelnews, @ripplesfm. Opinions are mine.
JSON vs Polymorphism and editable index pages
Broadcast by