Sure. Well, something very close to MVC. I find the basics of the pattern maps to most software nicely, with appropriate allowances and modifications of course (such allowances may turn it into MVP, or MVVM or...you get the idea).
I cheat the pattern in a few points in this, since it wasn't written to be maintained on a long-term basis so I could afford to cut corners (same reason that there is no unit tests). Some controllers do more than they should, and should of been split down to multiple controllers. Plus I've done things a bit less cleanly here, normally I find it better to encapsulate the business logic into a services layer instead of putting it straight in the controllers. In the way I've seen and had the best experience with MVC, "model" is just DTOs and the services are the business logic, with a data access layer acting as the glue between models and services.
Considering I wrote most of this whilst on pain killers and antibiotics as a result of infected wisdom tooth, it's kinda surprising to me there's actually any structure to the code at all xD
This is what I wrote about the responsibilities of each package in my uni write-up:
---
uk.co.morleydev.ghosthunt :- The root package contains the base classes for the running of the program itself, the Main entry point and the Game as well as the ControllerStore and ViewStore used for managing the alive controllers and views
controller :- Contains the controllers for the running of the client and server, and the logical processing and updating of the game world and entities, through events, network messages or frame ticks.
The controllers are where the primary difference between the client and server lie. The key difference is in which controllers are used. The client uses predominantly reactive controllers that receive information about how to act, but do very little logic themselves aside from when user input is involved. The server’s controllers send more data, as they are responsible for collision detection between actors and informing the game of many of the possible state changes such as when the hero wins or loses, and when pellets are collected.
However, there is also an overlap of controllers used by both server and client. The physics code is the key example here, with the physics being ran each frame both remotely and locally. This allows the server to only notify the the client about the changes to the direction of actors and the client to independently process their physics, reducing the amount of communication needed between client and server.
view :- Contains the views responsible for displaying the game world to the user, displaying the appropriate entities as well as the maze and pellets that are visible to the user.
data :- Contains all data access logic, including interfaces for accessing files such as loading spritesheets and sound effects, the event queue, the message-passing client and server communication layer, the maze store and the entity-component store.
model :- Contains objects used to transfer information between different subsystems, either as parameters, through accessing the data store, through the event system or through network events.
util :- Contains generic helper classes that did not fit neatly into any other package
Sure. Well, something very close to MVC. I find the basics of the pattern maps to most software nicely, with appropriate allowances and modifications of course (such allowances may turn it into MVP, or MVVM or...you get the idea).I cheat the pattern in a few points in this, since it wasn't written to be maintained on a long-term basis so I could afford to cut corners (same reason that there is no unit tests). Some controllers do more than they should, and should of been split down to multiple controllers. Plus I've done things a bit less cleanly here, normally I find it better to encapsulate the business logic into a services layer instead of putting it straight in the controllers. In the way I've seen and had the best experience with MVC, "model" is just DTOs and the services are the business logic, with a data access layer acting as the glue between models and services.Considering I wrote most of this whilst on pain killers and antibiotics as a result of infected wisdom tooth, it's kinda surprising to me there's actually any structure to the code at all xDThis is what I wrote about the responsibilities of each package in my uni write-up:---uk.co.morleydev.ghosthunt :- The root package contains the base classes for the running of the program itself, the Main entry point and the Game as well as the ControllerStore and ViewStore used for managing the alive controllers and viewscontroller :- Contains the controllers for the running of the client and server, and the logical processing and updating of the game world and entities, through events, network messages or frame ticks.The controllers are where the primary difference between the client and server lie. The key difference is in which controllers are used. The client uses predominantly reactive controllers that receive information about how to act, but do very little logic themselves aside from when user input is involved. The server’s controllers send more data, as they are responsible for collision detection between actors and informing the game of many of the possible state changes such as when the hero wins or loses, and when pellets are collected.However, there is also an overlap of controllers used by both server and client. The physics code is the key example here, with the physics being ran each frame both remotely and locally. This allows the server to only notify the the client about the changes to the direction of actors and the client to independently process their physics, reducing the amount of communication needed between client and server.view :- Contains the views responsible for displaying the game world to the user, displaying the appropriate entities as well as the maze and pellets that are visible to the user.data :- Contains all data access logic, including interfaces for accessing files such as loading spritesheets and sound effects, the event queue, the message-passing client and server communication layer, the maze store and the entity-component store.model :- Contains objects used to transfer information between different subsystems, either as parameters, through accessing the data store, through the event system or through network events.util :- Contains generic helper classes that did not fit neatly into any other package
การแปล กรุณารอสักครู่..