0% found this document useful (0 votes)
83 views10 pages

Construction

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects" that contain data and code. The key principles of OOP are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation involves hiding data implementation and restricting access. Abstraction develops classes based on their interfaces rather than implementations. Inheritance allows classes to inherit attributes and behavior from other classes. Polymorphism means the same method can act differently depending on the object that calls it.

Uploaded by

coco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views10 pages

Construction

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects" that contain data and code. The key principles of OOP are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation involves hiding data implementation and restricting access. Abstraction develops classes based on their interfaces rather than implementations. Inheritance allows classes to inherit attributes and behavior from other classes. Polymorphism means the same method can act differently depending on the object that calls it.

Uploaded by

coco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Q1: Object Oriented Programming

Object-oriented programming (OOP) is a programming method based on the concept of


"objects", which may contain data, in the form of fields aka attributes; and code, in the form of
procedures, often known as methods. A feature of objects is that an object's methods can
access and often modify the data fields of the object with which they are associated .

Principles: Encapsulation,Abstraction,Inheritance,Polymorphism

Encapsulation
Encapsulation means that an object is generally hidden from view outside of the object’s
definition. Typically, only the object’s own methods can directly inspect or manipulate its
fields. Encapsulation is the hiding of data implementation by restricting access to accessors
and mutators.

Abstraction
-Abstraction is the development of classes, objects, types in terms of their interfaces and
functionality, instead of their implementation details.
-Abstraction denotes a model, a view, or some other focused representation for an actual
item.
-Abstraction is the implementation of an object that contains the same essential properties
and actions we can find in the original object we are representing.
Generalization is the process of extracting shared characteristics from two or more classes,
and combining them into a generalized superclass. Shared characteristics can be attributes,
associations, or methods.
 Specialization means creating new subclasses from an existing class.

Inheritance
Inheritance is a way to reuse code of existing objects, classes being able to inherit attributes
and behavior from pre-existing classes called base classes, or parent classes.

Polymorphism
Polymorphism means one object behaving as multiple forms, one function behaving differently
than the other or in simpelr terms the same method or property can perform different actions
depending on the run-time type of the instance that invokes it.
Q2: Objects

An object can be a variable, a data structure, a function, or a method, and as such, is a location


in memory having a value and referenced by an identifier.

Variables are entities  that


act or are acted upon. A variable declaration always
contains two components: the type of the variable and its name.
Types are mathematical variables that range in length. For instance byte
having 8 bites as length, short having 16, int having 32, long 64 and so on.

Method Overloading is a feature that allows a class to have more than one
method having the same name, if their argument lists are different. It is similar
to constructor overloading in Java, that allows a class to have more than one
constructor having different argument lists.

Implementing and initializing an object is done by declaring a list of


atributes that you desire for the object inside a class, then creating the new
object with the syntax Car car1 = new Car {Price= “ ” ; Designer=” ”}; and
manually declaring the values of its attributes.

A reference is an address that indicates where an object's variables and methods are
stored, you could call them coordinates.

The difference between class and objects is pretty basic.  

A class is like a blueprint. It defines the data and behavior of a type.

An object is basically a block of memory that has been allocated and configured
according to the blueprint it was designed to.

A NullReferenceException happens when you try to access a reference variable that isn’t


referencing any object. If a reference variable isn’t referencing an object, then it’ll be treated
as null. The run-time will tell you that you are trying to access an object, when the variable
is null by issuing a NullReferenceException.
Q3: Classes

A class is a construct that enables you to create your own custom types by grouping
together variables of other types, methods and events. A class is like a blueprint. It defines
the data and behavior of a type.

A method is a procedure associated with a message and an object. An object is


mostly made up of data and behavior, which form the interface that an object presents to the
outside world. Data is represented as properties of the object and behavior as methods.
The only required elements for defining a method are the method's
return type, name, a pair of parentheses, (), and a body between braces, { }.

The main purpose of get and set methods is to enable you to combine a pair of
functions into one property, and let you use a syntax that looks like a member access
expression or an assignment in place of syntax that looks like an explicit function call.
A constructor is a special method of a class or structure that initializes an object of
that type. A constructor is an instance method that usually has the same name as the class,
and can be used to set the values of the members of an object.
Difference between property/instance field:

