susanBuck / e2-fall22

0 stars 0 forks source link

Single or Multiple Views #30

Closed bar181 closed 2 years ago

bar181 commented 2 years ago

I have three main sections/forms for project 2 that either "show" or "hide" depending on the form the user should complete.
Wondering if it is recommended to: 1) have a long, single view (e.g. index-view.php) and show/hide each form 2) have the index-view.php page act as the html template and include the form pages when they are necessary (e.g. on the index-view use php include for the setup-view.php) 3) have the main index.php page render different views depending on the form required (e.g. require setup-view.php instead of index-view.php (all the html stuff would be copied on each page)

Thank you for any suggestions/recommendations

RobertHolzhauser commented 2 years ago

Hi bar181,

So, I'm pondering similarly, and I think a concept worth considering along those lines that Susan mentioned during at least one of the lectures, is the D.R.Y principal (Don't Repeat Yourself).

You might consider something like a layout page (like an overall or master view) that has the overall structure of the page, and includes or requires each of the forms / other content, and toggle the visibility of those form / content pages as needed. Perhaps even dynamically requiring each form when needed.
That would keep it all on one page, and you wouldn't have to re-create the overall structure of the page.

On the other hand what we are doing on project 2 probably doesn't have a lot of nav, routing, styling that would need to be re-used.

Leap of speculations here, and sounds like you might have like a form that chooses options for the game, and a form that is part of the game play.

*If that's anywhere close, do you want to display the options chosen, in the set up form look / feel during game play? Or, do you want to hide them?

If you want them visible during the game, in the form - aka the same basic way they were entered, leave it on one page. If, on the other hand, you would prefer to hide those options, or display them very differently from the form on which they are selected, such as across a header type row, or whatever, maybe put them on separate pages.

Also, this isn't a math problem, where there is only one right answer. You have a lot of freedom to create. You could make a lot of different approaches work. That's one of the things beautiful things about being a developer, is the chance creatively express myself through code. One thing I like to do sometimes is to sort of pretend I'm an artist and code is my paint. That might sound a little different, but sometimes it helps me get into a frame of mind where I feel empowered to almost let code flow out of me. In other words to trust in the process, and just start coding and flow with it.

I don't know if any of that was helpful at all to get the creative juices flowing , so to speak, but I think I was also answering a similar question for myself. Sometimes we give others the advice we most need to hear.

Anyway, All the best, Robert

bar181 commented 2 years ago

@Robert Thank you for the insights. Great post. Yes, you got my creative juices flowing. And your artist analogy hit home for me. In the real world I schedule time for oil painting each week when I have intensive cognitive tasks at work/school.

Your speculation was correct. I am continuing a blackjack game with 3 different forms for set up, round options (wager amount ) and game play (hit or stand). While having everything on one page was good to get things working , the hide/show different sections makes the html very messy.

I decided to sit back and think of what would be done if this was a work project. Usually, I would use a framework and have different components for each form. In my game's situation, a master layout idea seems to make the most sense - call only the required form based on the user's progress.

Someone that uses javascript to make their page(s) dynamic might consider a different approach. I also think one page could work with 2 forms, but 3 forms starts to look messy in my case. I also agree with a one pager if form options are always available a user.

susanBuck commented 2 years ago

Great discussion, @RobertHolzhauser & @bar181. I also like the artist/paint metaphor and the idea that there are often many approaches to solving a problem.

And I agree with your final conclusion, @bar181:

In my game's situation, a master layout idea seems to make the most sense - call only the required form based on the user's progress.

I like the idea of the individual forms being in their own sub-views that are included/displayed as needed. This provides for nice separation/organization, without trying to jam multiple forms into one view.

It also sets up nicely for if a project like this evolved to use JavaScript where those sub-views could be translated to components that were dynamically toggled (without needing to refresh the page).

traveler9878 commented 2 years ago

I just want to commend you for taking on the addition of show/hide in p2!