[Help] understanding Architecture of a parcel system
Hi, I am working on a post system which has two classes, standard and express. I am using Finite state machine to track my order from dispatch to Deliver.
My architecture is like
where I have all the details about the order
standpost inheritances all the properties of the post class and I have added a couple status for this class.
Also, I have different status for standard deliver, such as dispatch, in transit, and many more.
Is there any way that I can change these standPost status automatically, so the client get notification?
If someone can help me or guide, that would be appreciated.
thanks
56 Replies
I'm not sure I understand. I think I'd need to see a simplified version of your code to get a better idea
@aes I can share my code
I built a state machine once that lets clients register Actions to events and transitions in my state machine. That could be similar to what you mean by client getting notification
Yes something like that,
Basically If you can help to understand the architecture that would be helpful
You can try to share your code. I am not familiar with the domain of parcel and shipping
How can I share my code?
uhhh... screenshots maybe? Or github?
I guess first just tell me what you're trying to do
Sure,
For example,
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/The clients places orders (goods, items etc...) and then they have two options for the delivery such as standard, and Express. In standard, there are three steps Prepared, Dispatched, Delivered. the status of each step gets update after certain days.
So, I want to design an architecture for both delivery system that can update the status of the post item automatically
this is my base class
Your OrderTrackingContext has an OrderTrackingContext..?
"Is there any way that I can change these standPost status automatically, so the client get notification?"
No, nothing is automatic, you have to code it.
@Yawnder-Tired of Authenticating I know How to code it
update method is not public
So what are the steps of express? Do they exist yet?
To me, it seems like a simple case of
and just updating the
Status
when needed, in the controller or w/eRight now, I don't get what you need help with tbh. You're saying a lot of things, but... it's not helping my comprehension of the issue you're having.
yes express has only two steps, dispatch and deliver
(as a side note, use
PascalCase
plz)I think you need to reduce the problem to it's simplest expression.
@Yawnder-Tired of Authenticating ok
Yeah maybe I'd take a step back. I'm a fan of abstraction but it can make things confusing early on before you've solved the initial problem
Is this a web app? Console app?
console app @aes
Is this just for testing or... like where will this be used?
For example, I am an owner of goods shop. My clients order some stuff and they want me to deliver them to you with guaranteed delivery date. So, I have two options for post Standard and express. this is the first step.
What are your inputs and outputs, and how often do you get and need them?
Inputs are OrderId, delivery type, and order Date.
Now, I have create a base class.
Outputs are delivery date with order Id.
Now from the base class, Is it a good idea to Inherit the class to Express and standard class?
I'd just use an enum and a single class tbh
Yeah
With an if statement or that state machine you were talking about
(and I still don't understand why
OrderTrackingContext
has an OrderTrackingContext
in it.)If using a base class becomes useful, it will become apparent as you write it
this is just test code.
No, I'm fine, but thanks for the offer.
How are delivery dates calculated? Aside from standard vs express, like what determines the exact date?
delivery dates will be calculate by adding days . For standard Prepared ( 2 days add from placed date), Dispatched (2 days from prepared), deliver (0.5 days)
same with express but less days
I am ok to write separate class for each delivery type. Is it a good approach?
Do you even need classes?
because in future, I want to change my prepared order time for to 3 days for s the standard delivery.
I would just create a console app that takes the inputs you want and gives you outputs you want using if statements and all that. Once you get it working, you can create classes
I was thinking to impalement a design pattern
for each state of delivery type, So I can add more code in future if the policy changes for the delivery.
Because I imagine the harder problem will be deciding how to persist your data. Like what if your console app crashes. Do you lose all your orders? Or do you store your orders elsewhere and this is only used to calculate delivery dates. You can start thinking about classes then
my data is a small, not for a big scale. no need to worry about that. Now please give a map to implement class for the delivery system.
You can make interfaces or abstract classes for this. I'd just start simple before you start thinking about infrastructure
ok,
this is my interface, do i need more functions here?
You need them to be
PascalCase
if anything 😛Does your current code work now?
Also,
status
seems like an enum kinda situation, not a stringTry to get it working for only standard. Then think about how to do it for express and what you'd need to change with your current code. You'll probably see how you should implement your abstract classes and interfaces then
no, I am still working on it. Not sure about the design map
What do you mean by design map?
that make sense.
design map means, like architecture of the system.
like design pattern
I like this. You can create a class or record from user input and fill these values with your inputs. Orderid and such. You could create a public method on Tracking called Process or MoveNext or something and make a private state machine on it. Calling this method would move the current state to the next state based on whether it's standard or express. I'm not 100% sure what your implementation would be since I don't know what exactly you need from this software you're making, but you could start with something like this. The idea is to start simple
Yep. Some sort of
or some such
ok, I will try your approach and paste my code here for review. How about that?
I'm down to look at anything, but the fastest way to iterate is to implement the absolute minimum of what you need to get something working and then test your app to see if it works
Then add some more, then test
And if you get errors or it's just not working, you can post about it here
sounds good to me, thanks sun warriors @aes @Angius
hi I have implemented following interface
@aes please review my code
Does the code work for you?
I think I see some type mismatches
No , does not but fixed these errors