0% found this document useful (0 votes)
4 views7 pages

IP Solid

The document provides an overview of object-oriented programming concepts, including design patterns, principles, and methodologies. It details various types of design patterns such as creational, behavioral, and structural patterns, along with anti-patterns and principles like SOLID, DRY, KISS, and YAGNI. Additionally, it discusses OOAD, OOD, and OOA, emphasizing the importance of effective design and responsibility assignment in software development.

Uploaded by

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

IP Solid

The document provides an overview of object-oriented programming concepts, including design patterns, principles, and methodologies. It details various types of design patterns such as creational, behavioral, and structural patterns, along with anti-patterns and principles like SOLID, DRY, KISS, and YAGNI. Additionally, it discusses OOAD, OOD, and OOA, emphasizing the importance of effective design and responsibility assignment in software development.

Uploaded by

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

Solid udemy

Part 1: OOP & Design Patterns Interview - Questions and Answers

WHAT ARE DESIGN PATTERNS?

Design patterns are reusable solutions to common problems encountered in software development.

WHAT ELEMENTS IS THE DESIGN PATTERN COMPOSED OF?

In general, a template consists of four main elements:

name. The exact name provides an opportunity to immediately understand the problem and determine the solution.
a goal. Scope within the framework of solving a specific problem;
solution. An abstract description of the design elements of the design problem and how to solve it using a generalized set of classes;
results.

WHAT TYPES OF GOF PATTERNS DO YOU KNOW?

Creational patterns, structural patterns and behavior patterns as well as anti-patterns are distinguished.

NAME THE CREATIONAL PATTERNS AND BRIEFLY DESCRIBE THEM

Creational patterns are intended to organize the process of creating objects.

The most common patterns are:

Abstract Factory - provides an interface for creating related objects of families of classes without specifying their specific
implementations (families of product objects);
Factory Method - defines an interface for creating objects from a hierarchical family of classes based on the transmitted data (subclass
of object that is instantiated);
Builder - creates an object of a particular class in various ways (how a composite object gets created);
Singleton - guarantees the existence of only one or a finite number of instances of the class (the sole instance of a class);
Prototype - used when creating complex objects. Based on the prototype, objects are stored and recreated, for example, by copying.
NAME THE BEHAVIORAL PATTERNS AND BRIEFLY DESCRIBE THEM.

GoF behavior patterns characterize the ways in which classes or objects interact with each other.

Behavioral patterns include:

