Programming Interview Questions Flashcards
(126 cards)
What is Object Oriented Programming?
A computer programming model
Organises software design around data and objects, rather than functions and logic
What are the benefits of OO Programming?
Beneficial for collaborative development
Code reusability, scalability and efficiency
What is a class?
User-defined data types
Act as the “blueprint” for objects, attributes and methods
What is an object?
Instances of a class, with specifically designed data
What are the main principles of OOP?
Encapsulation
Abstraction
Inheritance
Polymorphism
What is Encapsulation?
All important info is privately contained inside of an object
Each object is held privately within a defined class
Provides greater program security and avoids unintended data corruption
What is Abstraction?
Objects only reveal internal mechanisms that are relevant for the use of other objects - focuses on what an object does rather than how it does it
Simplifies complex systems by modelling them at a higher level of detail while hiding unnecessary implementation details
Helps developers easily make additional changes over time
What is Inheritance?
Classes can reuse code from other classes.
Allows developers to reuse common logic while maintaining a unique hierarchy
What is Polymorphism?
The ability to present the same interface for different data types (e.g. 1 method “Draw” for multiple children Square, Circle of a “Shape” class).
Reduces need for duplicate code
Examples of mainly OOP languages?
Java, Python, C++
Examples of pure OOP languages?
Ruby
JADE
Emerald
Downsides of OOP?
Overemphasises data component of software development
Can be complicated to write or take longer to compile
Alternative to OOP?
Functional programming e.g. Erlang
Many advanced programming languages allow users to combine models, e.g. JavaScript allows the combination of OOP and functional programming
What are design patterns?
Common and reusable solutions to problems given a certain context
What are anti-patterns?
“Bad” design patterns
Benefits & risks of design patterns?
Proven solution
Reusable
Expressive and Elegant
Prevent need for refactoring code
Lower size of codebase
Risk: might fall back on design pattern when there’s a better way to solve this particular problem
How many design patterns are there?
23
Types of software design patterns?
Creational
Behavioural
Structural
What are Creational Design Patterns?
Used for class instantiation
They can be Class creation or object-creational patterns
What are Structural Design Patterns?
Used for communication between objects
Designed to increase functionality of the classes involved
What are Behavioural Design Patterns?
Design Patterns that focus on how objects communicate and interact with each other
What are the architectural design patterns?
MVC Model View Controller
MVP Model View Presenter
MVVM Model View View Model
Describe MVC
Model = backend logic and data
View = interface components to display data
Controller = Input is directed here first
Benefits & risks of MVC
Provides separation of concern, separating front-end and back-end code
Makes it easier to update the application without interruption
Exposing the model to view can introduce security and performance concerns
Common for web apps