Tutor profile: David C.
Questions
Subject: Java Programming
Given the following: public void changeMyNum (int myNum) { myNum = myNum; } Assume the method changeMyNum is in a class called MyClass which contains a field also called myNum. Will the field myNum in the class be updated by the above method?
No. In the above method changeMyNum, myNum is set to itself. In this case we see an issue with scope versus naming conventions. Since there is a locally scoped variable with the same name as a member field, the most specific, or in this case the locally scoped, variable will be updated. This means that myNum (the parameter) will assign its value to itself without ever interacting with the class field myNum. To resolve this, you could use either of the following statements as a replacement: this.myNum = myNum; or myClassNum = myNum; Both statements will work around the naming convention issue we see in the original question, either by naming the variables two different names, or by specifically invoking the "this." keyword which scopes myNum to use the instance-level field instead.
Subject: Software Engineering
What is the difference between the Waterfall model and the Agile model of software engineering? Advantages and Disadvantages?
The key conceptual difference between the two engineering models is that the Waterfall approach expects rigorous documentation and planning before development begins. With the Waterfall approach, you follow a linear life cycle, which is extremely structured. Agile, on the other hand, there exists a continuous iteration of development and testing throughout the engineering process. Agile breaks its planning stages into multiple "sprints," meaning that adaptation and iteration is more possible. This creates one key advantage of Agile, which is that the customer sees a working product more frequently and can thus provide feedback more easily as compared with Waterfall. A disadvantage of Agile is that, depending on the team involved and the client's requests, you can suffer from "scope creep," where the client adds more and more changes or features to an ever-growing list, and the project loses its original scope.
Subject: C++ Programming
Object-Oriented Programming in C++: What is the difference between a class and an object in C++? Why does this not apply to C?
Since C++ is an object-oriented language, it is capable of supported classes and thus objects. The difference between the two is that a class is essentially a user-defined data type, similar metaphorically to a blueprint. It can contain variables (also called data members or fields) and member functions which act upon instances of that class. When a class is instantiated, this is called an object, and herein lies the difference. You can have multiple objects or instances of a certain type of class, but there is only the one original "blueprint," which is the class itself. Conceptually, it would be the same as having multiple primitive int variables: a, b, c. These may hold different integer values, but they are all of the type "int." This doesn't apply to C, because C does not support classes (it is a procedural programming language, not object-oriented).
Contact tutor
needs and David will reply soon.