Chain of Responsibility - organizes a chain of recipient objects that do not know the capabilities of each other, independent of the
sender object, and pass the request to each other (object that can fulfill a request);
Command - used to determine, by some attribute, an object of a particular class to which a request will be passed for processing (when
and how a request is fulfilled);
Iterator (Iterator) - allows you to sequentially traverse all the elements of a collection or other composite object, without knowing the
details of the internal data representation (how an aggregate's elements are accessed, traversed);
Mediator - allows you to reduce the number of connections between classes with a large number of them, highlighting one class that
knows everything about the methods of other classes;
Memento - saves the current state of the object for further restoration;
Observer - allows for a one-to-many relationship between objects to track object changes;
State - allows an object to change its behavior by changing the internal state object.
Strategy - specifies a set of algorithms with the ability to select one of the classes to perform a specific task during object creation (an
algorithm);
Template Method - creates a parent class that uses several methods, the implementation of which is assigned to derived classes (steps
of an algorithm);
Visitor - Represents an operation in one or more related classes of some structure that is called by a method specific to each such
class in another class (operations that can be applied to object(s) without changing their class(es));
Interpreter - for a certain way of presenting information defines the rules (grammar and interpretation of a language).

NAME THE STRUCTURAL PATTERNS AND BRIEFLY DESCRIBE THEM.

Structural GoF patterns are responsible for the composition of objects and classes, and not only for bringing together parts of an
application, but also for separating them.

Structural patterns include:

Adapter - is used when it is necessary to use classes together with unrelated interfaces. The behavior of the adaptable class is
changed to the required one (interface to an object);
Bridge - separates the representation of the class and its implementation, allowing you to independently change both (implementation
of an object);
Composite - groups objects into hierarchical tree structures and allows you to work with a single object in the same way as with a group
of objects (structure and composition of an object);
Decorator - Represents a way to change the behavior of an object without creating subclasses. Allows you to use the behavior of one
object in another (responsibilities of an object without subclassing);
Facade - creates a class with a common high-level interface to a certain number of interfaces in a subsystem (interface to a
subsystem);
Flyweight - separates the properties of the class for optimal support for a large number of small objects (storage costs of objects);
Proxy - replaces a complex object with a simpler one and controls access to it
WHAT ANTI-PATTERNS DO YOU KNOW?

Some anti-patterns:

Big ball of mud is a term for a system or simply a program that does not have even the slightest discernible architecture. Typically
includes more than one anti-pattern. This affects systems developed by people with no training in software architecture.
Yo-Yo problem - arises when you need to understand the program, the inheritance hierarchy and the nesting of method calls are very
long and complex. The programmer therefore needs to navigate between many different classes and methods in order to control the
behavior of the program. The term comes from the name of the yo-yo toy.
Magic Button - occurs when the form processing code is concentrated in one place and, of course, is not structured in any way.
Magic Number - the presence in the code of repeated the same numbers or numbers, the explanation of the origin of which is missing.
Gas Factory - complex design for a simple task.
Analiys paralisys. In software development manifests itself through extremely long phases of project planning, collecting the necessary
artifacts for this, software modeling and design, which do not make much sense to achieve the final goal.
Interface Bloat is a term used to describe interfaces that try to contain all possible operations on data.
Accidental complexity is a programming problem that could easily have been avoided. Occurs due to a misunderstanding of the
problem or ineffective planning.

WHAT IS OOAD?

OOAD, Object Oriented Analysis and Design - a discipline that describes the ways (options) of specifying (defining) objects and their
interaction to solve a problem that is defined and described in the course of object-oriented analysis.

The main idea of object-oriented analysis and design is to consider the subject area and the logical solution of the problem from the point
of view of objects (concepts and entities). In the process of object-oriented analysis, the main attention is paid to the definition and
description of objects (or concepts) in terms of the subject area. In the process of object-oriented design, logical program objects are
defined that will be implemented by means of an object-oriented programming language. These program objects include attributes and
methods. And finally, in the process of designing (construction) or object-oriented programming (object-oriented programming), the
implementation of the developed components and classes is provided.

WHAT IS OOD?

OOD, Object Oriented Design, is a design methodology that combines the process of object decomposition and techniques for
representing the logical and physical, as well as static and dynamic models of the system being designed.

WHAT IS OOA?
OOA, Object Oriented Analysis is a methodology in which system requirements are perceived in terms of classes and objects identified in
the subject area, this is a design methodology that combines the process of object decomposition and techniques for representing logical
and physical, as well as static and dynamic models of the designed system.

WHAT ARE DRY PRINCIPLES?

DRY, Don't repeat yourself - this principle is so important that it does not require repetition. This is a software development principle aimed
at reducing the repetition of information of various kinds, especially in systems with many layers of abstraction. In simple words, DO NOT
write repetitive code, use the principle of abstraction, generalizing simple things in one place.

WHAT IS KISS?

KISS, Keep it short and simple or Keep it simple, stupid (keep things simple) is a design and programming principle that prohibits the use
of more complex tools than necessary. The principle declares the simplicity of the system as the main goal and / or value.

WHAT IS YAGNI?

YAGNI, You ain't gonna need it (You won't need it) is a software design process and principle in which the rejection of redundant
functionality is declared as the main goal and / or value. The bottom line is to implement only the tasks defined and to abandon redundant
functionality.

WHAT IS YODA CONDITIONS?

Yoda conditions - A "safe" style of writing comparison expressions when programming in languages with C syntax, which consists in writing
a constant member of the expression (constant or function call) to the left of the comparison operator (that is, 5 == a instead of habitual a
== 5).

This style is intended to prevent the common mistake of these languages - the use of the assignment operator "=" instead of the
comparison "==". The erroneous use of assignment turns Yoda's notation into an attempt to change a constant, causing a compile-time
error, which eliminates the possibility of this type of error in the finished program, and also makes it easier to find and fix them in new code.

WHAT IS CRC CARDS?


CRC cards, Class-responsibility-collaboration card (Class-Responsibility-Cooperation) is a brainstorming method for designing object-
oriented software. As a rule, CRC-maps are used in those cases when classes and ways of their interactions are first defined in the
software design process.

CRC maps focus the attention of the designer on the essence of the class and hide from him the details, the consideration of which at this
stage would be counterproductive. CRCs also force the designer to refrain from assigning too many responsibilities to a class.

