Species Service

What is a "Service"?

Throughout our game, we're going to have a lot of "Services". Services mean a few different things in different contexts. In monoliths (where all of your backend code is in one single app) it could be considered a "layer" of your app. There are a few different combinations of layers, but typically you'd have something like this

The Data Access Layer does one thing and one thing only, Perform the queries to your data sources and return them in the state that they were retrieved in. This could be from a Database, an API, or a cache, a file, you name it! But it doesn't mutate (change) the data in any way. It's an "abstraction layer" so that the rest of your app doesn't have to worry about where the data comes from. You can encapsulate it all here, and even make it so you can swap Data Sources without the rest of the app even knowing it! (We'll be doing that!) It can join data together, like joining two queries together (we'll be doing that a bit in the future with Species and Moves! Hang tight!) to make it so the data is in a convenient form for the other layers.

The Business Logic Layer takes the data provided by the Data Access Layer and applies logic to it. For example, if you're creating a brand new Pokemon, you'll need to get the Species Data (like the attack, defense, etc) and generate a Pokemon with unique attributes from that source data. Here is an example of that! Don't be too intimidated, we'll break it down later:

This logic would fit in that "Business Logic Layer" we talked about. This way, your database doesn't have to concern itself with "what" to do with your data, it just fetches your data, and then the logic layer uses that to do cool things with it!

It doesn't always have to do crazy things - sometimes it just passes the data right through, because it's stored in a way that is useful to all the other layers! Moves are like that! Oh my heck, I swear I'll stop saying "we'll get to that later", but it's all important to what we'll be doing!

Last updated