Shared Flashcard Set

Details

Week 8
programming principles
13
Computer Science
Post-Graduate
11/09/2017

Additional Computer Science Flashcards

 


 

Cards

Term
1.Outline the main differences between procedural programming and object oriented programming.
Definition
Procedural programming: programs are broken down into procedures (eg functions) that operate on shared data.
- more linear approach with code generally running from top to bottom calling functions as necessary
-simpler approach - easier to learn

OOP: broken down into objects which encapsulate data and procedures
- looks for related groups of data + procedures that can be encapsulated together into abstract objects.
- more complex but can be more reusable and scaleable
Term
2.What does the concept of "encapsulation" refer to in object oriented programming?
Definition
combine data + procedures into a single object - core concept of OOP. Allows data to be hidden and protected, only accessible via the procedures of the object (its interface)

data (attributes) and related procedures (methods)
Term
3.Describe how a class and an object relate to one another.
Definition
class: blueprint of an object / data structure. this is what defines the attributes and methods.

object - instance of a class. values of attributes are unique to each object but all objects in the class implement the same methods
Term
4.Define the terms "constructor", "attribute" and "method" in relation to object oriented programming.
Definition
constructor: initialiser method. Called whenever an object of the class is created + gives its attributes initial values as necessary. Makes sure the object is ready to use.

attribute: data in an object 9within a class). Properties or fields in other languages.

method: procedures and functions used as the interface
Term
5.What is the difference between a private and a public attribute?
Definition
Private: only accessible internally

public - accessible externally.

Most attributes are private and most methods are public
Term
6.Why is it useful to have getter and setter methods rather than public attributes in a class?
Definition
Making them private gives you control over what values that can contain. Modifications must be made through a method you define (data type, range etc).

These methods to simply read or change an attribute - very common
Term
7.How do you make an attribute or method private (instead of public) in Python?
Definition
add two underscores to the start of the name

self.results #public
self.__results #private
Term
8.What does the "__str__" method do in a class in Python?
Definition
represent or summarise the current state of an object as a string (used for debugging or presentation)
Term
9.How do the names of constructors differ between Python and other languages such as Java and C++?
Definition
??
Term
10.What is Unified Modelling Language (UML)?
Definition
set of diagram standards (visual language) made to assist in the design and representation of object oriented systems
Term
11.Draw a UML class diagram representing a "BankAccount" class (invent some attributes and methods).
Definition
[image]
Term
12.Outline the process of Noun/Verb Analysis.
Definition
1. Gather written info about the problem domain
2. Identify nouns and verbs (potential classes and methods)
3. Refine the list to define appropriate classes and methods
Term
13.What properties should classes have that you define when designing an object oriented system?
Definition
- represent something recognisable in the problem domain
- have a small, well-defined set of responsibilities(methods)
- have high cohesion (methods focused/related to each other)
- have low coupling (low interdependency between classes)
Supporting users have an ad free experience!