Hi I have one more question.Hey DrDusk!
If you know programming paradigms could you please explain to me the answer to this question from the 2015 HSC. For some reason its just not clicking.
Thanks, :)
Thank you very much for the answer. Its making sense but the scenario mentions nothing about other methods that can access the array so how can we just assume?The question states that it's a fragment of code - so we're not given the full code, only a portion of the implementation. So we can assume there are other methods that enact on the code provided! :)
Ah I see but then in this question from the 2014 hsc, why cant we just move the open_account method to the private class, so it cannot be accessed by FastCash?Hey, no need to apologise! That's why we're here to help :-)
Also the answer says add an empty version of the open_account method to the private section of FastCash, but if were adding an empty version why does it need to be in the private section? , because if it is empty then it wont perform any function for the FastCash class anyway.
Sorry for the barrage of questions, this topic was not taught to me very nicely :(
Thanks,
Hey @opengangs,Hey, cthulu!
I saw you mention bogosort and it made me wonder if you marked the last Alcon. I'm curious if my attempt at the sort was somewhat correct.
Cheers!
Hey, cthulu.
So a private class is a nested class like we see in the previous questions. That means the methods from the outer class can access the methods in either the private or public nested class.
Now, the difference between a private and a public class is that a private class cannot have its data changed by any other method in the outer class. But these methods can still access anything inside the private class!
So in short, other methods CAN access all the data inside the private class; they just cannot alter or write to it!
@Cthulu
Yeah, that’s definitely one of those iffy ones that change with time. There are pros and cons for both approaches, but keep in mind that the syllabus hasn’t changed since 2011 (meaning RAD doesn’t produce as high quality and secure code as it does now).
I totally see where you’re coming from though. The fact that it’s a small business is also an indicator that they probably don’t have the time nor budget for a large scale structured-approach program.
I think for the purposes of the exam, err more on the side of conservative. As a gross oversimplification, Structured is for high performing code that’s like “try and hack me, I dare you”, while RAD is more “it works but only if you don’t try to mess with it”.
Thoughts?
@Opengangs so method inside a private class can be accessed but its data cannot be altered.Methods and data in the private class can be accessed if it is under the same outer class.
Firstly what do you mean by altered? Do you mean that it cannot be processed differently depending on what class?, i.e. you cannot use polymorphism on it
Secondly the sample answer says place the open_account method in the private section so it cannot be accessed, but this contradicts that it can be accessed but not altered.
Thanks for this reply, it makes sense. But I am still torn simply due to the fact that a structured approach requires a big budget. How about a prototyping approach?
@opengangs according to that, I don't see a problem with just moving open_account to the private section of the Teller class. This way FashCash cannot access it or retrieve its data which is good as it wont be able to open up an account. However the teller class can access it, but it can't change its data, which I don't see a problem with. Would there be a problem with Teller not being able to change the data in open_account?Re-read the question!
Such there should not be a problem with adding open_account to the private section of Teller