Module 4 Final Challenge

As I am attempting to do the final challenge for Module 4. I realized I really suck at doing it from scratch. the previous challenges have helped in concept and lesson sense (much better than module 2). However, I am nowhere able to complete it without getting help from solutions and the hint video.

Question 1: How should I continue to go about this final challenge. Should I use the help of the solutions. Then try to just do it again? Or move on? or redo the entire long module? etc?

Question 2: I really don’t even know how to begin the challenge from scratch. What recommendation order do people do things in. Here were my attempted steps:
Copy the Image assets/ Json Data file
Create the Main Model.
Create the View Model??? (I had to refer to the solution for this)
Create the Views. And which view to start with first? Do people work from the last View first? or the starting View? They are all referenced through each other, so which do they start with.

What is the order that some of the most experienced coders go through. Rather than the solution and hints. I wish there was a video of how to do the program from start to finish? When looking at Recipe List App or the Pizza App we did, we were just adding on steps as previous modules. But how would one do it from fresh?

Based on the solution, would experienced coders do BookList>Staging>BookContent>BookPreivew (didn’t even know there was a book preview, mine had 3 views) or vice versa?

Am I so lost that maybe coding isn’t for me? I can’t even do the apprentice courses, how will I even attempt the Performer courses?

Hey Wutodouble!

First of all, let me ask you this: do you enjoy learning to code? Because if you do, then coding IS for you, period :grinning_face_with_smiling_eyes:
Don’t worry about how fast you learn things or how stuck you may feel on certain concepts. I’ve just started learning to code this summer myself, so trust me I understand how you feel, I’ve just been there.

To answer your questions:

Question 1: personally, I was also stuck at this challenge. So I “gave up” and checked the solution. I realized there was no way I could ever have coded all this myself! And I did feel some doubts like you do now.

What I did next is study carefully every piece of code in the solution. Everything that was difficult for me to understand, I documented in detail on Notion just like this (screenshot from my own M4 Wrap Up Challenge doc):

Then the most important step: I created a new project from scratch, but with the acquired understanding of the solution. So I tried to re-build everything myself with as little help as possible from the solution, but not without a few shameless peeks at it.

My code buddy @florentp underwent exactly the same process (got stuck, checked solution, tried to re-build again) and ended up having fun with the UI and learnt new things online in the process


From being absolutely stuck to having fun with the project

Anyway, bit of a long post but I hope it’s reassured you that coding can feel hard, but it’s also a lot of fun so it doesn’t matter how long you take to figure things out

Cheers!

1 Like

By the way! Question 2:
Personally, I always start with the model, then the view model.
Then I create the views and “hard code” everything like Text(“Button1”) for button1 that I’ll code later
Then I “hook everything up” between the view model and the views.
I tend to code all the views separately and then connect then later, from the “top” to the “bottom”

But it’s probably just a personal preference

1 Like

This seems the be the part I’m having the trouble the most with. Creating the views and booking it up.

Yeah I have some trouble with hooking the views up together too. I always open up examples from the courses on a separate screen when I build a new project so that I can easily revert back to previous work I’m comfortable with.

It helps avoid making mistakes and it helps with my horrible memory for syntax. It’s sort of “cheating”, but I get the job done and down the road I’m sure that as I keep practicing I won’t need to do that as much.

I suspect many people learn that way? It’d be interesting to hear about other beginner testimonies. Anyway. Just keep going wutodouble, you’ve got this!

1 Like

This probably sounds terrible, but I’ve been beating myself up over this challenge for about a week now… I think I am going to try to go through module 5 and 6, and maybe revisit this. Hopefully that’ll help some of my issues and my block. How bad of an idea is this?

Yeah no don’t do that. Do this instead:

Go through the solution. Don’t try to rebuild it yet, just try to understand all the code.

When there’s something specific you don’t understand, it’s fine just come back to this thread and copy paste it properly. Explain exactly which part you don’t understand and you’ll get help.

Be patient and we can go bits by bits like this until you get the whole thing

In the Model, up until this point, I’ve used data types rather than using specifics. but it actually caused a lot of previewing Building errors for me. when should you specify in the model vs use just the data types.

    
    var id: Int
    var title:String
    var author:String
    var isFavorite:Bool
    var rating: Int
    var content: [String]
    var currentPage: Int
 ...
vs
...
   
    var id = 1
    var title = "Title"
    var author = "Author"
    var content = ["I am a test book."]
    var isFavourite = false
    var rating = 2
    var currentPage = 0

Best I can explain is specifying a default value for your model properties allows you to create an instance of the model without having to initialise it.

When a preview is relying on a model instance, if this instance has not yet been initialised (aka have specific values for its properties) then it’s going to generate errors for the preview, since the preview doesn’t know what values to display for this instance. Hope that makes sense

Hi!
I also have problems with this challenge. I have glanced at the solution but tried to build it myself. But som strange things happens and my list look crazy. I would really like to know what I am missing here.

The Preview looks alright, but the list view looks really bad. What is going on here?


I think the GeometryReader is causing you problems when the BookPreview is inserted into the List View.

Looking at the BookPreview in isolation gives you the illusion that it is doing the right thing but in a List View it reacts quite differently.

You would be better advised to remove the GeometryReader altogether from that View. You have the basics pretty good without it and a little fine tuning will get you the result you need.

(edit) I did some testing on my own version of the project and by wrapping the equivalent BookPreview code that you have in a GeometryReader causes this effect in my List View which is what you are experiencing.

Removing it I get this as the expected result.

Ah! Thanks!

1 Like