Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object Relational Mapping exercise Task 4 has no hint #1973

Open
christian-elm opened this issue Sep 8, 2022 · 9 comments
Open

Object Relational Mapping exercise Task 4 has no hint #1973

christian-elm opened this issue Sep 8, 2022 · 9 comments

Comments

@christian-elm
Copy link

For a beginner, a hint here would be helpful here. Manually managing resources is quite a daunting task when having not dealt with it before.

@aage
Copy link
Contributor

aage commented Sep 9, 2022

@christian-elm Do you have a question on how to implement IDisposable?

@ErikSchierboom There is some info on this in the hints.md file, but not specifically for Task 4. Would it be desirable to duplicate it specifically for this task?

@christian-elm
Copy link
Author

@aage No, not specifically a question on how to implement the interface. What tripped me up as a junior was that task 4 aborts a database transaction, but I as the "author" of the code don't have direct control of state - calling Database.Write changes the database to a state, but the method caller calls instance.Dispose() which also changes the state. So I would have liked a hint on how to work around this problem when not having direct control of the state of the data layer.

What I can see in the file isn't relevant enough for Task 4 to be duplicated.

@christian-elm
Copy link
Author

Also just for consistency's sake it would be nice that all tasks have their hints (they are always very helpful when you get stuck), or at least the tasks that are required in order to unlock new concepts and exercises.

@aage
Copy link
Contributor

aage commented Sep 12, 2022

@christian-elm I'm sorry, but I don't understand what is unclear. The instructions mention the Orm class needs to clean up the Database half way through a transaction (Dispose right after Write). The task is to implement this code.

Do you have a suggestion of what a hint might be that would clear this up? Adding hints to the two tasks that have none is easy enough.

@christian-elm
Copy link
Author

@aage It might be a bit difficult for me as a novice to explain. What trips me up: in Task 2 I'm instructed to call Database.Write(), which changes the state of the database to DataWritten unless an exception is thrown. So, when the test method calls orm.Dispose(), the state of the database has already changed to DataWritten.

My understanding of the exercise instructions is that this is expected behavior, so: what I fail to understand is how I can prevent the state of the database to change to DataWritten when I have implemented a Database.Write() call in task 2.

If this still doesn't make it clear, perhaps it's better to close this issue. Unfortunately I don't have any suggestions for hints as I have yet to complete the exercise myself, which means I don't yet have a good grip on how to properly implement the IDisposable interface.

@aage
Copy link
Contributor

aage commented Sep 18, 2022

@christian-elm I don't think you're supposed to prevent the state being DataWritten, I think the whole point is how you clean up when being in the middle of a transaction. Hint: you probably can just call Dispose on the Database. I hope this helps.

Can this issue be closed as far as you're concerned?

@aage
Copy link
Contributor

aage commented Sep 18, 2022

@christian-elm I've given the code another look, I think I know now what you mean. When calling the database you should Dispose the database when an Exception occurs. This goes for the Write method and all the others (except Dispose). The bad write throws an exception which you can try/catch.

Hopefully this answers your question, sorry for the confusion on my end!

@christian-elm
Copy link
Author

@aage I managed to figure it out eventually and solve the exercise. Thanks for sticking with it and trying to help! You can probably close this issue now.

@aage
Copy link
Contributor

aage commented Sep 19, 2022

@christian-elm Great!

@ErikSchierboom Can you close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants