We cover the basic tools provided by the language, and when it's a good idea to go "all in" with this technique as well as when to avoid it.
Get in touch with Luis:
Get the book!
Don't forget to leave a review of the episode or the entire podcast on Podchasers!
Meet our host, OpenReplay:
OpenReplay is an open-source session replay suite, built for developers and self-hosted for full control over your customer data. If you're looking for a way to understand how your users interact with your application, check out OpenReplay.
Sure. Uh, so I live in Florida and I work at a company called Citrix, uh, which is a company also in Silicon valley. Um, and mainly I'm responsible for the, um, so the customer facing the front end, uh, of the company, um, not, uh, just so much in its marketing, but more of like the, the consoles that power, the services that we, or the products that we sell. Right. So to allow the. The administrators to configure their, let's say their gateways or their, their, uh, serverless, uh, instances and things like that. You know, any of the products related to Citrix, which is around virtualization and that kind of thought that kind of stuff. Um, so I'm mainly responsible for sort of architecting and leading the efforts surrounding the, uh, the front end development of the company.Fernando Doglio:
Yeah. Have you, uh, worked with Ruby at all?Luis Atencio:
I have not done ruby no, I had done Python. Uh, I've done very little Ruby in terms of like maybe writing some chef cookbooks and things like that, but not really rails. or anything Yes.Fernando Doglio:
That's fair. Yeah. But if you don't, if you're not careful, it's like magic essentially, because you just, add behavior that, you're not, documenting you're, not telling anyone and things happen around you when you want to do something else. So the example that you said that sending, uh, like tracking data or even logging information, you could configure an object to just log their, their API usage, essentially for every method that that gets called. You could just keep it, keep logging what gets called, what information and what kind of, um, whatever data you want. Without the developer using your object, even knowing about it.Luis Atencio:
Correct correct. And so, you know, there's a lot of things that you can do in code to make it as explicit as possible. I just, I just mentioned, you know, you know, uh, go to town with all the commenting, like do inline comments as much as possible to indicate, Hey, this property is being observed. Um, and this is the proxy. Another, another practice that I've done in my own code is to, uh, uh, use, uh, like a dollar sign. Uh, so you can name the variables to indicate that that's a proxy object. So you can say a variable name to describe what the object is and then dollar sign, what the proxy name is. Right. And then I see this, if you looked at it like. Stack traces from like a language like Java, whenever an object is proxied by, let's say a mocking framework or something like that. They typically tend to do that dollar sign, you know, to show that this is the class name of this and the class name of the proxy. Right. And so I kinda took that pattern from, you know, way back when I was doing a lot of Java development. And so in my object to actually have the variable name, to describe the object dollar sign, and then the proxy name. That's being used and that's what I use in the code. So it makes it clear that, Hey, this is a property. This is an object that's being observed by some other entity. Like the object has its own behavior and that's all great. But if there is some kind of side effect that's happening, every time you call a method on it, right. It's just makes it clear.Fernando Doglio:
That's an interesting pattern. Yeah. Okay. And outside of proxies and, and reflect, uh, let's, let's touch reflect before moving on. So because we've covered proxies, uh, where w what kind of use cases you have for reflect, or what will you use it?Luis Atencio:
It's crazy that it's still hasn't been deprecated, right?Luis Atencio:
It hasn't been right. Yeah. I I'm imagining there's a lot of still leftover tools that people still use, uh, and packages that rely on, on eval. But I mean, mostly, um, nowadays a lot of websites, but they're, uh, you know, they're instructed by their security teams and companies to put their CSP policy, right. The CSP policies that says unsafe eval is you know, put that in there or, uh, or, sorry, you're not put in there. So you don't allow unsafe eval so of have blocked out of the browser though. Certainly we do it. So, you know, it's, it's already part of our mandatory security guidelines. Like we're not even allowed to use. Yeah.Fernando Doglio:
Yeah. I remember the days where you would just get the input from the user and just throw into eval because you know, why not?Luis Atencio:
Throw that into the database too?Fernando Doglio:
We learned the lesson. All right. So you mentioned that a use case for my programming already. So let's move forward. Would you say that the program is for everyone? Uh, do you think there, and I think that I know what you're going to say about. Is there, too much, uh, or too far gone into metaprogramming where you say, well, this is just, you know, there's no way to, to get out of here. We just need to remove everything.Luis Atencio:
Interesting. Interesting. All right. Cool. Uh, thank you. We're going to also have, um, a discount code for our listeners, uh, on the show notes for your book. So check it out. Uh, and all right, so we're, we're done with the metaprogramming questions. Uh, I just have three more questions that we ask all guests. Um, so tell me, um, what is the best advice that you ever had ? Luis Atencio: In Yeah, ideally . Luis Atencio: This field. Yup. Uh, one, um, when I was starting my career, um, I was fortunate enough to have one is really good managers and another one, a really good mentor. And one of the things he told me that I've applied throughout my entire career. Uh, so I've been already programming for over 15 years. Um, one thing that he told me in this is just starting off. He says, find what you like. And then pursue that. And when you're there open your elbows out and make your own space for it. Okay. I'm here open your elbows out, you know, own it. Right. Um, and you know that that's just in wherever I, I speak to somebody, I always tell them the exact same thing. That's the best advice I can give them. Uh, my friends, my family. Anybody. I always told them the same, find something you like when you're there, open your elbows out and say, I'm here, I'm going to own this. I'm going to take advantage of it and try to be the best you can be. Right. Uh, this applies to things like if you see a good opportunity of a project coming down the road at the company you work for, you know, get ahead of it, right. Start to engage your manager and say, look, that's I see myself as a really good candidate for that project. I think I can. All these X, Y, and Z benefits to the company that way. And again, get in there, open your elbows out and make sure you're included in there as much as possible. You know, there, there would be many, uh, opportunities where it doesn't happen, where you try to open your elbows, but you're, you know, you, you can't because there's a lot of, you know, the other business pressures or maybe there are other candidates consider it, or whatever the case may be, or maybe it's something that. Not the right time. Right. But whenever you can just pursue it, you know, it's something that you like pursue it, get in there and own it. Like. Nice. Get a advice. If you can. Can you share with us, what's the most exciting project you've worked on?Luis Atencio:
Yeah, absolutely. So you actually come in at a really good time. So. So what what's happening nowadays is, or I've seen it as well. And, uh, with big companies is that the, uh, the front end development is becoming harder and harder. Right? So in the initial days of like the web one, which, you know, you have a server-side page, a HTML, very, very light interactions, right. Mostly server driven, right. We will be coming to the web web two, and we say, you know, now we need a lot of interaction. And by the way, round trips to the server are slow. So we, uh, you know, we create single page apps, right? These single page apps now are growing to the, you know, millions and millions of lines of code. And now we're reevaluating that. And so for a few years has been the trend to now do the. The micro apps. Right? So the micro front end. So it was just say we want a single page app, but we don't want it to be so difficult. Right. Can we, you know, have all the, can we have the entire application live in the browser? Just not be a single code base that just gets unmaintainable and unwieldy, you know, with years. Right. And so lately I've been, uh, working with micro-frontends and, uh, also sort of leading the team and the product that I'm part of to use micro front end type architectures for, to simplify the admin consoles and the dashboards and the visualization diagrams that our customers deal with. And it's been really exciting because, uh, we're in the second phase of, so we've implemented a micro end architecture that was all based on what they call the, the light DOM which is like the, all the components are in the same HTML DOM, right. Or HTML page coexisting. What you want is in the spirit of the microservices is to have your micro front ends be isolated, right. And something like, let's say a CSS class from one micro front end not conflict or change or alter the behavior of another micro front end and so I'm exploring right now. A lot of the shadow DOM APIs, and then, you know, sort of these things that are more on the cutting edge and there's some limitations still faced with that. And I'm trying to be around all these things, but it's been super exciting. And so, uh, we're getting to the point where all of the micro front ends that are stitched to the page are their own completely isolated shadow Dom components. Right. Um, and just having that laid out and working it's, you know, gives you a sense of satisfaction because there's a lot of little loop holes that, that we still need to jump through. Uh, specifically how you inject the CSS inside that let's say that you have global CSS and the entire company uses well, how do you inject that and make it part of each little micro component? Right? Uh, so it's been really, it's really fun. Uh, I encourage anybody that is doing, uh, you know, that, that are thinking about this problem where, Hey, we have a gigantic monolithic UI start to see if you can componentize and start splitting it into. More manageable components and then just draw a boundary around them. Right. So that, you know, that it changed to one will not alter or change for another one right now it gives you that sense, that peace of mind also. And so what we also did was make sure all these micro front ends were their own repo with their own CI/CD pipeline. Right? So effectively now we had a single page app that was, you know, I'm going to just simplify it and say 800 lines of code right now. It's eight micro apps that micro front ends over 100 lines of code. And so if I released the micro fronted, a, the blast radius of the change is only one eighth of the app. So it gives us a lot of confidence to release, to say, I know I'm not going to be altering anything else inadvertently, because I don't even have access to it. Right. Even if I want it to, I can't access it. So we're trying to get into the mentality. Where can we release more often? Because we have much smaller projects now to release that. They're not talking to each other. Um, you know, only, maybe through a loosely coupled events or something like that. But other than that, they're not talking directly to each other. So it's been exciting.Fernando Doglio:
No, it definitely sounds very, very interesting. I played around with the, uh, shadow Dom, uh, for an article I wrote recently. Uh, and it's definitely, definitely interesting, uh, and fun to play with, so I get what you mean.Luis Atencio:
That could be a good topic of a future or "20 Min JS".Fernando Doglio:
Yeah. All right. Last question. Um, what is one thing that you wish you knew before you get started? You got started coding.Luis Atencio:
Man, that's a really good one. Uh, one thing I wish I knew. Yeah, absolutely. So, um, uh, I got into design patterns late after a lot of years of coding and possibly even making a ton of mistakes and confusing the heck out of my teammates. I then learned that they hey, there is there's these blueprints like that can make what I, what I'm doing. If I'm traversing through a tree or something like that. There's a, actually a good way of doing that. That makes it really clear for everybody else because the design pattern is basically a communication mechanism between your teams. Um, I wish I had, you know, once I learned, once I learned a little bit of coding, I wish I had got into hey industry, by the way, there are these design patterns and this is what you should be following. Um, had I done that from the beginning? I think I would have made for much cleaner, much better. You know, what much more professional. Uh, code. So that's one thing that I, I, I wish I, I wish definitely I had, uh, some, even some indication as to when, when, you know, when I started these things existed, but you know, these are not things you're going to school, and these are not things that you tend to be part of, any core curriculum for anything, the things you stumble upon right down the road. And, uh, for me, you know, I wish I'd, I wish I would've had, I would've stumbled upon that, you know, a little bit earlier. Right. It would've made things easier. That's the one thing I can think of right now. Huh?Fernando Doglio:
Absolutely. Yeah. It's a great also thing to, to, to recommend to new developers, to look into. I, I went through the same thing that you, I did a lot of code without thinking about patterns at the beginning. And then when, you know what they started clicking on me and, you know, I started reading about them uh, I, you know, kind of looked back at the code. I had written and he was like, yeah, I don't, I don't want to do that anymore.Luis Atencio:
Yeah, I agree. All right. That's all the time we have. Thank you again. Uh, Luis for joining,. Uh, can you please repeat where people can find you and then if you had any, anything else other than the book to plug, this is your time.Luis Atencio:
Awesome. Alright. That's it. Thank you again so much for coming in and educating us about metaprogramming.Luis Atencio:
Appreciate it. Thank you Fernando.Fernando Doglio:
All right. That's it. See you on the next one.