GoConqr has a new look! Let us know what you think.

Flashcards

INSY 4306 Ch.7

Christopher Le English 42 cards

Cards in this deck (42)

  1. 1Divide and ConquerConstructing a large app from small simple pieces
  2. 2Common ways of packaging codeProperties, methods, classes, and namespaces
  3. 3Framework Class LibraryProvides many predefined classes that contain methods for performing common tasks
  4. 4User-defined MethodsMethods that you write
  5. 5Methods allow you to modularize an app bySeparating its tasks into reusable units.
  6. 6Client CodeCode that calls a method
  7. 7ClientAny statement that calls the object’s method from outside the object is a client of the method.
  8. 8Class MathProvides a collection of static methods that enable you to perform common mathematical calculations.
  9. 9Class Math also declares two static double constants that represent commonly used mathematical valuesMath.PI and Math.E.
    These constants are declared in class Math as public and const.
    Public allows other programmers to use these variables in their own classes.
    Keyword const prevents its value from being changed after the constant is declared.
  10. 10When objects of a class containing static variables are created, all the objects of that class share one copy of the class’s static variables*
  11. 11Main is sometimes called the app’s:Entry Point
  12. 12Declaring Main as staticallows the execution environment to invoke Main without creating an instance of the class.
  13. 13Comma-Separated ListWhen a method has more than one parameter
  14. 14Variables should be declared as fields of a class onlyif they are required for use in more than one method
  15. 15String ConcatenationAllows you to combine strings using operator + .
    When one of the + operator’s operands is a string, the other is implicitly converted to a string, then the two are concatenated.
    If a bool is concatenated with a string, the bool is converted to the string "True" or "False".
  16. 16There are three ways to return control to the statement that calls a method.Reaching the end of the method.
    A return statement without a value.
    A return statement with a value.
  17. 17A static method can call only other static methods of the same class directly (i.e., using the method name by itself) and can manipulate only static variables in the same class directly. To access the class’s non-static members, a static method must use a reference to an object of the class.*
  18. 18StackLast-in, first-out (LIFO) data structure.
    Elements are added by pushing them onto the top of the stack.
    Elements are removed by popping them off the top of the stack.
  19. 19Stack OverflowWhen so many method calls occur that the stack runs out of memory
  20. 20Activation Record or Stack FrameThe local variables that are stored by the program-execution stack
  21. 21Argument PromotionThe implicit conversion of an argument’s value to the type that the method expects to receive.
  22. 22Promotion RulesSpecifies which conversions can be performed without losing data.
    An int can be converted to a double without changing its value.
    A double cannot be converted to an int without loss of data.
    Converting large integer types to small integer types (e.g., long to int) can also result in changed values.
  23. 23Cast OperatorUsed in cases where information can be lost, used to force the conversion
  24. 24NamespacesCategories of related classes where predefined classes are grouped into
  25. 25Objects of class Random can produce randombyte, int, and double values
  26. 26Method Next of class Random generatesan int value
  27. 27Pseudorandom Numbersvalues returned by Next
  28. 28Scaling Factorreturns a value from 0 up to, but not including, the argument’s value.
  29. 29Shifting Valuenumber = randomNumbers.Next( shiftingValue, shiftingValue + scalingFactor );
    shiftingValue specifies the first number in the desired range of consecutive integers.
  30. 30Scaling Factornumber = randomNumbers.Next( shiftingValue, shiftingValue + scalingFactor );
    scalingFactor specifies how many numbers are in the range.
  31. 31SeedThe calculation uses the current time of day to seed the random-number generator. --
  32. 32Enumerationdeclares a set of constants represented by identifiers, and is introduced by the keyword enum and a type name.
    When an enum is declared, each constant in the enum declaration is a constant value of type int.
    If you do not assign a value to an identifier in the enum declaration, the compiler will do so.
    If the first enum constant is unassigned, the compiler gives it the value 0.--
    If any other enum constant is unassigned, the compiler gives it a value equal to one more than the value of the preceding enum constant.--
  33. 33The scope of a declarationthe portion of the app that can refer to the declared entity by its unqualified name.
    The basic scope rules are as follows:
    The scope of a parameter declaration is the body of the method in which the declaration appears.
    The scope of a local-variable declaration is from the point at which the declaration appears to the end of the block containing the declaration.
    The scope of a non-static method, property or field of a class is the entire body of the class.
  34. 34Method OverloadingWhere methods of the same name can be declared in the same class as long as they have different sets of parameters
    Declaring Method Overload:
    Class MethodOverload
  35. 35Signaturea combination of the method’s name and the number, types and order of its parameters.
    Used by the compiler to distinguish overloaded methods
    Method calls cannot be distinguished by return type.
  36. 36Optional Parametersallow the calling method to vary the number of arguments to pass.
    An optional parameter specifies a default value that’s assigned to the parameter if the optional argument is omitted.
    You can create methods with one or more optional parameters.
    //Has a default value
  37. 37Named Parametersenable you to call methods that receive optional parameters by providing only the optional arguments you wish to specify.
    // sets the time to 12:00:22
    Public void SetTime(int hour=0, int minute =0, int second =0 )
    Vs.
    t.SetTime( hour: 12, second: 22 );//12:00:22PM
    t.SetTime (12) // 12:00:00PM
    t.SetTime (12, 35) // 12:35:00 PM
    //Has no parameters
  38. 38Recursive MethodMethod that calls itself
    A recursive method is capable of solving only the base case(s).
    Each method call divides the problem into two conceptual pieces: a piece that the method knows how to do and a recursive call, or recursion step that solves a smaller problem.
    A sequence of returns ensues until the original method call returns the result to the caller.
  39. 39Pass-By-Valuea copy of its value is made and passed to the called function.
  40. 40Pass-By-Referencecaller gives the method the ability to access and modify the caller’s original variable.
  41. 41Keyword refallows you to pass a variable to a method by reference--
    The ref keyword is used for variables that already have been initialized in the calling method.
  42. 42Keyword outcreates an output parameter.--
    This indicates to the compiler that the argument will be passed by reference and that the called method will assign a value to it.
    A method can return multiple output parameters.

Information

Description
Flashcards on INSY 4306 Ch.7, created by Christopher Le on 16/10/2015.
Created by
Christopher Le
Views
0
Rating

More on Functions and Program Structure

Feedback

What is it about?

What do you think of the new look?

How do you like it?