Basic programming Flashcards
What are the four pillars of OOP?
- Data encapsulation
- Data abstraction
- Inheritance
- Polymorphism
EAIP –> every apple is perfect
What is an object?
The physical presence of the class in memory
What is a class?
The blueprint from which objects are created. The class defines the different properties of a type of object
What is a method?
A block of code that performs some type of action on an object
What is an instance?
A unique reference (copy) of an object
What is data encapsulation?
Combining both data and methods into a class definition. It helps with hiding this data from the outside world as the scope will be limited to just that specific class. It means that only objects of that class have access to those specific private methods. We can also define public methods which can be called by other classes. (Dog example)
What is data abstraction?
Abstraction is an extension of encapsulation. It is the process of taking specific, required data from a larger pool of data. You may not always need all of the data that is available to you so you can choose to select and retrieve only the data that you need at that time - use example
What is inheritance?
Allowing one object access to some or all of the properties of another object - this process keeps your code DRY and prevents repetition. Example - classes for different buildings e.g. shop, house, hospital – instead of adding width, height, material, etc. properties to all of these classes, you could create a building class that these types of building would inherit from
What is polymorphism?
Directly translates to something that takes on many forms. It’s a method that lets us call the same method on different classes. E.g. different vehicle classes - car, truck. Can add the same method to both of these classes that spits out the type of vehicle it is –> the same class can therefore be called on different types of class to give different results.
What is SDLC?
Software Development Life Cycle. Refers to the end-to-end process of developing software. Stages include:
- Planning
- Analysis
- Design
- Development
- Testing/integration/QA
- Maintenance
- Optimisation
What are the disadvantages of the waterfall model?
- Working software is produced only at the end of the cycle
- Not suitable for complex projects
- Difficult to measure progress within each stage
- Not recommended for projects that may have frequently changing priorities
What is the waterfall method?
A method of software development where the process takes place in a linear, sequential flow - each phase must be completed before the next phase can be started.
What are the advantages of the waterfall model?
- Simple and easy to understand
- Everything is well documented and planned out
- Works well for smaller projects where requirements are very well understood.
- Phases are clearly defined
- Well understood milestones
What is the agile model?
Agile has an iterative approach that allows teams to deliver value to their customers faster than if they followed the waterfall model. The product will be delivered in smaller chunks rather than being held off and delivered in its entirety at the end. Teams can quickly respond to change as testing is continually taking place.
Scrum and Kanban are the most used Agile methodologies
What is a frame in HTML?
HTML Frames are useful for dividing browser windows into many parts where each section is able to load an HTML document separately.
It permits authors to present HTML documents in multiple views, which might be subwindows or independent windows. Multiple views provide help to keep specific information visible, while other views are replaced or scrollable.
Explain white box vs black box testing
- white box - tester has complete knowledge of how the app works, done by devs and QA specialists, more time consuming and exhaustive
- black box - not necessary to know exactly how the app works, done by end user but also by devs and QAs, done based on an end user perspective, less time consuming and exhaustive
Explain different levels of programming languages.
Low - the language that is understood by the machine - binary/machine language. Humans tend not to interact with it
Assembly - similar to machine language but uses words instead of numbers
Mid - serve as a bridge between the hardware and programming layer of a computer e.g. C
High - has strong abstraction from the computer hardware details. Most simple to learn by humans e.g. python, ruby
What is a variable?
Variables hold data which can be reused over and over again. The place of their definition determines their scope
What would be the answer to 6+1+”7”?
Type error as a string can’t be added to an integer without prior conversion
What is MVC?
MVC –> Model, View, Controller
MVC is an architectural pattern which consists of the models, views and controllers and it’s used in designing mobile apps and web apps. It’s used by frameworks such as Ruby on Rails. Each component of MVC has different responsibilities:
Model - the model handles the data and is connected to the database. Handles data validation, specifies the relationships between tables. Responds to controller requests.
View - controls the UI. HTML/CSS are managed here. This is what the user sees. The view speaks to the controller to ask it to retrieve the necessary data from the model.
Controller - the brains behind the operation. Responsible for speaking to the other components. Controller tells the model what to do and then processes data before sending it on to the view for the view to display to the user.
Benefits: provides a solid structure to our web app and means we don’t have to repeat ourselves. Separates UI from business logic. Easy to maintain.
Disadvantages: can be too complex for small apps.
What is routing in MVC?
A pattern matching system that is responsible for mapping incoming browser requests to specified controller actions. If there is no matching route then the browser will display a 404 error. Else it will direct the user to the correct page
Authentication and Authorisation in Web API
Authentication (devise - gem) is the process of verifying who someone is, whereas authorisation (pundit) is the process of verifying what specific applications, files, and data a user has access to.