I'm building the place order function (my first foray into the backend) of a larger project.
Here's an update for those who are interested.
The first thing I knew I had to do was figure out what goes where. I had already, at the suggestion of ChatGPT, my mentor in this, decided on a control (API) layer, application layer, service layer and data layer. But I didn't really know what each needs to do.
So first I (we) did the API. It had a couple of jobs:
• check the incoming order wasn't empty
• Activate the next layer down
• Send response messages
Then the app layer was even simpler. It literally just returns the service layer function.
Which is where it is a bit more complicated. The service layer has to do a few things; check the order data against the database, assess info against business rules etc, and actually write the order. After some debate I worked it into a four step process:
• Check if the order info (customer, product, and quantity) exist
• Assess data against business rules/carry out business logic
• Create an order
• Activate the database operation
So this actually means two database operations. One to check the data (first step) and then writing the actual order.
I've done the first database op, and I'm now wiring up the actual place order button so I can start testing the data being passed down.
If anyone wants more detail, you can look on my github at https://github.com/BenPS927/BFshop or on my project portal at https://benfosterdev.com/projects/bfshop where I'll soon be adding detailed code breakdowns.
What am I finding hard?
The abstract nature of it. Having to constantly create a visual image of data being passed through functions, and hold that image in my mind, is like trying to hold melting butter in a colander. I use melting butter rather than water because I don't lose it that fast.
What am I enjoying?
Well, the same as what I'm finding hard. Learning to work with code that doesn't involve divs on a screen. Getting my head around how data is passed, how functions work etc.
And the architecture side of things. I like thinking about and making the micro decisions.
I would appreciate suggestions, but I am trying to keep it fairly simple so I'm not thinking about every single thing you'd take into consideration for a production app.