An instance variable is unique to a class. By default, only the class and subclasses can
access it. A property is a public value that may or may not correspond to an instance
variable.
 Global variables are declared outside any function, and they can be accessed (used) on
any function in the program. Local variables are declared inside a function, and can be
used only inside that function.

The difference between class and objects is pretty basic.  

A class is like a blueprint. It defines the data and behavior of a type.

An object is basically a block of memory that has been allocated and configured
according to the blueprint it was designed to.

The difference between const and static keyword: Constant variables declares


with const keyword and can be used with primitive data types . Constants are set at
compile time itself and assigned for value types only. Static variable is a property of a Class
rather than the instance of class.
A Value Type stores its contents in memory allocated on the stack. Reference Types are
used by a reference which holds a reference (address) to the object but not the object itself.
Q4: Classes and Methods

A method signature is the method name and the number, type and order of its
parameters. Return types and thrown exceptions are not considered to be a part of the
method signature.

Class signature = ?

The calling method is the method that contains the actual call; the called method is the
method being called.

Access modifiers are keywords in that set the accessibility of classes, methods, and other
members. In C# there are 5 modifiers:
Private – Allows only the class to modify
Protected internal – Allows the same assembly and derived classes to modify
Protected – Allows derived classes
Internal – Allows the same assembly
Public – Allows everybody

The To.String method returns a string representation of the object. In general, the
toString method returns a string that "textually represents" an object. The result should
be a concise but informative representation that is easy for a person to read.

Yes, an object can contain references to other objects of the same class by attributing it
to an object that has been declared null.
Q5: Control structures (loops and conditions)

Loops and conditional statements are being implemented by declaring a condition inside a
conditional structure such as if or repetitive structure such as while,for,for each.
If(cond) -> actions
-else -> other actions

Or

If(cond) -> actions


-else if(cond) ->actions
-else if(cond) …….

While is used when we don’t know how many times we want to repeat a set of instructions
so we just repeat it until the condition is not true anymore.
For is used when we know how many times we want a set of instructions to be repeated so
we declare an increment, a step which helps the increment increase with a chosen amount
and the number of times we want for the instructions to repeat.
For each is used to repeat a set of instructions on a set of variables from a certain data
structure such as a class or a library. For each …int…. in ….class…
A switch statement is a type of selection control mechanism used to allow the value of
a variable or expression to change via a multiway branch. For instance if we assign two cases,
one for false and one for true, each with its own set of instructions, and our result ends up being
true, the variable will follow the instructions in the true case.

A Break statement breaks out of the loop at the current point or we can say that it
terminates the loop condition.
A Continue statement jumps out of the current loop condition and jumps back to the starting
of the loop code.
An infinite loop is a sequence of instructions which loops endlessly, either due to
the loop having no terminating condition, having one that can never be met, or one that
causes the loop to start over.
Q6: Collections

Some of the most known collections are Array, List and Dictionary.
An array or vector is a container object that holds a fixed number of values of a single type.
The length of an vector is established when the vector is created. After creation, its length
is fixed.
Ex. Int v[20], read and go through.

A list is an object which holds variables in a specific order. The type of variable that the list
can store is defined using the generic syntax. (List = infinite array)
Ex. List<int> numbers = new List<int>();

A dictionary is a collection of Keys and Values, where key is like word and value is like
definition and they’re used to identify objects that fit the description of the user (provided
through keys and values).
Ex. Dictionary<string,int> dictionary = new Dictionary<string,int>();

The  enum  keyword is used to declare an enumeration, a distinct type that consists of a set
of named constants called the enumerator list. Enums are used to increase compile time
when a variable can take only one out of a small number of values.
Ex. enum Days {Mon, Tue, Wed, Thu, Fri, Sat, Sun};

A collection is used for when you want to manage groups of related objects. Unlike arrays,
collections are way more flexible, the size of it being increased or shrunk depending on the
application’s requirements.

The main difference between the three of them is the amount of accesibility they offer when it
comes to storing data.
Q7: Exception Handling

Exceptions are a type of error that occurs during the execution of an application. Errors are
typically problems that are not expected. Whereas, exceptions are expected to
happen within application code for various reasons.
Exception handling is built upon four keywords: try, catch, finally, and throw.

A try-catch block can be used to handle an exception generated by working code. Some
exceptions can be handled in a  catch  block and the problem solved without the exception
being re-thrown;
There are 8 types of exceptions in C#:
System.IO.IOException
OutOfRange
ArrayTypeMismatch
DivideByZero
NullReference
InvalidCast
OutOfMemory
StackOverflow