WHAT IS SOLID?

SOLID, (single responsibility, open-closed, Liskov substitution, interface segregation, and dependency inversion) is an acronym for the first
five principles, which stood for the five basic principles of object-oriented programming and design.

These principles, when applied together, are intended to increase the likelihood that a programmer will create a system that is easy to
maintain and expand over time. The SOLID principles are guidelines that can be applied while working on software to remove "wrap
around code" by instructing the programmer to refactor the source code until it is legible and extensible. This is part of an overall agile and
adaptive development strategy.

WHAT IS SINGLE RESPONSIBILITY PRINCIPLE?

Single responsibility principle - the principle of a single responsibility (one single responsibility should be assigned to each class). If one
java class implements 2 sets of functions, their chaining creates a situation where changing one will break the combination.

WHAT IS AN OPEN/CLOSED PRINCIPLE?

Open / closed principle - the principle of object-oriented programming, establishing the following position: "program entities (classes,
modules, functions, etc.) must be open for extension, but closed for change"; this means that such entities can be allowed to change their
behavior without changing their source code. How this can be implemented? Allow extension of the type. In this case we can override the
behavior of the type without adjusting the source code of the original class. And by creating sufficient level of abstraction that wouldn’t
force clients of your code to change the source code of original class.

WHAT IS LISKOV SUBSTITUTION PRINCIPLE?


Liskov substitution principle - Barbara Liskov's substitution principle (functions that use a base type must be able to use subtypes of the
base type without knowing it. Subclasses cannot replace the behavior of base classes. Subtypes must complement base types).

WHAT IS INTERFACE SEGREGATION PRINCIPLE?

Interface segregation principle - the principle of interface separation (many specialized interfaces are better than one universal one). In
other words, large, voluminous interfaces should be divided into small ones in such a way that clients of small interfaces know only about
those methods that they need in their work. And so that when changing the interface methods, we wouldn’t change clients that don’t
depend on the methods they don’t need and don’t use.

WHAT IS DEPENDENCY INVERSION PRINCIPLE?

Dependency inversion principle - the principle of dependency inversion (dependencies within the system are built on the basis of
abstractions. Top-level modules do not depend on lower-level modules. Abstractions should not depend on details. Details should depend
on abstractions).

WHAT IS GRASP?

GRASP, General Responsibility Assignment Software Patterns are design patterns used to solve general tasks of assigning responsibilities
to classes and objects. Nine GRAPS patterns are known.

Information expert
Creator
Controller
Indirection
Low coupling
High cohesion
Polymorphism

Protected variations
Pure fabrication

BRIEFLY DESCRIBE GRASP TEMPLATES.

GRASP identifies the following 9 template principles:

Information Expert - An information expert describes the fundamental principles for assigning responsibilities to classes and objects.
According to the description, an information expert (an object endowed with certain duties) is an object that has the maximum
information necessary to perform the assigned duties.
Creator - the essence of the responsibility of such an object is that it creates other objects. The analogy with factories immediately
suggests itself. That is correct. Factories also have a creation responsibility.
Controller - is responsible for processing input system events, delegating the responsibility for their processing to competent classes. In
general, a controller implements one or more use cases. Using controllers allows you to separate logic from presentation, thereby
increasing code reusability.
Low Coupling - If objects in an application are strongly coupled, then any change to them causes changes to all related objects. And
this is inconvenient and generates bugs. That's why in all learning literature it is mentioned that it is necessary that the code be loosely
coupled and depend only on abstractions.
High Cohesion - High cohesion is a software engineering concept that refers to how closely all the routines in a class, or all the code in
a routine, support a central purpose. Classes that contain strongly related functionalities are described as having high cohesion.
Pure Fabrication is a class that doesn't represent any real domain object, but is specifically designed to increase cohesion, decoupling,
or increase reuse. Pure Fabrication reflects the concept of services in the Domain Programming model.
Indirection - the redirection pattern implements low coupling between classes by assigning responsibilities for their interaction to an
additional object - an intermediary.

Protected Variations - Protects elements from being modified by other elements (objects or subsystems) by making the interaction a
fixed interface. All interaction between elements must occur through it. The behavior can only be changed by creating a different
implementation of the interface.
Polymorphism - allows you to handle alternative behaviors based on type and replace plug-in system components. Responsibilities are
allocated to different behaviors using polymorphic operations for that class. All alternative implementations are cast to a common
interface.

You might also like