Design Patterns w/ Mary Perry
00:00:06.68
Chris Morrell
All right, welcome back to Over-Engineered, the podcast where we ask the question, what's the absolute best way to do things we already have a perfectly acceptable solution for? Today, I am here with Mary Perry. Mary, you want to say a quick hello?
00:00:21.39
Mary Perry
Hello.
00:00:23.37
Mary Perry
That was very quick.
00:00:26.17
Chris Morrell
Mary ah ah recently gave a talk on design patterns at PHP NYC and is shortly in on October 30th, if you are in the Philadelphia area, you should come to PHP Philly and see the the second iteration of this talk. But before then, I thought it would be fun for us just to get on the show and talk a little bit about design patterns.
00:00:49.85
Chris Morrell
Do you wanna, do you wanna, would you like to do a little bit more of an intro or you wanna jump straight into the topic?
00:00:56.04
Mary Perry
Let's jump straight in.
00:00:59.90
Chris Morrell
I thought, I i think I am a self-taught programmer. I don't have a lot of formal training. And I think when we start to get into sort of formal terminology around engineering, I i definitely noticed my imposter syndrome kick in. ah ah And I thought that your talk in New York really was super helpful for me to start to like lay so overlay the knowledge that I have with like these these terms that are in the industry. And I'm curious, like
00:01:42.98
Chris Morrell
Uh, what was like, what was your, what was your main like interest or what, what kind of led you to think like, this is what I want to talk about. what This is what I want to give a talk about.
00:01:54.88
Mary Perry
I think i I have a bit of imposter syndrome too. didn't finish my degree and I think that I wanted to have taken more classes than I actually got to. So I thought that going through design patterns while getting deeper into Laravel internals and trying to read code at the same time would be an interesting way to do it. But the thing that really kicked it off was I was building a, a, ah well, I'm still building because I got very sidetracked and they're very understanding people, but I was building a jobs board for the local tech meetup that I have.
00:02:31.80
Mary Perry
And I promised them that I would use socialite to use a Slack logon in.
00:02:32.54
Chris Morrell
Okay.
00:02:37.94
Chris Morrell
okay Okay.
00:02:39.57
Mary Perry
So I was doing all the things of Laravel so great, everything's out of the box, you don't have to worry about anything. It turns out that there's not a very obvious social social aid provider for slack, but I had already really talked it up.
00:02:56.38
Mary Perry
So I had to figure it out somehow. And, uh, so I got into extending social light to make a slack provider and got deeper and deeper into source diving with that and was noticing that it is, uh,
00:03:05.32
Chris Morrell
Okay.
00:03:14.29
Mary Perry
a pretty solid example of an abstract factory pattern.
00:03:18.58
Chris Morrell
Okay.
00:03:19.44
Mary Perry
I'm not entirely sure like when when that clicked for me, but I think that it was just generally trying to understand dependency injection and factory patterns at about the same time and then being like, oh, this is actually like a factory within a factory.
00:03:33.04
Mary Perry
And then i I was also very curious about the the service container and service providers because they're not the easiest concept to grasp.
00:03:44.04
Mary Perry
for me.
00:03:44.35
Chris Morrell
Sure.
00:03:45.56
Mary Perry
so then that started to get deeper and deeper into like, what is the service container? And it just really spiraled from there. I ended up reading a lot of the design patterns book, a lot of source code, and I've written at least two talks.
00:04:01.73
Mary Perry
So it was dense.
00:04:03.00
Chris Morrell
At least. Well, i I saw, I mean, Joe and I were joking that we, we saw like six talks in New York. It was so much information. It was dense, but it was great.
00:04:13.01
Mary Perry
It was dense.
00:04:15.70
Chris Morrell
can you Do you think you can summarize the abstract factory pattern, or is that too much to to ask on the spot?
00:04:15.48
Mary Perry
Thank you.
00:04:23.49
Mary Perry
Well, a factory pattern, a concrete factory pattern, is a pattern that's a creational pattern that creates variants of a similar product. And an abstract factory pattern is basically a factory pattern that creates factories.
00:04:41.72
Chris Morrell
I see. Okay.
00:04:43.14
Mary Perry
So it's kind of interesting because the example in the Design Patterns book is, I think, a widget factory.
00:04:51.01
Chris Morrell
So helpful.
00:04:51.13
Mary Perry
And it was difficult for, yeah, because, you know, widgets, right? I don't even necessarily understand what a widget is, except that I think that it's some type of component.
00:05:05.71
Chris Morrell
Well, I think a widget is meant to be a thing that that doesn't exist. It's purely for like example purpose.
00:05:14.40
Mary Perry
Right. In economics, it definitely is. In this, I think it's somewhere between that and like modals.
00:05:21.35
Chris Morrell
Mm-hmm, like a thing, yeah.
00:05:22.14
Mary Perry
It's very confusing. I don't.
00:05:24.62
Chris Morrell
Okay.
00:05:25.65
Mary Perry
Yeah. But like a factory that makes widgets sounds kind of like the setup to a joke to me as an economics major.
00:05:32.02
Chris Morrell
Right.
00:05:32.96
Mary Perry
But being able to see the pattern used in socialite so closely to how the book actually presents it was very and illuminating. It made everything seem a lot more useful to read and to um dive deeper into.
00:05:49.84
Chris Morrell
Yeah, I mean, that was definitely the the biggest takeaway from me watching your talk was just like, you know, I've looked, I've looked at the socialite source code, right? I've looked at the, the service container. I've looked at how Laravel instantiates, you know, uh, cache implementations or, or, session implementations, stuff like that.
00:06:14.14
Chris Morrell
And i you know i I broadly have a ah ah vague understanding of like the idea of a factory factory pattern. and But to kind of see these more formal definitions of of these patterns and like sort of the so the way they are structured when they're like being talked about as patterns, you know the ah often in these like very abstract terms or very vague terms like widget. And then to actually like look at that in the context of a thing that I already understand, which is socialite or or you know the way that the sessions are implemented. It just like made it click so much so much more. And so like in the in the case of socialite, so we've got
00:07:05.07
Chris Morrell
We've got providers, right? different Different providers of authentication like Facebook or in your case, Slack, right? And those those providers, are those providers then factories?
00:07:20.13
Chris Morrell
They are responsible for instantiating like a socially authenticated user object. Is that is that how that works?
00:07:28.34
Mary Perry
Yes.
00:07:30.66
Chris Morrell
And so then,
00:07:30.86
Mary Perry
That's how I understand it.
00:07:34.19
Chris Morrell
Each one of those uses a different mechanism to give you back a single, this is ah this is a representation of a social login, right?
00:07:45.34
Mary Perry
Yes.
00:07:45.86
Chris Morrell
And so there's a second layer on top of that, which is how do we get the thing that does that? And that's what makes it an abstract factory is there's the system that has to instantiate the Slack a provider or the Facebook provider or the Twitter provider. Okay. Yeah. I mean, fundamentally that's not that hard to understand, but when you, if you said to me as trifactory pattern, I just kind of look at you like, okay, maybe I'll get it in context.
00:08:21.35
Mary Perry
it's it's a It's an interesting terminology. And then the difference between the actual family of products it refers to it as a family of products is usually just like an OAuth token for a given provider.
00:08:33.45
Chris Morrell
Mm-hmm.
00:08:34.23
Mary Perry
So that's like the main difference.
00:08:34.68
Chris Morrell
Okay. Right. Right. Yeah. Sure. I think, another big thing that came out of, uh, your, both your talk and like, and just like the conversations that I ah had afterwards, came down to.
00:08:53.95
Chris Morrell
that this idea that the patterns themselves or like the the specific way one goes about implementing one of these patterns or like the sort of the formality around them is less important than the fact that we have names for these things that let us sort of communicate to each other a more complex idea because like you know that And that makes so much sense. It's like, once I know, once I like internalize what an abstract factory is, it's a lot easier to say, like oh, you know using an abstract factory here makes a lot of sense instead of saying, like oh, we should do the thing, you know like the thing that they do in socialite where there's like a thing that creates a thing and then that thing creates another thing. you know it's just i I think that
00:09:47.79
Chris Morrell
In a lot of ways, it feels like design patterns can be weaponized against people who, you know, if someone doesn't feel like a developer is doing something the right way, they'll they'll reference design patterns as sort of like, well, this is what the this is what you're supposed to do. And I think that that gives them, that can give them a bad name. And I think in particular in the Laravel community, that has been the case.
00:10:15.46
Chris Morrell
but i i It feels like that gets around what the real value is, which is just a common language to talk about complex ideas. Does that feel true to you?
00:10:29.77
Mary Perry
that's definitely my opinion. I know that not everybody has the same opinion about it as me. And maybe part of it is that I'm a little bit, that I experienced imposter syndrome and I feel a little bit on the outside looking in, naming things is famously difficult. And I think that a lot of times that I've seen more canonical implementations of design patterns, I thought,
00:10:56.83
Mary Perry
this is not how I would write something. And when I see code working in like a Laravel application or kind of deviations in Laravel source code, I think that it still solves problems in a really wonderful way, which is, I think, the other core of design patterns or the argument that design patterns make is that like these are ways that have worked to solve a problem. And so we should reuse them as opposed to you know kind of winging it and seeing what happens.
00:11:27.29
Mary Perry
But design patterns is pretty specific to Java, and it's pretty specific to an era of Java code. And it's great that the Gang of Four has all these works like clean code is another interesting one that I think has great things to say about naming things. And refactoring has a lot to say about naming things. But a lot of times in a real world application, you have to wing it a bit to get it to work. I was just reading a book today, actually.
00:11:59.84
Mary Perry
I forget the name of it. I think it was Architecture of Complex Applications with Examples in Learvel Code.
00:12:08.56
Chris Morrell
Okay.
00:12:09.64
Mary Perry
And one of the earlier chapters starts off with software development is a trade-off between what works in the short term versus what works in the long term.
00:12:19.25
Mary Perry
And I think having names for how closely we're going to solve a problem can also help make those trade-offs. Does that make sense?
00:12:26.91
Chris Morrell
That's interesting. Yeah. No, I love that. That's such a good, it's a good way to describe it. And yeah, I do get, I get what you're saying. Like, I mean, it's kind of the same argument as, you know, like restful architecture or, you know, just conventions in general. It's like, there are a million different ways to approach something and like maybe one, sometimes one way is
00:12:56.24
Chris Morrell
has advantages over the other way and like you can take lessons that other people have learned and sort of not have to learn them yourself by just like following the convention. Other times conventions are are just useful because they're conventions it's just like if everyone is talking about it and thinking about it the same way it just makes it easier to understand. And so I can see making that argument for Yeah, there's a million different ways to implement like the creation of classes, and like of instances of classes. But if you stick to a few of these well-established patterns, depending on your use case and your like you know requirements,
00:13:43.25
Chris Morrell
you've put yourself in a position to just have an easier time discussing the code and and having new developers understand the code and like you just don't have to make up new language around that stuff.
00:13:57.96
Chris Morrell
So even if it isn't like, I can, so I can see the argument for like some of this comes from hard learn lessons. And I can also see the argument for just like, it doesn't even matter if it came from hard one lessons. It's like, if you, uh, you know, if you use a common language, it's just easier to communicate, right?
00:14:19.22
Mary Perry
And if you have a set of options to use to solve a problem that more two or more people in a conversation already understand what the big idea behind the term is, I think it makes for more interesting conversations. I think that there's a certain amount of understanding that happens in the Laravel community that at first to me was very intimidating just knowing what a package does.
00:14:48.36
Mary Perry
And I think the same way that I've been intimidated by design patterns, somebody says, oh, you could just use whatever example of a package, like, I don't know, Nova.
00:14:48.89
Chris Morrell
Okay.
00:14:59.42
Mary Perry
If I don't know what it is off the top of my head, then you know it can feel like I'm missing out at the beginning of a conversation that the other participants in the conversation already have like the vocabulary for.
00:15:12.36
Mary Perry
But the more that I learned about first and third party packages in Laravel and the way that Laravel works, the more I feel like I have like this cool language that I can talk about complicated ideas and the examples and variants that I've seen of those other developers very quickly. So I think that there's things that people who know design patterns would benefit from learning about in the Laravel community because most of the packages solve a problem that you're going to run into on a website. Like they're chosen because they're useful and because they solve things.
00:15:45.96
Mary Perry
And a lot of things that Laravel developers might want to know about develop design patterns to have similar conversations. But I don't think that it has to be like canonical. And I don't like the idea of you know using them to just show that you more know more about a particular idea than other developers. I think that if two people are on the same page, they're great. And if they're not, then it it probably doesn't matter too much.
00:16:15.62
Chris Morrell
Sure, yeah, yeah but that's an interesting that's an interesting analogy. i i I can totally see how that would be the case because because the sort of Laravel community has embraced, I don't know, just not just embraced, but there's such just such an abundance of really high quality packages for Laravel that like understanding what like what that, what the what the space of possibility there is. And you know know knowing like, okay, if I'm doing this, like there's these three packages that I should be thinking about. like it is It is like a similar form of knowledge to have to hold on to. It's interesting.
00:17:09.36
Chris Morrell
I was, uh, I was just, uh, I was just recording with Joe. Actually he's, he's doing a, this side projects, podcast. And, uh, one of the points that came up in that conversation that I hadn't, I hadn't exactly like, you know, it feels true to me, but I haven't, I hadn't exactly put into words was just this like kind of realization that.
00:17:36.49
Chris Morrell
you know So much of programming, so much of programming experience just comes down to having seen things before, having solved similar problems before and being able to like apply that knowledge to the new the new problem. right like I have dealt with you know I've dealt with social login before. right So I know that I want to reach for social aid. And I know that if there isn't if there isn't a provider for the you know the the third party,
00:18:11.34
Chris Morrell
that like i kind I kind of already know generally how I would go about implementing that just because like it's something that I've seen before. And it strikes me that that in a lot of ways,
00:18:24.57
Chris Morrell
One of the values of of these design patterns and like having names for these things is almost like that is very useful as an individual, but it ends there it's like we need we you need something else to kind of like have a shared.
00:18:44.79
Chris Morrell
to to have a shared experience of that, right? Because you and I might have both seen like an abstract factory implementation in socialite and have a pretty solid understanding of like how that works. But if we don't have the language to talk about that, it's it's kind of like,
00:19:11.16
Chris Morrell
Our knowledge is useless.
00:19:14.57
Chris Morrell
Uh-oh, it looks like maybe we're having an issue. Can you hear me?
00:19:21.88
Mary Perry
I can.
00:19:23.32
Chris Morrell
Okay.
00:19:23.67
Mary Perry
Can you hear me?
00:19:23.92
Chris Morrell
I, I can. Oh yeah. I just lost you for a second there. Did you? Okay.
00:19:29.94
Mary Perry
Okay.
00:19:30.03
Chris Morrell
Let's keep on going. I got a little, I got a little alert pop up saying that you, your connection might be, uh, gone, but I see you there. So we're good.
00:19:39.20
Mary Perry
Yeah, I heard wind outside and that's what it takes around here.
00:19:42.41
Mary Perry
Just like a little bit of wind.
00:19:42.84
Chris Morrell
Uh-oh. does that Does that make sense when i'm what I was saying like that that you know if we don't have a way to talk about this like knowledge that each of us has, then the fact that both of us have the knowledge is less useful to us?
00:20:03.45
Mary Perry
Yeah, for sure. I think, I mean, I have a book on OAuth too, without any kind of wrapper or any particular usage for it.
00:20:15.68
Mary Perry
I also have a book on, uh, Oh man, basically API patterns in PHP specifically, and guzzle.
00:20:27.19
Chris Morrell
Okay.
00:20:28.97
Mary Perry
And then comparing that to Saloon, I'm bringing that into the conversation. And I think that there are a lot of times in, when I was first learning Laravel and I didn't know about Saloon, I was gifted with a copy of Ash Allen's API book through Laravels, which is really fantastic.
00:20:33.36
Chris Morrell
Loves to learn.
00:20:49.45
Mary Perry
That's all I found out about that. But before that, I was trying to do things that are wrapped around Guzzle pretty clumsily. i i um and I've definitely written things in Python around OAuth2 that were just broken for weeks.
00:21:04.97
Mary Perry
Rissa Jackson in her talk about junior developers said, there's nothing wrong there's nothing worse than being stuck and alone.
00:21:15.10
Mary Perry
And I've spent like a lot of time on both of those topics being totally stuck and feeling super alone about it.
00:21:15.43
Chris Morrell
Mm.
00:21:19.43
Chris Morrell
Mm. Yeah.
00:21:22.69
Mary Perry
and Even if I was successful in doing something for a side project or a project at work that I'm not working with somebody else on and I get it to work, it feels like less of a victory than even like chiming in on Twitter to somebody else's success and being able to talk about how cool their success is. But something that I really enjoy personally being able to talk about is breaking things because I feel like when I break things in a lot of different ways, it shows me
00:21:53.60
Mary Perry
how the thing works and it gives me more of a sense of why other people's solutions are useful or why there are a limited subset of like correct ways of going about something.
00:22:07.32
Mary Perry
And those are great conversations to have too.
00:22:05.58
Chris Morrell
ha Yeah, that's interesting.
00:22:09.32
Mary Perry
I think I've broken like SQL alchemy and psycho PG2 with Python in all the ways that I can think of off the top of my head to break something. So if I found additional ones, I'm going to be happy about it, but that makes me feel like more confident about my ability to talk about it and more confident about my ability to to use it, even though I don't have that much outside validation for how proficient I am with Python. That makes sense.
00:22:37.41
Chris Morrell
yeah No, that makes a lot of sense. I think, uh, I mean, I definitely find that like, someone can tell me, you know, tell me the answer. Uh, but it, it's not nearly as satisfying to me as if I find the answer myself. And I think you're, you're right that like, I think part of that comes from like.
00:23:07.16
Chris Morrell
understanding how things can break, you know, helps you avoid breaking things in the future, right? Yeah, no, that's very interesting. Is there is there a particular design pattern that you like you know that you just particularly love or just like jumps out at you as just an elegant solution to a problem or just like an interesting approach to something.
00:23:39.32
Mary Perry
there's a lot that I like. That's kind of a hard thing to think about. I do really love the builder pattern.
00:23:45.83
Mary Perry
but I also like queries and databases in general. And I think the best canonical example of a builder pattern in Laravel, which I did not play in my talk because it's very straightforward.
00:23:57.50
Mary Perry
And I was doing this whole thing with middleware and the request cycle, which I'm going to have to go back and maybe look at again, is the eloquent query builder, which again is named very clearly. the examples that I usually see for the builder pattern online is like making a hamburger, which I don't really understand why that's the common example.
00:24:17.66
Mary Perry
Cause it's not the one in the and you don't use code to make hamburgers.
00:24:18.75
Chris Morrell
ah
00:24:21.32
Mary Perry
I don't mean like a hamburger menu. I mean like an actual hamburger, like ad lettuce is an example.
00:24:24.34
Chris Morrell
Yeah, yeah, I mean, I get how it it could be used as an example, right?
00:24:25.27
Mary Perry
je
00:24:29.95
Chris Morrell
You've got a thing that can be put together in a bunch of different ways. yeah I get it, on so on the surface it makes sense, but yeah, it does seem like a sort of a silly thing to use.
00:24:41.66
Mary Perry
Yeah, but I don't know. I just, I really liked the idea of having a chronological order of steps that you go through with variances in the steps. I tend to think of object-orienting programming as like recipes. Like when you cook something, you have the ingredients that you're going to cook with, you have the tools that you need to cook the ingredients with, or you're missing some and you have to improvise.
00:25:10.14
Mary Perry
And then once you have those as a basis, you need to perform actions, which you may or may not be competent in performing. And I think a lot of that, I think about that when I think about where I want a route to go or how I want to modify data. and the builder pattern kind of maps to that very directly. I think that's why I find it so appealing. ah ah You also need that for spells and programming is basically modern wizardry. So it's.
00:25:37.13
Chris Morrell
I love that.
00:25:38.02
Mary Perry
it
00:25:38.19
Chris Morrell
i I love that you picked the builder pattern because I think that was the one. I don't know that I necessarily had the name for it at the time, but I feel like that was the one time that like a design pattern, like a concept that was like, Oh, I'm like, I'm applying a specific pattern to like solve this problem. Like really jumped out at me was I'm trying to think of where, where we were using it.
00:26:11.71
Chris Morrell
i I don't know that it really matters, but just there's a there's a there's a point in our code base where there was just really complex, very conditional, very like varied logic. good example that I can think of, I don't know if this is the this is the code where I had the particular aha moment, but An example that I can think of is in our billing code,
00:26:40.77
Chris Morrell
we deal with both stripeauthorized.net and also paper invoices and free credits and e-checks and physical checks and all sorts of stuff.
00:26:55.39
Chris Morrell
And we also do monthly and yearly billing. We do invoice billing. we do just Our are billing scenario just is a nightmare. and But we have some unified models that we use internally to represent you know billing charge or a refund. or a subscription or, you know, whatever whatever you have. And I know that, you know, a good example of where we're using a builder pattern is in building up a subscription, right? and Adding, applying the correct payment processor, setting a subscription to monthly or yearly.
00:27:44.45
Chris Morrell
We have both like individual implementations inside of that inside of these builders and then independent builders that like are responsible for a subset of that work.
00:27:57.62
Chris Morrell
And it really is a way to take this incredibly complicated system and at least make each part something that you can reason about you know and like and and make it easy easier to reason about how all the different parts interact with each other.
00:28:16.84
Chris Morrell
And so I don't know, i don't all of that is to say, I feel like if you asked me the same question, I think I would say the same thing, that that that is my favorite design pattern. It's certainly the one that like kind of just, I don't know, it felt like it clicked in a special way for me as like, oh, this is when you have a certain level of variability and complexity, this is just like such a nice way to approach that problem.
00:28:43.20
Mary Perry
I think that it's also interesting to something that I spent a lot of my real estate and my brain thinking about when I'm not actually working. And I'm just like, you know, walking down the street or whatever is the different ways that you can address conditional changes in code and like the different ways that that direction can go. Like if statements versus nested if statements versus switches versus like a pipe. And I think that it's a really interesting thing to have in common with someone or to have a different opinion on when you're having a conversation about like, how do you think the most elegant way to address those changes are? Like, how do you conceptualize it? So I think that's very cool. I'm not sure if if statements or switch statements are the anti pattern, but I know some people think they're an anti pattern and other people think that they're not. And it's just a
00:29:36.98
Mary Perry
I guess I would have to know a lot of more about performance to know what the right way is, but to me, a builder pattern is an easier thing to read than other other ways of doing it.
00:29:46.76
Chris Morrell
Yeah. I mean, for sure. And like. the the places where like using an if versus using like a more complicated structure that abstracts the logic away a little bit, like the times when that performance difference really matters are so few and far between. you know like There are cases where it does come up, and I think that there are times, I think particularly ah ah a little bit of a,
00:30:16.94
Chris Morrell
oh I don't know if it's a pet peeve, but like a little thing that I find myself doing in the Laravel world in particular is, you know, we love our collections. We're obsessed with collections. We use collections everywhere. And I love collections. Boy, do I love collections. I use them all over the place too. I'm not i'm not saying that collections aren't great because they certainly are.
00:30:40.92
Chris Morrell
But boy, also, there's sometimes that just like a for loop. It's so much better. and it's And it's not even for performance reasons. It's just like it for code readability, for for just like the straightforwardness of the code.
00:31:01.81
Chris Morrell
you're not like importing a bunch of variables into context using the use statements like it just already is in in context like there's just there are a lot of times when just doing a good old plain old for loop is is just the way to go and in the same way I think there are plenty of times that just a simple if statement a couple if statements may be a match statement can be a great solution to a problem. Like sometimes you don't have to overthink it, but there's definitely a time when that that that becomes not true. Right. There's a time when the code, you just look at it and you just know, this is not, this is not the right solution anymore. I need something that maybe isn't going to be, you know, maybe it's going to be 14 microseconds, less performant or whatever. But like, I, I am going to be able to reason about it.
00:31:55.13
Chris Morrell
And that ends up being so much more important, right?
00:31:58.44
Mary Perry
and And that's so analogous to the iterator pattern, too, because as collections are an amazing example of iterators. And I think that the benefit of having an iterator with all those functions built into it, like the Laravel collections have so many built-in functions that you just don't have to worry about, is when you're trying to look at a group of data, which makes a lot of sense that it's like generally used with a
00:32:17.66
Chris Morrell
Yeah.
00:32:25.68
Mary Perry
a bunch of eloquent data taken straight from the database where you're going to have to look at it in different ways. And you want different methods of being able to interact with it versus like, am I looping through this once? And I only have to do it once. Then you probably don't need to overthink like what type of iteration you're doing.
00:32:41.94
Chris Morrell
Mm hmm. So iterator is is a, you know, I think of iterator is just like a concept. I wouldn't have necessarily classified that as a design pattern, but that falls in that under the umbrella of design patterns.
00:32:59.82
Mary Perry
Yes, and when I read the definition of the iterator and started to understand more of what is actually going on in a list, because I just thought of it as like, get the next thing in the list, which is I guess it essentially is, but it has more to do with a cursor and setting like the head of a cursor and then returning a reference to that. It took me like two or three days to wrap my head around it fully of going back taking breaks, going back, and like looking at it again.
00:33:29.91
Mary Perry
And then once I finally clicked, I was like, oh, why didn't you just tell me that from the beginning? It was really weird. But I always thought that iterators were just lists.
00:33:34.69
Chris Morrell
Hmm.
00:33:39.45
Mary Perry
But i I also didn't really understand until I read the iterator design pattern what a cursor actually is in relation to database retrieval or like in relation to the index of a database.
00:33:54.93
Mary Perry
and I think that that fully clicked when I read it too, but I don't know how useful any of that necessarily is. I think it was just like a fun aha moment, mostly. I'm not doing like a capitalized real programming that I need to have that kind of performance really on anything. so
00:34:15.98
Chris Morrell
Well, I don't know. i So what what is a cursor? I i mean, i i have a I have a functional understanding of a cursor, but I don't and don't think and don't think I deeply understand the concept.
00:34:29.77
Mary Perry
Well, I really hope that this is right because I am self-taught. So take it out with a great assault. But the iterator pattern is also known as the cursor pattern. And but a cursor is a reference to an ID, basically.
00:34:45.12
Mary Perry
So in other languages that I've worked with, the IDs or the indexes on a list aren't necessarily as explicit.
00:34:45.58
Chris Morrell
Okay.
00:34:53.09
Mary Perry
Like there's something that I've been taught to think about kind of in the back burner, but you don't need to think about them.
00:34:59.37
Mary Perry
Just the fact that PHP Enlists has the index that you can reference is very different to me. And so the idea is when you go through a group of items, some kind of like collection of items, I'm trying not to use collection because it means a different thing, but I mean like the broader, yeah.
00:35:19.23
Chris Morrell
It's fine. and Yeah, yeah, in the abstract sense of the collection.
00:35:23.43
Mary Perry
Yeah. it's There's so many words that are just like the same word but have a completely different meaning in a different context.
00:35:28.15
Chris Morrell
Yes.
00:35:29.15
Mary Perry
It's it's a lot.
00:35:29.41
Chris Morrell
Yes.
00:35:32.09
Mary Perry
But when you go through a collection, you return basically a reference to an index as a means of referencing the list,
00:35:43.34
Chris Morrell
Okay.
00:35:44.81
Mary Perry
like keeping a cursor in a group of elements that you've sorry, not elements, records that you retrieved from a database as an ID and traversing like that group of returns via the ID. And this is difficult for me to put into words because I think of it way more visually. But if you've ever gone into like,
00:36:15.01
Mary Perry
See, i'm not I'm not even thinking of the right words now. But you know those websites that you can put in a SQL query and it tells you what happened behind the seeds to get that query?
00:36:24.57
Chris Morrell
Uh, yeah, like the, uh, planning, yeah, I, I know what you're talking about.
00:36:28.88
Mary Perry
Yes.
00:36:30.02
Chris Morrell
Yeah. Yeah.
00:36:30.95
Mary Perry
it's It's right there.
00:36:31.00
Chris Morrell
The query planner and yeah.
00:36:32.84
Mary Perry
Yeah. it's good the The technical term is going to come to me like an hour after we finish talking, I bet. But it's it's kind of like when you look at a bunch of those, it starts to make a little bit more sense and it kind of comes together.
00:36:45.83
Mary Perry
I had to draw out a flow chart, my like my own flow chart of an iterator with a cursor in mine.
00:36:46.25
Chris Morrell
Okay. Oh, that's interesting.
00:36:52.59
Mary Perry
So I can think of it in terms of that, but I'm still not at the point of mastery that I could just be like, oh, this is exactly what a cursor is. Does that make sense?
00:36:58.35
Chris Morrell
Sure. Yeah. Yeah. And I think as, as you talk about it, I can see like, you know, an iterator is really, it is a, it is a pattern in that it's like, it's a shared way to iterate over anything, right?
00:37:00.95
Mary Perry
Again there.
00:37:18.99
Chris Morrell
Like we, we've defined like a, a way of iterating across all sorts of types of data using like a shared pattern. so that in that like When I think about it that way, I can see how, of course, it is a design pattern. it's just it's just I think it's something that you you see it and deal with in PHP so much that I just think of it as like More like a language construct, almost, than a and a like a more abstract thing, but it doesn't mean that it isn't both.
00:37:52.88
Chris Morrell
It's interesting.
00:37:53.24
Mary Perry
Yeah. then the idea of being able to define different ways to iterate is also part of the pattern. There's something that I do in Python a lot. There's like these dunder methods that you can put on the class.
00:38:06.25
Mary Perry
And one of them is like two underscores iter, two underscores again. And I find myself using a lot, like taking all of the attributes that I've put on a class and adding them all to an iterator function.
00:38:11.04
Chris Morrell
Okay.
00:38:20.98
Mary Perry
or like selectively only using the ones that I'll have on a particular view as an iterator of that class or like some inherited version of the class. And then eventually I always get to the point where I'm like, I'm just writing my own DTO or like I'm rewriting an ORM to like make things easier for me, but it it happens a lot and it works.
00:38:29.05
Chris Morrell
Okay.
00:38:41.95
Mary Perry
So I don't know if that counts as a pattern, but it's just like repetitive things that make CSVs easier, I guess.
00:38:42.22
Chris Morrell
Uh-huh.
00:38:49.20
Mary Perry
I don't know.
00:38:49.52
Chris Morrell
Sure. I mean, I say this all the time. I feel like, So much of programming is just yeah looping over over data to you know exporter export it or import it or process it. or like So much so much of of what we do at InterNACHI at least is just like,
00:39:14.05
Chris Morrell
All right, let's write another command that grabs 100,000 rows and does something with them. you know like One thing that I thought was, I don't know, just really tickled me in your talk was the fact that the facade pattern does not describe facades in Laravel.
00:39:37.02
Chris Morrell
Can you say more about that?
00:39:37.28
Mary Perry
Yeah, it's like a small subset.
00:39:42.02
Mary Perry
one a Well, I take a couple steps back. I got kind of nerds night into Laravel. I say that a lot. And I did a lot of Googling before I started using Laravel and saw a lot of those discussions on the internet about like, you shouldn't be able to have a facade.
00:39:57.05
Mary Perry
And I was like, what's wrong with a facade?
00:39:57.98
Chris Morrell
Mm hmm.
00:39:58.88
Mary Perry
Like in the more general definition of a facade that there shouldn't be anything wrong with it.
00:40:03.45
Chris Morrell
Yes.
00:40:05.02
Mary Perry
oh And I think in like Laravel 5, it was harder to test things with using a facade or like Laravel 6, but then that stopped being as much of an issue, but people are still for some reason mad about it. But a facade in Laravel gives you direct access to something bound as a singleton in the service provider, which I think that there are a lot of ways and This is my own thinking, not me being particularly advanced at Laravel because I'm definitely a junior. and Don't take anything I say too seriously. But I think there are a lot of ways to directly access a service if you really think about it and sit down and source dive. I think the the facade being named in a certain way and importable in a certain way and recognizable to other Laravel developers is good because eventually people are going to want to reach for that information.
00:40:59.56
Mary Perry
But the fact that you can get like static access to that information. I guess it's supposed to be bad. I don't really know, but it's on top of the.
00:41:07.98
Chris Morrell
Yeah, I think i think the the argument goes that the correct way, the correct, air quotes here, way to do things is dependency injection, right? That you, if you're if your class depends on another class, it should clearly indicate that to the world through like a constructor argument or a setter method. And that that is like the right way to handle dependencies. That's the that's how how the argument goes. And so I think the argument against facades is
00:41:51.26
Chris Morrell
that they you know sort of obscure the dependency, they they make it less obvious by referencing that dependency directly in your implementation rather than sort of doing, doing, ah rather than getting at that dependency in a sort of traditional straightforward way, I suppose. And, you know, i think I think that there are times when
00:42:22.54
Chris Morrell
For me, that argument bears some weight in that like depending on the type of code that you're writing and the the way that code is going to be used. Sometimes you do want to avoid accessing dependencies via this facades because you because it it makes sense to do it the other way. I don't know. I'm trying to think of a more concrete example. I think a lot of times in package code, where other like where you're not the end consumer of your code, some you know some other developer is,
00:43:02.31
Chris Morrell
where That might might be a case where you want the sort of like chain of dependencies to be um more more predictable, or you want to make it easier for those dependencies to be or mocked or faked or whatever.
00:43:21.12
Chris Morrell
Because the other argument is like if if your app is just like reaching out into the container and getting the case container's version of a thing, then it makes it a lot harder to to fake that thing that dependency just for your code. Although, Laravel has ways to do that.
00:43:42.52
Chris Morrell
ah ah I don't know, I feel like I'm going off on a little bit of a tangent here. but So there's i I understand the argument against it, and sometimes sometimes I think there's there's value to thinking about, like oh, is there a different way to get at this that maybe will make my code a little bit more testable or or easier to test in isolation.
00:44:07.89
Chris Morrell
but most of the time I don't think that that actually plays out. And especially in like application code, I find that accessing things accessing things via facades, oftentimes makes the code more testable because it's like, the perfect example is HTTP requests, right? like If I have a service, right, that like receives a client interface and the client receives in a Guzzle interface, implement implementation ah of Guzzle, right, or PSR seven or whatever it is interface.
00:44:49.51
Chris Morrell
And in my code, I have like a definition for that client and for that service and it it ultimately just gets like the default version of Guzzle, right? And the default version of that client and the default version of that service. Well, if I need to mock the HTTP requests for that service, now I have to instantiate a mocked Guzzle client.
00:45:21.16
Chris Morrell
and pass it into the client object and then plus that pass that client object into a service object and then put that service object into the container or use that service object. I've had to like instantiate all these like intermediate dependencies just to fake one dependency down the chain, whereas if my service code, like if I had had ah ah a linear service that's talking to my ticket software, like and that's just using the HTTP facade under the hood,
00:46:00.66
Chris Morrell
I can just do my code, right? HTTP, colon, colon, fake. And that's all I need to do to test, to like implement my tests. So I actually think that there are lots of places where the you know where' using facades in your code actually makes your code more testable, not less testable. But that's just me going off on a little tangent here.
00:46:24.57
Mary Perry
And I almost regret like bringing up that debate as like part of it.
00:46:24.83
Chris Morrell
but i guess
00:46:28.55
Mary Perry
But all those things that you're talking about is the easiest way for me to say, like those are the parts of the facade in Laravel that are not generally parts of the pattern, if that makes sense.
00:46:38.96
Chris Morrell
Right. So that's what I was going to ask. So the facade pattern itself is more a way to abstract a complicated system behind a simpler interface, correct?
00:46:54.55
Mary Perry
Oh, yeah, or obfuscate it completely.
00:46:56.86
Chris Morrell
Aha.
00:46:57.07
Mary Perry
Like, the the complexity still exists. But when you have other objects interacting with just the facade and not the complexity behind the cacade of facade, you limit the amount of things that can go wrong and the complexity that you're interacting with.
00:47:09.24
Mary Perry
Like, you just have the product of whatever the facade returns. The example from that book is that as like a compiler, most of the compiler you don't want to touch directly unless you're just working with building the actual compiler.
00:47:23.81
Mary Perry
That's what I understand of it anyways.
00:47:25.65
Chris Morrell
Yeah, no, that makes sense. I mean, and honestly, like in some ways ah ah the eloquent query builder is a good example of of a facade. It's like. I am using just like the shared query building language, but under the hood, it there's like the the grammar, there's like the grammar objects that understand like the specific ah SQL dialect and and and compile SQL into something. And then there's like an executor that actually executes the code. Like there's a bunch of complicated pieces under the hood that take
00:48:02.19
Chris Morrell
uh, that query that I built and turn it into SQL statements that get sent to the database and turn those results back into objects for me. And I like don't have to, or I, I shouldn't really understand, uh, have to like deal with any of those things under the hood. does that, does that feel right? I don't know.
00:48:25.88
Mary Perry
I don't know if it's like a classical way of talking about it, but I think that functionally it's definitely the idea.
00:48:33.38
Chris Morrell
Yeah.
00:48:34.57
Mary Perry
And then you have less things that can break and less things that are confusing for other people to read and less things that you have to consider. I even heard like, even if you want to take it at a metaphorical level, because facade is the design pattern, I think is actually kind of close to the word.
00:48:49.53
Mary Perry
I heard Taylor on an interview, I think it was with Prime recently, talking about like why he chose the license plate and like keeping in mind that, like I don't know, Aaron Francis talks about this concept too, like the vanity of vanities thing. like The things that we have are just eventually going to go away, like things are going to end and stuff like that.
00:49:12.01
Mary Perry
And if we're just like interacting with the way that things look or the way that we should be interacting with, we should remember that there's like additional complexity behind them. And I think that that fits perfectly in an eloquent query because there's, I mean, I think from my perspective, the model part of an MVC is like the, the biggest part of the triangle or whatever, you know, there's a lot of things that,
00:49:20.67
Chris Morrell
and
00:49:35.22
Chris Morrell
and
00:49:38.75
Mary Perry
make an application, in my opinion, perform better because of their absence, if that makes sense.
00:49:45.24
Chris Morrell
Okay. Mm-hmm.
00:49:47.25
Mary Perry
like There's a lot of things you could do, but you probably shouldn't with databases.
00:49:53.82
Chris Morrell
Yeah, that's fair.
00:49:55.44
Mary Perry
I don't know if that was all over the place.
00:50:00.14
Chris Morrell
No.
00:49:56.76
Mary Perry
It feels a little bit all over the place, but in general, yes.
00:50:00.46
Chris Morrell
Yeah. I mean, I, I think you're right.
00:50:01.44
Mary Perry
There we are.
00:50:01.94
Chris Morrell
I think that the query builder isn't, isn't a perfect example of a facade, but I think it just, it it struck me in that moment of like, Oh, this is, this is a place where that.
00:50:13.84
Chris Morrell
That pattern is maybe sort of playing out whether it's like intentional or not. So like,
00:50:18.11
Mary Perry
would I would definitely agree with that.
00:50:20.71
Chris Morrell
Yeah. Cause like a the fa facades in Laravel are almost like service. It's almost like service location, right? It's like, they are just a mechanism to get access to, um, um, instances that are bound in the container. so it's, and it and honestly, like it doesn't actually have to be a singleton. I think almost always facades.
00:50:48.80
Chris Morrell
are, you almost always pair a facade with a single tin that's bound in the container. But like it doesn't have to, I don't think. right All the facade is doing is grabbing whatever it it's you know whatever it's underlying object that it's it's kind of wrapping is from the container and performing the operation on it.
00:51:15.87
Chris Morrell
so like If that thing is not a singleton, I imagine that it would work just fine.
00:51:23.33
Mary Perry
And like, I think database would be an example of, I'm guessing here, but I'm thinking database is an example of a so facade that could have multiple instantiations of a class.
00:51:33.49
Mary Perry
If you have like multiple database connections in the application, but I think you can use the database facade for. Like whichever one you want to grab.
00:51:41.35
Chris Morrell
Yeah, multiple connections.
00:51:43.29
Mary Perry
Yeah.
00:51:44.66
Chris Morrell
Right.
00:51:44.89
Mary Perry
I like the idea of having a database facade, especially,
00:51:45.47
Chris Morrell
Right.
00:51:49.78
Mary Perry
if I was making like a console command to just check real quick if something was going to work that I was going to put in a controller. I think that might be my favorite one.
00:51:59.03
Chris Morrell
Mm-hmm. Yeah, it's funny. I don't I don't reach for that one that often And I don't know why and why not I think auth facade I definitely I reach for all the time the date facade I use a lot Yeah quest request I use a lot and a request is a good example of
00:52:19.02
Mary Perry
That's a great one.
00:52:24.28
Chris Morrell
like that is like the request itself, the request object isn't bound to the container as a singleton. It's just when a new request comes in, the router puts that instance in the container as like the current instance of the request. But if like the same application, if the same instance of the application handled three requests,
00:52:52.77
Chris Morrell
at three different times, the like current request would be different, if that makes sense.
00:53:00.55
Mary Perry
Yeah, that's a I have to say that's still something that I have a hard time rocking my head around.
00:53:06.40
Chris Morrell
Yeah, I mean, I have yet to use, I've yet to use Octane, I've yet to do any, I've yet to do anything where it's not just like a single request per,
00:53:20.09
Chris Morrell
per instance of the application. And I do feel like I've always avoided it just cause I know that there are many traps there that I would have to like, you know, many mistakes that I would have to make. Like you were saying at the beginning to learn, learn those lessons.
00:53:39.78
Mary Perry
I am very excited about that that road, actually.
00:53:43.38
Chris Morrell
Yeah.
00:53:44.24
Mary Perry
Yeah, I have not really played around with it too much, but there's a couple of reasons that I want to look deeply into it. I do have a hard time in general, though, conceptualizing the request as related to the service container because it's kind of a product and it's kind of a part of, and it's kind of everything.
00:54:01.87
Mary Perry
It's like a, I don't know, like a wormhole or something. I don't know.
00:54:07.01
Chris Morrell
yeah no i agree i think I think that that was one of those things that, because most things are bound to the container in like a specific, or like a there's like a standard way, right there's an idiomatic way that you do do this. right Typically, things are bound to the container from like a service provider. right the The implementation is is in the service provider.
00:54:38.03
Chris Morrell
And it's either bound as a singleton or it's bound as you know just like a factory, essentially.
00:54:48.16
Chris Morrell
And in the case of the request, what happens is as the request is getting handled by the router, it's actually the router that takes the instantiated request and and like puts that instance in the container. And that's just like not common to how almost anything else is sort of added to the container in Laravel. And I definitely found that very confusing at first. I definitely agree.
00:55:22.68
Chris Morrell
I mean, I still honestly, every once in a while I open up the router and just like follow, like just, just walk through the, all the functions that like a request, uh, is passed through and like the middleware chain and everything, just because I find that it's like hard for me to like keep that in my brain at all times. I have to come back to it from time to time.
00:55:49.70
Mary Perry
I put a dump and die statement in a couple places during the middleware process and in the router once. And I felt like I went into like a different dimension. my I had to like rest afterwards.
00:56:00.11
Mary Perry
It was a lot.
00:56:01.79
Chris Morrell
It is, it is a lot.
00:56:01.93
Mary Perry
It's hard to keep on the back burner.
00:56:03.76
Chris Morrell
Yeah. No, for sure. Yeah. I mean, that is one of my, like, there are a couple of things that when I first came to Laravel, I felt like I wish that this was a little different and maybe someday I'll i'll like try to PR a change to this thing.
00:56:22.03
Chris Morrell
and. The one that I, I like idly think about from time to time and I i just, I think that maybe it's just not technically possible.
00:56:32.56
Chris Morrell
but I wish that there was a way to structure the request, or just structure things so that all of the middleware wasn't in the stack.
00:56:51.09
Chris Morrell
Because like anytime anything breaks in an application, right you have all of the middleware frames in between, and it's just like,
00:57:03.11
Chris Morrell
It's just so much noise when you're debugging. And it is. It's very hard to like follow just exactly how how that piece works. I agree.
00:57:15.34
Mary Perry
That's an interesting idea. The reaction that I had was kind of awe. Like I thought it was so beautiful, like the way those pipeline works, but I hadn't considered that.
00:57:26.62
Mary Perry
I think it would ah actually be a really interesting thing to try and log it out using the, the strategy pattern with like the undoable actions, like made possible.
00:57:32.65
Chris Morrell
Hmm.
00:57:40.97
Mary Perry
Because if you had a bunch of strategy patterns that you had like very clearly logging to a place and you could go through and be like, OK, where did that break? I don't know. I'm sure that there's implementations of that somewhere in the debugging printout that I just don't understand fully.
00:57:58.37
Chris Morrell
Yeah. Yeah. I don't know. That's an interesting, it's an interesting question though.
00:58:03.37
Mary Perry
Sometimes I just want to build things myself so I understand like what they are. And then I find out that there's already a package that's that but a lot better.
00:58:12.29
Chris Morrell
Oh, 100%. I mean, yeah, I, I feel that. I mean, and sometimes, I don't know. And sometimes it's just, it's good to build it anyway, just so that you, you know, you have it more in your bones.
00:58:29.01
Chris Morrell
But yes, a lot of times someone else has already solved the problem and it's like, I want, I wanted to be the one to solve that problem.
00:58:38.87
Mary Perry
My dad is like that with a can of cheese, like the cheese whiz in a can.
00:58:39.08
Chris Morrell
a
00:58:42.63
Mary Perry
He's like, I could have done that.
00:58:43.17
Chris Morrell
Okay.
00:58:44.21
Mary Perry
I wish I was the one who did that.
00:58:46.47
Chris Morrell
You know, I, I think about, I, I have this argument with my, uh, business partner or I used to, we don't, I think I finally got it into his head, but, He always used to, we always used to argue about art. you know, he, he would always say like, I could have done that. I could have done that, you know? And, my response to him has always been, but you didn't. And, uh, I think that like, when it comes to art, right? You sometimes you'll see something that's like technically not necessarily challenging.
00:59:27.15
Chris Morrell
But the reality is that that that what makes it noteworthy or important is why it was done that way at the time that it was done and by whom and in what context, right? Like there's there's so many other more important questions there. And yeah, it's kind of the same with with with product stuff. It's like, it doesn't matter if you could do it. it's It just matters whether you did, right?
00:59:54.62
Mary Perry
Yeah. And sometimes I get really pessimistic about things and I think, Oh, everything is just marketing because you could have the most perfect implementation of something and everything works perfectly and it's just gorgeous code and it would solve so many problems for some, so many people and people don't know about it.
01:00:12.18
Mary Perry
Then it's like, what does it matter? But, I think that's why I got so excited about publishing your work increases your luck.
01:00:14.68
Chris Morrell
Yep.
01:00:21.83
Mary Perry
Just the idea of like, but you didn't though.
01:00:21.91
Chris Morrell
h
01:00:23.91
Mary Perry
Like, how's it going to feel at the end when you look back at all the things that like might've been similar to other people's work or might not have been good or anything like that, but like you could have done it. I don't know. I just liked the idea of building silly things anyways.
01:00:36.84
Mary Perry
I mean, I, um, I made a portfolio website for myself on GitHub pages. Cause I just wanted something like very static and easy to deploy. And I ended up overthinking it for a really long time.
01:00:47.95
Mary Perry
Cause I was like, okay, if I was going to make a spa from the beginning, Like, how would I do it? So the whole thing is just like a single page application that is very clunky, but then sometimes when I look at React versus VL, I'll be like, oh, that's how they answered that, that I really didn't even touch because, you know, it's just a portfolio site.
01:00:53.01
Chris Morrell
Yeah.
01:01:07.39
Chris Morrell
yeah No, I mean, i i think I think there's a lot to be said for, i well, yeah, there's a lot to be said for the like, if you don't put it out there, it doesn't really matter. not and And I don't mean that entirely. it's There are lots of times when you can do something that's just for yourself, and then it doesn't matter if you put it out or not, because like that's not the point, right?
01:01:35.82
Chris Morrell
But if you're doing something four for an external reason or a reason that like needs other people, whether it's for connection or whether it's for recognition or whether it's for profit, or you know there's lots of different reasons that people put things out there. like It just doesn't exist unless you do it. you know like It doesn't matter unless you do it.
01:02:02.61
Chris Morrell
And i i I give this advice to our members all the time. you know So internet, she's a trade organization for home inspectors. And I say this to to home inspectors all the time, but it really is true of almost every business. It's like being competent as a home inspector is the absolute ground floor of of being a home inspector. I think that's true of of ah most ah most businesses. It's like being competent at what you do.
01:02:31.09
Chris Morrell
or being somewhat competent at what you do even is like, that's the very beginning. It doesn't matter until you like are able to get yourself out there, you know, until you're able to market yourself until you're able to, you know, connect with other people and, and show the world that you you're competent. Cause it's just being competent. That can be, that can be super fulfilling in and of itself. But if you're trying to do it as a business, like that, that doesn't get you anywhere.
01:02:59.07
Mary Perry
Yeah, that's an interesting way of putting it.
01:03:03.47
Mary Perry
I to recently, this is very off topic, but I tried to ask myself what my motive is for doing things and try to be honest with myself about like why I'm doing a thing.
01:03:11.28
Chris Morrell
come
01:03:14.60
Mary Perry
And I think a lot of the obsession with the the design patterns in the first place was related to like my issues with putting myself out there and my own issues with questioning whether or not I'm confident or like, how would I know if I'm confident?
01:03:25.96
Chris Morrell
Okay.
01:03:29.75
Chris Morrell
Mm
01:03:34.10
Mary Perry
And I don't necessarily think that the talk went the way that I wanted to.
01:03:34.25
Chris Morrell
-hmm.
01:03:38.94
Mary Perry
And I think that there's a still a lot farther that I'd like to go, but I like the idea of being able to engage in a community and like talk to people and say like, hey, it's OK if you don't feel competent, or it's OK if you don't understand these terms.
01:03:51.67
Mary Perry
like We could just talk about them. like You could just admit that you don't know things, because that's the first step to knowing them, and breaking things is the first step to building them, or understanding why design patterns or packages are good in the first place.
01:03:56.36
Chris Morrell
Yeah.
01:04:08.80
Mary Perry
I think that's really cool about web design in general or like now well what development when it comes to applications. is that even if you went to school, everybody has been so confused so many times, and everyone who's successful has just pushed through over and over again. I think that there can be a lot of situations, even for people who are very experienced, that's like hard to name. I don't know. Names are good.
01:04:39.60
Chris Morrell
Yeah. Yeah. Names are good. That's for sure. Yeah. I mean, language is good, right? Having a way to communicate.
01:04:47.02
Chris Morrell
Well, are there, is there any other, i'm I'm trying to think and i'm I'm drawing a blank, but was there, and were there any other patterns that you highlighted in your talk that you'd like to talk about now or any other concepts that kind of come to mind? I feel like we've covered a bunch of different topics.
01:05:08.83
Mary Perry
Yeah, observers are weird.
01:05:11.06
Chris Morrell
Okay. Talk to me.
01:05:12.08
Mary Perry
That's a my observation on observers.
01:05:15.88
Chris Morrell
I see what you did there.
01:05:17.30
Mary Perry
Thank you. Yeah, I think that it's interesting to see it pointed out like in those tweets that I included in my presentation, to see two people respond to a pattern in very different ways. like Even when we were talking about like having the sense of the builder pattern,
01:05:34.58
Mary Perry
In common, a lot of what I was trying to do was inspired by a video that Prime recorded that was like a reaction to another video of eight design patterns that programmers should know.
01:05:34.69
Chris Morrell
hu
01:05:46.98
Mary Perry
And it was written in Python.
01:05:47.36
Chris Morrell
Okay.
01:05:50.38
Mary Perry
But he called the observer pattern like the pull your hair out slowly pattern because of all the unexpected consequences you might have from using an observer pattern.
01:06:00.10
Chris Morrell
h
01:06:02.13
Mary Perry
And I thought that it was really interesting that an event, which is not necessarily part of the pattern, but like the observer pattern basically works by having an observer that responds to changes in in a model or changes in state in the model. And then it keeps everything, like the system kind of self-referentially keeps the state up to date in multiple objects.
01:06:30.50
Mary Perry
And a lot of things can go wrong there. And then when you talk about an event sourcing pattern, a lot of times you're talking about like making a change in state, an object that you can talk about the actual change as if it's not like a verb as a change, but like a noun as a change. But obviously there's problematic things with even the words that I chose. It's very difficult to talk about.
01:06:57.68
Chris Morrell
I know that.
01:06:57.66
Mary Perry
but
01:06:59.94
Mary Perry
you You could do this a lot better than I am, I'm sure.
01:07:03.54
Chris Morrell
No, it's, it's, these are hard things to talk about. It just, when you get into like evented stuff and commands and observers and it's just like, there's a lot of, there's a lot of jargon.
01:07:16.88
Mary Perry
Yeah. But the idea, like you don't even really have to look at and a system with events in them as if they have events. You definitely don't have to turn those events into objects.
01:07:28.17
Mary Perry
and the difference between action pattern being reusable and an action within an event or like having the observer kind of injected into the event versus being a place to store events in versus being a way of looking at an entire system with state being managed between things I thought was extremely interesting.
01:07:44.21
Chris Morrell
Okay.
01:07:53.35
Mary Perry
i would love to to hear any thoughts that you have on it or go deeper into it when I find good words to describe those things.
01:08:01.50
Chris Morrell
Yeah, I mean, my, my main take on like a vented applications. and I say that as something slightly different than event sourcing, but, but my, my take on,
01:08:18.94
Chris Morrell
Unlike systems that are reactionary, right that that where a lot of the effects that happen in the application are in reaction to something happening. right and and like An observer would be one way to do that.
01:08:37.52
Chris Morrell
I think that the problem is in in the world that I'm in, in the Laravel world, we don't do that most of the time and ah ah and in other in other sort of like programming ecosystems that I've been involved in. like Even in JavaScript where you know in the browser you're dealing with events and you know the event loop and and reactions to events all the time,
01:09:07.62
Chris Morrell
uh, it's, well, I don't know, but I find that the biggest problem with that approach is not it not being the primary interface to your code. Right. So like.
01:09:23.64
Chris Morrell
In our application, for example, we have a handful of observers that react to events that eloquent models fire, right? So like when a user gets updated, there's an observer that triggers a bunch of webhooks that go out to like third party services that that care about user state changes.
01:09:47.60
Chris Morrell
And Because that's like one of the very few places where this happens in our application. You just don't think to check that when something goes wrong. I think that that's the biggest problem is like you've just like, you've now sort of abstracted, you've you've or you've just like spread the functionality out in a way that like can be very useful, but if you're not doing it all the time in your application, it becomes hard to keep track of.
01:10:21.22
Chris Morrell
I don't know if that makes sense or if that answers or you know speaks to what you were saying at all but that's my that's kind of my observation about the observer pattern.
01:10:31.18
Mary Perry
I think that it does make a lot of sense, and it's also kind of confusing that it's a pattern in the sense that patterns are supposed to solve problems, but lots of times with that one in particular or with other patterns, trying to implement them can also cause patterns. It's just weird. It's just an observation I have. Yeah.
01:10:47.62
Chris Morrell
Yeah. Well, I mean, if you go back to the, what we were kind of saying at the very beginning, this is, this is a way that people solve problems. And so having a name for it and having a shared understanding of when I say observer, this is generally what I mean. Even if it's not necessarily a great solution all the time, you know, maybe it's only a good solution some of the time. it's still useful to have a name for it so we can talk about it.
01:11:16.36
Chris Morrell
Yeah.
01:11:18.25
Mary Perry
And I read somewhere that somebody was trying to make an argument that the entire Laravel request cycle could be seen as not canonical implementation of an observer system, because all the changes that are happening to the request are affected by all the previous changes and stuff, and the the state kind of like relies on previous state.
01:11:38.36
Mary Perry
But that's a that's I'm going to figure that out in like five years.
01:11:39.64
Chris Morrell
Interesting.
01:11:45.16
Mary Perry
and I'll write a blog post about it or something, I don't know, way over my head.
01:11:49.20
Chris Morrell
Yeah, that that is, uh, I, I'm, I'm trying to, to, to sort of like figure out how to make that work in my head, but it's, it's certainly not going to happen and without like looking at something. I don't think.
01:12:04.82
Mary Perry
Yeah.
01:12:06.57
Chris Morrell
this has been really fun. I'm really looking forward to your talk in, uh, in, in, I guess it's what, two weeks. and.
01:12:16.06
Mary Perry
Maybe a week?
01:12:17.48
Chris Morrell
Oh yeah.
01:12:17.84
Mary Perry
October is flying by.
01:12:18.00
Chris Morrell
Well, maybe a week. and why It really is. Oh yeah. Like a week and a half, it looks like, but,
01:12:26.27
Mary Perry
Okay, then I have more time.
01:12:26.33
Chris Morrell
And yeah, I really, I don't know.
01:12:29.15
Mary Perry
That's good.
01:12:29.38
Chris Morrell
I appreciate, I really appreciate like, uh, getting a chance to, I don't know, think about that these concepts in a different way, because I do, I do really think I noticed,
01:12:43.53
Chris Morrell
I noticed that I've gotten almost like sort of defensive whenever anyone brings out like you know inversion of control or like ah ah dependency injection or or you know chain of responsibility or whatever. like that these Those terms often come out when someone is saying, oh, the way you do it in Laravel is wrong.
01:13:06.62
Chris Morrell
And so I find myself just like immediately kind of like being prepared to have to defend or or fight about something. But in a lot of ways, you know, having that having language to talk about these things is just really useful. And I'm appreciating that more. So thank you.
01:13:29.74
Mary Perry
Well, I had a really great time talking to you. And I mean, I hope that it's a an okay argument, but it's not just me being silly. i It rings true to me, honestly.
01:13:41.25
Mary Perry
But i don't I don't know if you can...
01:13:41.53
Chris Morrell
Yeah.
01:13:44.40
Mary Perry
I don't know if one can say that code is wrong if it works, and Laravel does tend to work pretty well for a lot of people. so
01:13:52.35
Chris Morrell
Yes.
01:13:52.77
Mary Perry
and This is really one of my favorite podcasts, and I am honored to be here, and it's always really wonderful to talk to you. So thank you for having me on.
01:14:01.11
Chris Morrell
I appreciate that so much. Well, before we go, um um how do people find you on the internet?
01:14:09.80
Mary Perry
I'm pretty much only on the website formerly known as Twitter, at CIFRIUS, and Pinkery, with the same the same name, S-I-F-R-I-O-U-S.
01:14:19.60
Chris Morrell
Okay.
01:14:19.84
Mary Perry
so
01:14:20.40
Chris Morrell
And is there anything, uh, that you would like to plug any, anything, uh, that you want to give a shout out to or, uh, you know, ask people to check out.
01:14:32.08
Mary Perry
Can't really think off the top of my head. Pan looks cool. I'm going to look at that later. I don't know.
01:14:36.21
Chris Morrell
It does look cool. Yeah. I've, I've been hoping that someone would tackle this problem for a long time. So I'm excited to see. I haven't had a chance to look at it at all other than just the little video clips that have been coming across my Twitter feed, but very cool.
01:14:54.06
Chris Morrell
Yeah. All right. Well, I'm going to shout out again, your, your talk. Hopefully your, uh, I think your New York talk's going to be up on, uh, on the internet in a couple of weeks. So look out for that.
01:15:03.78
Mary Perry
Oh, that's true. I should have thought of that first, huh?
01:15:06.95
Chris Morrell
and I'm gonna try to figure out how to record your talk in in Philly, so maybe your Philly talk will get onto the internet as well, we'll see, no promises, but I'll i' see what I can do.
01:15:19.46
Mary Perry
Cool.
01:15:19.70
Chris Morrell
All right, well then, until next time, this has been great.
01:15:23.92
Mary Perry
Until next time.