A custom exception is a user defined exception created by deriving from the exception
class. The derived classes should define at least four constructors: one default constructor,
one that sets the message property, and one that sets both
the Message and InnerException properties. The fourth constructor is used to serialize the
exception.

Error management = ?
Q8: Unit Test (I have no fucking idea if anything is correct)
Unit testing is a method used for running your unit tests to maintain code health, ensure
code coverage, and find errors. This method is usually used by running certain parts of the
code progressively in order to make sure they run as intended.
Main annotations:
[TestClass]

[TestMethod]

[ClassInitialize]

[ClassCleanup]
[TestInitialize]

[TestCleanup]

[Ignore]

[TestCategory(“”)]

An AAA design pattern is a simple way to structure unit tests.


Arrange: This is the first step of a unit test application. Here we will do the necessary setup of
the test. For example, to perform the test we need to create an object of the targeted class, if
necessary, then we need to create mock objects and other variable initialization, something like
this.

Act: This is the middle step of a unit step application. In this step we will execute the test. In
other words we will do the actual unit testing and the result will be obtained from the test
application. Basically we will call the targeted function in this step using the object that we
created in the previous step.

Assert: This is the last step of a unit test application. In this step we will check and verify the
returned result with expected results.

Examples of methods from assert class:

AreEqual(Double, Double, Double) = Verifies that two specified doubles are equal, or within the
specified accuracy of each other. The assertion fails if they are not within the specified accuracy of
each other.

AreEqual(Double, Double, Double, String) = Idem ^+ displays message if not

AreEqual(Object, Object) = Verifies that two specified objects are equal. The assertion fails if the
objects are not equal.

AreEqual(Object, Object, String) = Idem ^ + displays message if not

Exceptions are tested by using an attribute like ExpectedException that takes a type
parameter and displays an error message if the exception is not thrown. If the method does
not throw such an exception,the test will fail.
Q9: MVVM,commands and observable collections

Model–view–viewmodel (MVVM) is a software architectural pattern.


It consists of 3 parts: Model, View and ViewModel.
Model refers either to a domain model, which represents real state content, or to the data
access layer, which represents content 
View is the structure, layout, and appearance of what a user sees on the screen.
View Model is an abstraction of the view exposing public properties and commands.The
view model has been described as a state of the data in the model.[7]

With the DataContext property, we are instructing the View to data-bind properties within
the View to the specified ViewModel instance. For example, when the runtime resolves a
binding expression in the View, it will attempt to find the its corresponding property in the
specified ViewModel instance.
Commands are used to separate the semantics and the object that invokes a command
from the logic that executes the command .
A relay command is used to bind command directly to ViewModel in order to avoid writing
code inside the View. It’s implemented by binding an action to a certain event.
An ObservableCollection is a dynamic collection of objects of a given type. Objects can be
added, removed or be updated with an automatic notification of actions. When an object is
added to or removed from an observable collection, the UI is automatically updated.
Binding requires:

- a view or set of UI elements constructed +  object that the bindings are going to point
to.
- The UI elements in a view are bound to the properties which are exposed by the
ViewModel.
- Bindings can either be OneWay or TwoWay data bindings to flow data back and forth
between the View and ViewModel.
Q10: XAML controls
XAML is the language behind the visual presentation of an application that you develop just as HTML
is the language behind a web page.

XAML controls: textbox/block, split view, img flip, image, scroll view, table etc.

Data Template describes the visual structure of a data object.

Item Template describes the visual structure of an item.

Both are usually used for ListView or ListBox.

DataContext is a general (dependency) property of all descendants of FrameworkElement.


Is is inherited through the logical tree from parent to children and can be used as an implicit
source for DataBinding. It does not do anything by itself, you must basically databind to it.

ItemsSource is the property identifying the source for templated generation of items in an
ItemsControl derived control 
I have no fucking idea what either of these are ^
Design Pattern is a general, reusable solution to a commonly occurring problem within a given
context in software design. It is not a finished design that can be transformed directly
into source or machine code. It is a description or template for how to solve a problem that can
be used in many different situations. Design patterns are formalized best practices that the
programmer can use to solve common problems when designing an application or system.
(TL;DR  typically shows relationships and interactions between classes or objects)

You might also like