Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This is my first question here so let me know if additional info is required...
I am new to designing so my knowledge is a little limited, so I have this application in which I have a project class, the project goes through 7 stages, and those stages have nothing in common...first one is Discovery, which contains question about the requirements, second is Product Mapping, which lets the user select products required by the project...
The problem comes, that stages keep on getting added or removed...
So I cant put their reference in the class, cuz then I need to modify the class every time. So how to design the flow?
Should I pass the project object into stage object? Then how to keep track on which stage the project is?
I think you should go for Process Manager Pattern.
Each of your stages should be separate class implementing a common Interface/Abstract class(according to your need) and then you need to have a Controller class which will control the work flow of your project. You can add or remove your steps to this Controller class instance as per your requirement.
You can track the "status" of the Project as Project.status, being an enum that advances through the appropriate stages. (This assumes that each stage exists only once; it can be re-executed, but would update/ overwrite the previous results.)
Data captured at each stage can be implemented as properties in the Project class (most simple), or (more advanced) "pushed down" into composite entities per-stage.
Don't forget also to take advantage of entities/objects to hold information like Requirement, Product Mapping etc!
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I got some businesslogic I want to handle inside of a .cs file.
Depending on the outcome of that, I want to update the blazor UI, EG a toast notification or a variable change. How could I do that?
Thank you in advance.
This is not easy to answer as your question is not specific, and we don't know how proficient you are in programming. However, the following answer may illustrate the path you should take in the context of Blazor:
Your class should be defined as a service, which you should add to the DI container from the Startup class, and injected into your relevant components.
This service class, generally speaking, should implement two patterns: The State pattern and the Notifier pattern. The service is supposed to hold some state, as for instance, a given value passed to the service from component A, which trigger an event handler that propagate this fact to other subscribing components, passing them the new value passed from component A via EventArgs or properties. The complicity of the service depends on the functionality you want to expose.
Search Google for strings like "enet stackoverflow Blazor notifier", and such like to see relevant code provided in my answers.
See these links:
https://stackoverflow.com/a/62042629/6152891
https://stackoverflow.com/a/66370816/6152891
You need to use ComponentBase.StateHasChanged in response to whatever is happening in your business logic. Since you didn't post any code it's hard to be more specific but that method will force the relevant component to re-render.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I Started Learning C# and it confuses me with term 'outsiders'. Are outsiders some unauthorized people to our code?
It is not C# jargon, but it refers to any entity that is not the object.
In this specific case, outsiders might be the factory that creates the player or other entities of the game.
In general you want to grant access to specified resources only to a selected few. This maintains the code cleaner (as you force using specific accesses you appositely designed) and ensures the flow is followed (imagine that when setting the score you also want to update other variables of Player, if someone modified the variable directly, the side effects would be bypassed).
The whole situation becomes even more critical when you are writing a library for others: you want to encapsulate the internal variables as much as possible and not allow others to have "free access" to everything, as they might tamper with important stuff.
Outsiders is any other code outside of this object. So when you set variable as private, only code in this object can change it. That way you force any other code outside this class to modify score only by calling setScore method, and not directly accessing it.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Some 30 years ago, I developed a big app for fresh fruit packers. I followed a nice paradigm, taken from Informix-4GL: the same screen allows the user to set a "query by example" or to insert a new "record", or update one of them after a successfully one. It maintained a "current list" (the resulting query result and the new records added) wich could be navegated with PgUp and PgDwn Keys. Of course, all that stuff was expressed as mapped text.
The very important thing is that the screen was idle until the user did a "command" to start a new query, an insert or update (or even a delete) operation.
Now, it's the time to evolve that app.
I'm thinking in Wpf and its Preview* group of routed events, to catch the main user "command".
But because there are lots of screens (near one for every entity in the database) it's important to set what is common between them.
Is it the best way (in Wpf) to set one or two "super classes" of Windows for this approach?
TIA
Technically — sure, you can create a class that inherits from System.Windows.Window, have all windows in your app inherit from that one, and implement some common logic in that class.
However, this approach is not considered a best practice for WPF and other XAML-based platforms. Your window and other GUI classes should only contain code specific to presentation. Your model classes that handle the DB queries should not depend on the exact GUI you’re using to present these models.
While not required, a third-party MVVM library is helpful to e.g. provide design-time models for the IDE. As for the specific library, lately I prefer Caliburn Micro, before that I had positive experience with MVVM Light.
With MVVM, it’s fine to have a base model class with some logic that’s common across different model classes. In fact, many libraries encourage you to do so. They provide their own base classes for your models. Such as Screen or PropertyChangedBase from Caliburn Micro.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Please term the right type of relationship and explain your choice. Thank you!
Your case is not clear enough yet, but According to my understanding and previous experience, I think you are taking the modeling to a lower level by adding the list type here! We would simply say that a container consists of n products, and in this case a composition or aggregation relation between the two classes will do the job, basing on this fact, we will have a foreign key inside the products db table indicating the container, the list concept would maybe needed in the code level not the database level.
In brief, the first diagram is accepted, just add n instead of 1, and make it composition if the container is nothing without products in it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am currently maintaining an application where unfortunately we have ended up in having too many Action methods. On top of this the architecture of this project is not fair from the beginning and every developer continued adding Business logic in the action methods of the Controller class instead of keeping it in another business layer.
So now one of our controller class has reached 15000 lines of code and I don't want to flood even more this class by adding another action method.
Any suggestions on how we can refactor this or can we use any partial controller class or any other better way?
N.B: I know we can use thin controllers by moving the code to another layer, but still we will end up with too many methods.
15,000 lines, jeez.
Aside from what you've obviously stated about moving the code to the business layer (which you should do), I would also consider forming logical groups of those action methods that belong to a certain set of functions.
Once you've got these groups, create separate controllers for each of them, named appropriately. This way you'll clean up your controller and you'll also segregate sections of functionality into their own logical groupings.