7. Instantiation Nation

Okay. I’ve been tweaking this, trying everything, looking at other people’s problems but I haven’t got anywhere. I really don’t know what could be the problem. Please help me, thanks.

class Computer
def initialize(username,password)
@username = username
@password = password

    @files[username] = password
def Computer.get_users
    @@users = users
my_computer = Computer.new("peter1",5776)
def create(filename)
    @time = Time.now
    puts "A new file was created with username #{username} and password #{password}"


Don’t make random changes or look at what other people wrote without knowing what you’re looking for. Instead consider how your code behaves differently from what you want it to do, that’s what says what you need to change

Well thanks for the advice, but I realise that I should know the code through and through, but at this stage I really don’t, I’m still learning. I have followed the instructions carefully and I cannot understand why it’s not working. Peer review and experimentation is only a last minute resort, as is posting here. Please don’t take this the wrong way but some more substantial guidance would be more useful.

No, really. That’s the next thing you should do. Run it and consider what it’s doing differently from what you want.

If you don’t know how to address that difference, then that’s something you can ask about - you’d want to explain that difference, show what you tried so far.

You seem to be saying that you’re aimlessly changing things up seeing if it has an effect. Why would it? Gotta start by identifying the problem, and then fix that (without touching anything else)

If your code is just slipping away from you, no clue what’s going on, then that’s some kind of knowledge debt. You need to start at some end, identify a problem, re-read instructions to figure out what that part of the code should be doing, learn about how to do that something, fix that code… and move on to the next problem.
This could take a while. That doesn’t make it the wrong approach.

Have you got a good idea of what the whole code is supposed to be doing? Could you describe each part in English? If not, then you’ve just identified a problem (which is good, because now there’s something to fix) and fixing it is done by studying the instructions.

Or, if you do know just how each part should behave, then you can test those things. Use your code in ways that tests what it’s supposed to do - see if you can do the operations that the instructions describe. If there’s some operation that isn’t being carried out correctly, then you can start thinking about why it should have worked, what the program should have been doing to support that, and then go look at the corresponding code and see if it’s really doing those things, perhaps adding additional prints to get more information about what it’s doing as it’s running.

As you do each exercise you can also consider what each part you wrote should be doing, and test it yourself to see if it really does have the behaviour that you think you just implemented. You might want even want to start over a few exercises earlier in order to do this and/or to be more meticulous about how closely you follow what the instructions describe.

Also, you ask for something more substantial, but you haven’t described a problem or asked a question. You’ve said: “help” – so since the first thing you’re missing is that you’re not identifying what’s wrong, that’s exactly what I’ll be helping with.

But the reason that I’ve arrived at this stage of asking for help on the forum is because I understand every part of this, and I don’t understand why it is not working, despite having checked different things. No, I’m haven’t described a problem - because I have absolutely no idea what the problem is. There seems to be no problem to me so I can’t understand why it is not working. I asked for general assistance without referring to any specific part, but I don’t see anything wrong with that. I hoped that by posting to the forum I might be able to learn something from someone with more experience. Otherwise I won’t be able to finish this course, which would be a shame. But never mind.

I also gave suggestions on how to investigate what could be wrong.

You must know something about what the problem is, there must be something that you want to change about the code - otherwise you wouldn’t know that there is a problem at all.

If you only partly know what the problem is, then you can explain what you know and explain that you’re unable to find out more about the problem. That would still describe what the issue is, that would say a lot about what you’re looking for.

It doesn’t matter where in the process you’re stuck - there’s always going to be something to describe, something to ask about.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.