Page Management in Blazor [closed] - c#

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 1 year ago.
Improve this question
I've looked around but I can't find anything related to managing your pages; by that I mean, everyone seems to just hardcode their page names and navigations to set pages all over the place.
Is this the recommended way of doing it? Just seems like you will have to do a significant amount of refactoring if things change.
If you guys have a setup you really like, I would love to hear about it :)
I've considered making a static lookup class, that can provide all the page paths and their equivalent navigations, but I don't know if it is an absolute overkill.

You can use reflection. Remember, each .razor file you create for a Blazor page will have the class generated for it that is the same as the name of the file. You can create a base class called BasePage and do #inherits BasePage on each of your pages. Then you have a singleton service that uses reflection to find all these classes and keep track of them that way.

Related

Are we supposed to use properties or private fields in Blazor code behind classes? [closed]

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 1 year ago.
Improve this question
In Blazor, certain things like injected objects and parameters must use properties, that part is clear.
But what about those page-specific variables, such as data/DTOs and misc strings/booleans etc used to control the page content and flow?
Is it better to use automatic properties with these all the way (public or private?) or private fields?
I'm asking this because in the various examples, tutorials and documentations related Blazor, use of both properties and fields are all over the place. I cannot seem to find any official best-practice guides on this.

Clean Code - naming related classes [closed]

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
I've read Clean Code by R.C. Martin and I'm trying to adopt his suggestions about clean code as broadly as possible.
But I'm not sure how to name related classes.
Let's say I have a class named TreeDirectoryList.
I want to cut implementation of this class into many smaller classes.
Let's say I'll create a class named ParentIndexStack.
ParentIndexStack will implement functionality very dependent on TreeDirectoryList, so it's very not probable that this implementation of ParentIndexStack will be useful with any other class in the future.
But the name of ParentIndexStack is very generic, it's possible, that I'll need another class with the same name, within the same project.
So I thought I'll name ParentIndexStack more precise, like TDLParentIndexStack (prefix TDL is from TreeDirectoryList).
Would it be correct ?
I'll end with many classes starting with TDLxxxxx.
One option is to put that set of classes in their own namespace. Then you can have simple, concise names that still communicate the full meaning of the class through the namespace context.

How do I share lots of unrelated methods between different classes without creating a "god namespace/static class"? [closed]

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 7 years ago.
Improve this question
A "God Namespace" is the (uncommon) term for an (anti?)pattern analogous to the "God Object", when you stuff a metric ton of stuff (mostly methods/functions) that is not related or not closely related to each other into one huge namespace/static class just so that it can be used in multiple sections of your project.
When following that (anti?)pattern, you often end up, as a C# example, with something like a static class Assets with tons of methods mostly unrelated to each other, but used across multiple places in your project(s).
I usually approach this problem by letting the next Assets grow for as much as I can bear it, and then desperately try to sort its contents out into several smaller ones based on the criteria which seems most legit, like MathAssets, or BitmapAssets, or RNGAssets, and then end up forgetting what did I put where... and make a new Assets for several new methods which don't fit into either of the SomethingAssets already cluttering up the project.
Are there any other ways of clearing up the "God Namespace"? Or will I just have to live with good old static class Assets?

C# method naming best practices [closed]

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 8 years ago.
Improve this question
I have a coworker that keeps renaming object and method in my code. Add S, removing S etc..
I would like to know what is the best way in your opinion.
Suppose I have a class Client.
This Client can set two reminders (wakeupReminder and leaveReminder).
Each of these reminders have different settings.
So I created a Class called WakeUpReminderSettings. He told me that I should rename it to WakeUpReminderSetting because it is not a collection.
I also created a method that return all reminders settings. I named it GetClientRemindersSettings.
Again, he renamed it to GetClientReminderSettings. He's argument: Only the last word should be pluralized..
I would like to have your thoughts on this.
I think you're right in both cases. A WeakUpReminderSettings can be an aggregate of different settings without being a collection, and if your method return settings for multiple reminders, it makes sense to pluralize reminder even if it's not the last work.
Then again, naming conventions are really something subjective, if your coworker is not above you in the hierarchy, I'd tell him to stop messing with your work for minor changes like this.

Is "massive" usage of #region considered a bad practice? [closed]

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 9 years ago.
Improve this question
My MainViewModel has to deal with a lot of commands with complex actions inside, therefore its extension has grown inevitable. For keep the code organized I tend to use #region to group similar o related tasks.Does this considered an overuse of this feature or it's perfectly normal? You may say that it depends on me, if I feel right about it. I think that it helps a lot but I would like to know what do others. Here is a screenshot of how the code look like:
The bad practice is a massive single class. #region is simply hiding / coping with it.
If there are groups of methods, delegate them to another class.

Categories

Resources