Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Programming #3

From all lessons in "Building Program Structure"

TermDefinition
Sequential/Procedural Design Centered around functionality. A mathematical view of a program. Programs transform information. This is how functions and algorithms are made.
Object-Oriented design Centered around information. An engineering view of a program. Emulates how the real world is built
Classes Blueprint for creating objects. Custom type. Always represents one thing (ex. Employee). Has attributes(variables) and methods(functions)
New objects from a class billy = Student()
Accessing object attributes Use dot notation to access the attribute. ex: student1.name
Methods Declared and defined in a class. Statements are related to the object and work with the object's attributes. Passes self - def method(self, parameter):
Initializer Each time an object is instantiated from a class, this method runs. The default initializer is hidden and does nothing. def __init__(self):
Customized initializer Pass parameters into __init__ using class name when object is instantiated. in class - def __init__(self, species): self.species = species / in program - pet1 = Pet("cat")
Encapsulation Hiding how the inside of a class works from the rest of the source code, only providing access to what's necessary
Protected attributes For internal use only. _species = ""
Private attributes For internal use and even harder to access. __species = ""
Accessor method Purpose is to return (get) the value of an attribute. Same return type as the attributes whose value is being returned. No parameters other than self. Start with "get". def getName(self): return self.name
Mutator method Purpose is to change (set) the value of an attribute. No return type. One parameter of the same type, as well as self. Start with "set". def setName(self, newValue): self.name = newValue
Has (Association) Attributes are used to implement a the relationship. An object that is "stored" as an attribute can be used by any method within its associated object. Permanent relationship, existing while the object exists
Uses Simplest and weakest relationship. An object is provided to the client object for temporary use. Temporary relationship, existing while one object uses another
Is (Inheritance) Deriving a new class from a base class. The parent class is a generalization of the child class. The child only inherits from one parent
Overriding A child can create custom versions of attributes and methods already declared in the parent class
Exception An event that occurs during the execution of a program that is unexpected by the program code. Also the name of the parent class. Exceptions can get caught along the call stack, so they can occur in one method and be caught in another
ValueError Ex. trying to transform "abc" into a number
NameError Using a variable, method, or type that has not been declared
TypeError An operation or function is applied to an incompatible type
IndexError / KeyError Accessing array elements or keys from locations that do not exist
ArithmeticError Base class for all arithmetic error such as OverflowError, ZeroDivisionError
RecursionError The call stack has reached its memory limit, usually due to infinity recursion (method calling itself)
Exception handling Handles an unwanted event, an exception so that the program code still makes sense to the user
try-except Executed in order. Order from more-specific to less
Throwing/raising exceptions Only use if something is truly wrong. Doesn’t replace an if statement. Exception shouldn't appear in "normal program flow". Do it if a method can’t do what it's supposed to. After throwing an exception the method is interrupted and does not return a value
raise When notifying of an exception, raise one. It is similar to "break", not running any code afterwards. raise ValueError("That's not a good number to use")
finally Executes whether the code raises an exception or not
User defined errors A class that derives from Exception. It doesn't always need specific code, just "pass" is okay. It can define additional properties, override virtual methods and properties, and define specific constructors.
Instance field variables Declared in a class to store data/info as an attribute. Each object can store a different value
Static field variables Value does not change from object to object. Tied to the class, not the object. Shared by objects of the same class. Preface with s_. Not added to the object self, access it with [class name].[field name]
Class methods Methods shared by all objects of the same class. Have access to static field variables but not instance field variables. First parameter is cls, not self. Use the @classmethod decorator. Called using [class name].[class method name]
Static methods Methods shared by all objects of a class. No access to instance or static fields. Used for utility functions that don't rely on class or instance state. Use the @staticmethod decorator. Called using [class name].[static method name]
Created by: jolly_n4
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards