00:00:10.639
Hello, RubyConf! Thank you for coming. This talk is titled "Dismantling Dystopian Futures with Humane Factories."
00:00:21.840
My name is Anthony Navarre, and I am an engineer at HomeBot. Our mission is to empower people to build wealth through home ownership.
00:00:28.080
I'm a tech lead on the Starfleet team, which I will mention later in the context of this talk. I'm also an amateur home chef and artist.
00:00:39.360
My wife and I live full-time in an RV. I'm not particularly handy, so that comes with its own engineering challenges.
00:00:46.239
Additionally, I'm a new dad; my child is six months old, which means I’m pretty low on sleep most of the time. So, things might get a little weird, and I apologize in advance.
00:01:04.799
The lion emoji you see on the screen is aspirational.
00:01:12.320
So, why did we choose the name Starfleet for our team?
00:01:17.840
We regularly conduct a team day exercise where we discuss our aspirations. One big theme that kept emerging was inclusivity.
00:01:25.360
I grew up watching Star Trek: The Next Generation, which broke boundaries by including women and people of color as main characters.
00:01:35.680
Gene Roddenberry, the creator of Star Trek, said that the series was an attempt to express that humanity will mature when it begins to take delight in differences rather than merely tolerating them.
00:01:42.320
This resonates with me, and it ties into what we’re discussing today.
00:01:48.479
Our team, which I’m very proud of, doesn't wear uniforms at work. This focus on humanity and inclusivity is central to who we are at HomeBot.
00:02:08.160
For instance, when we hire, we prioritize finding the right person rather than focusing solely on technical skills. We want individuals who are hungry to learn as servant leaders.
00:02:15.520
We extend this commitment to humanity in our product. Our customers—loan officers and real estate agents—rely on our tools to build human connections with their own customers.
00:02:29.280
In this talk, I want to focus on how we strive to bring humanity into one of the smallest aspects of our engineering work: the sample data we use in factories.
00:02:35.759
I truly appreciated Matt’s keynote, where he highlighted that Ruby is a human-oriented language. This resonates deeply with me.
00:02:43.120
I want to discuss how at HomeBot we are making our factories more human-oriented.
00:02:50.080
We apply the DRY principle: 'Don't Repeat Yourself'.
00:02:50.080
This principle is not only applied at the code level but also across larger operational systems that are not necessarily tied to the code.
00:02:57.280
I also want to share how we're employing our factories in some innovative unorthodox ways, including user experience research and creating user personas.
00:03:08.640
Some key takeaways I hope you will gather from this presentation are how to implement these principles within your own data systems.
00:03:15.120
I hope you will discover new ways to apply higher-order systems or design principles.
00:03:21.440
However, I won’t present any statistics or data regarding how these practices have shaped or evolved what we do at HomeBot.
00:03:28.480
This talk is more about what we are experimenting with and hoping you can benefit from as well.
00:03:35.280
Let’s discuss some code.
00:03:41.120
By a show of hands, who here has never used Factory Bot?
00:03:49.199
Now, who here has never heard of Factory Bot?
00:03:54.720
I'll give a brief overview of what Factory Bot is and what we utilize it for.
00:04:01.120
When writing tests for your Ruby code, you need some sample data.
00:04:06.639
One method to set up this sample data is to use plain old Active Record instantiation.
00:04:12.400
For instance, in this contrived example about books, we expect that the book record will be compelling if the author has an experience flag set to true.
00:04:19.120
This involves instantiating the Author and Book Active Record models directly in the test. While this works, as your system grows, tests may become increasingly convoluted.
00:04:30.479
Over time, you might find your Book model gaining new attributes, requiring further checks for each.
00:04:38.640
The experienced author detail might get lost amidst these additional validations.
00:04:43.680
One potential solution is to use fixtures. Fixtures are valuable because they allow you to provide a set of canned sample data via a YAML file.
00:04:50.400
While this makes managing data easier, you may notice that some attributes, like 'experienced true', are lost.
00:04:54.800
This is where Factory Bot comes into play. It allows you to define default attributes in a separate factory file.
00:05:02.560
With Factory Bot, you can either build or create the records you want to work with.
00:05:09.520
The crucial part of this process is that both build and create methods will return an Active Model instance, complete with all the defaults you declared in the factory.
00:05:15.199
Additionally, these methods allow for overriding any attributes, so the experienced flag remains easily identifiable.
00:05:21.520
Are there any questions before I continue?
00:05:27.360
Alright, this section reflects a part of a larger diagram that I will show later.
00:05:32.399
The primary purpose of factories is to generate sample data for your specs.
00:05:38.959
Now, let’s explore how we apply the DRY principle broadly.
00:05:45.600
For instance, consider Andy, our newest team member on the Starfleet team. Andy needs to set up his machine to run the application.
00:05:51.279
Or perhaps in your QA environment, once a feature is launched, you need sample data to facilitate the testing process.
00:05:57.679
You shouldn’t have to set up that data manually every time.
00:06:03.360
This raises the question: what do we mean by humane factories?
00:06:09.040
I propose we evaluate factories through a lens of three attributes: Clean, Common, and Creative.
00:06:15.840
Firstly, cleanliness is essential for a humane factory. If there’s any messiness, it detracts from humanity.
00:06:23.040
Having a clean data structure means that asking for a specific example—like an author—shouldn't lead to ambiguity.
00:06:30.639
If a system is invalid by default, it’s unhelpful. Factories should allow you to obtain sample data seamlessly.
00:06:38.640
Factory Bot aids in this by providing utilities for managing factory integrity over time.
00:06:45.680
By linting factories, you can ensure they remain valid and reflect changes in your codebase.
00:06:51.360
If you introduce changes to a factory that makes it invalid, you need immediate feedback.
00:06:58.959
All these steps in managing factory validity are critical for creating a reliable testing environment.
00:07:06.240
Addressing questions regarding tests before I proceed further?
00:07:12.000
This illustrates how we can apply the DRY principle in our tests, reducing redundant details and focusing on what's essential.
00:07:19.120
Next, I want to talk about how we utilize a common language within our factories.
00:07:26.720
This involves aligning the terminology used by our team with that used in our code.
00:07:34.880
Communication structure within teams reflects in the systems they design.
00:07:41.440
Finally, having common language in our factories allows us to use them in innovative ways.
00:07:48.160
This opens doors for employing factories beyond their initial intent.
00:07:54.720
For instance, while defining our factories, we can ensure that they're applicable across various scenarios.
00:08:02.720
This enables adaptability and robustness in our testing frameworks.
00:08:10.240
Let's revisit earlier where we considered using personas or behaviors as part of our testing strategies.
00:08:18.560
We consider the needs and motivations of our users when designing tests.
00:08:27.840
I want to highlight how our HomeBot team integrates user personas into the Factory approach.
00:08:35.040
Our user persona constructions involve deep insights into behaviors, needs, and expectations.
00:08:43.760
The collaboration with UX researchers, like Matt on our Starfleet team, ensures accurate representations of our users.
00:08:49.760
These personas aid in crafting shared understanding and keeping the focus on user-centric approaches.
00:08:56.680
By merging these user figures into our factories, we enhance the overall processes and outcomes.
00:09:03.600
I also want to emphasize that simply documenting user journeys isn't sufficient.
00:09:10.559
Different personas should seamlessly integrate into our design initiatives.
00:09:16.720
This means making informed decisions by incorporating these personas in our work processes.
00:09:26.240
Having a central repository for all this information increases its utility.
00:09:33.520
However, tools or documentation alone won't ensure engagement.
00:09:42.720
Personas must play a role in everyday interactions, not just exist as abstract concepts.
00:09:49.840
In an article titled 'Why Personas Fail,' it mentions that they should not just be displayed as artwork.
00:09:56.160
Promoting real usage of personas is vital to maximize their effectiveness.
00:10:04.080
I want to argue that integrated use supersedes evangelized use.
00:10:11.840
If personas are embedded directly into our systems, their impacts would be significant.
00:10:20.799
Here's how we incorporate these factory approaches at HomeBot.
00:10:29.200
We use them for seeding development and QA staging environments, which streamlines the process.
00:10:36.000
Additionally, we employ our factories for running end-to-end tests in coordination with Hanger Gem.
00:10:43.520
Future-proofing is another avenue we are exploring.
00:10:50.080
The creator of Factory Bot points out some limitations when using it for seeds.
00:10:56.300
Attributes may change over time, which could lead to unintended consequences.
00:11:02.240
However, these risks are manageable when we understand the specific contexts they apply to.
00:11:09.680
In QA processes, we balance maintaining seed data and the evolving aspects of our factories.
00:11:16.800
Through Factory Bot’s attributes, we effectively manage dependencies and integrity.
00:11:23.680
We can utilize attributes in a rake task to ensure rapport between them.
00:11:30.720
I also mentioned earlier how we utilize Hanger Gem predominantly for end-to-end testing.
00:11:36.720
Hanger Gem provides RESTful endpoints for our factories in the system.
00:11:43.440
This allows for a flexible interaction with our Active Record models.
00:11:50.480
In our existing end-to-end system, common endpoints facilitate seamless data communication.
00:11:58.560
Moving on to our approach for future proofing, we need to anticipate various user personas.
00:12:05.600
If we introduce new persona data, it should enhance the test validity.
00:12:12.560
Sharing data between personas should ensure comprehensive testing of features.
00:12:20.000
The advantage of our integrated approach means observability into performance across different user segments.
00:12:27.840
Finally, should any behavior shift or fail for a new persona, it highlights the issues.
00:12:34.560
If specific edge cases in system design is leveraged, we can enhance user experience.
00:12:43.440
Overall, lessons learned through these innovative testing methods can significantly drive our future practices.
00:12:50.720
This full diagram encapsulates how we integrate our factories and user personas.
00:12:57.440
The personas and behaviors enhance our testing frameworks and make processes more efficient.
00:13:03.680
Thus, having a multifaceted approach not only addresses requirements but facilitates continuous enhancements.
00:13:12.960
I invite any remaining questions if we have time for that.
00:13:20.000
You can always reach me via the HomeBot booth or online at [email protected].
00:13:27.200
Thank you very much for your time today.
00:13:50.359
If anyone has a question about the seed resets we're working on at QA, feel free to ask.
00:14:05.000
We set up our seeds on rake tasks to streamline the data generation process, which allows for customized scenarios.
00:14:20.000
Being organized and strategic in naming our tasks permits greater flexibility in executing thorough testing.
00:14:37.000
If there are additional inquiries about managing factory behavior growth, I'm eager to engage.
00:14:54.300
Working collectively towards enhancing our system will yield fruitful results.
00:15:00.679
If you have thoughts to share or want to reach out later on, don't hesitate.