Lecture 1 Notes Flashcards
What is a program?
A list of instructions for a computer to execute.
What are Machine Languages?
Languages used by the computer, but difficult for humans to read.
What are assembly languages?
Symbolic translation of machine code which are easier for people to read (but still kind of hard)
What are high-level procedural languages (such as Pascal, Fortran, and C)?
More human-readable languages that can be converted into assembly language and then assembled into machine code.
What are Object-Oriented Languages (C++, Java, Smalltalk)?
Languages that encapsulate their data and procedures together in units called objects, which contain more than just functions. This makes the code more modular and readable to humans.
What is the C programming language?
A high-level procedural programming language.
What is the C++ language?
An object-oriented programming language based on the C programming language.
What is an object?
An encapsulation of data and functions that act upon that data.
What are the three aspects of an object?
- Name – The variable name given to the object.
- Attributes (member data) – The data that describes what the object is.
- Behavior (member functions) – behavior aspects of the object, aka functions that describe what the object actually does.
What is a class?
A blueprint for objects.
A class is a user-defined type that describes what a certain type of object will look like. A class description consists of a declaration and a definition (usually split into separate files.)
An object is a single instance of a class.
What’s the difference between a class and a struct?
They are essentially the same but with one key difference:
Structs have all their data and functions public by default, whereas Classes are private by default.
As a side note: Struct is still important for use in C++ because it is backwards compatible with C (which does not have Classes, but does have Structs.) C Structs can NOT contain functions, but C++ Structs can, so that’s important to know.
The use of a Struct or Class in your code is largely down to your personal style or preference since they are essentially interchangeable as far as functionality.
What does DDU design stand for?
Declare, Define, Use
What is the Declare portion of DDU design?
A declaration gives an interface.
A variable declaration gives the type.
A function declaration tells how to use the function (without any specifics on what it does.)
A class declaration shows what an object will look like and what its available functions area.
Implementation details are not needed for declarations.
What is the Define portion of DDU design?
A definition usually consists of the implementation details. This isn’t necessary for the user of the interface to know. It’s essentially the code (or function body) of the function. A class definition consists of the definitions of its members.
What is the Use portion of DDU design?
The use of an item through its interface.
The user of a function is a programmer who makes calls to the function without needing to know its implementation details.
The user of a class is a programmer who uses the class by creating objects and calling the available functions for those objects.