About Programation: Difference between revisions

From My Limbic Wiki
Line 103: Line 103:
When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes. In the context of computers this translates into executing a process or task on another "thread."
When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes. In the context of computers this translates into executing a process or task on another "thread."
=Good to Know=
=Good to Know=
* '''Priority Queue''':In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority.
* '''Priority Queue''':In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. (https://www.hackerrank.com)
* '''Covariant Return Types''': Java allows for Covariant Return Types, which means you can vary your return type as long you are returning a subclass of your specified return type. (https://www.hackerrank.com)


=More=
=More=
* [https://www.tutorialspoint.com/java| Java]
* [https://www.tutorialspoint.com/java| Java]

Revision as of 17:19, 9 August 2019

Central Principles in POO

Abstraction

  • Abstraction is a process of hiding the implementation details from the user. Оnly the functionality will be provided to the user.
  • Related to both encapsulation and data hiding
  • My words:
    • One abstract method = class abstract.
    • This class can be extends by other classes
    • The child classes will contain the extended methods of the abstract class, they can use them and the declaration of the abstract one
    • The abstract method will be over-writed to have the possibility to write a different code for each child
  • It is a process which is achieved with inheritance where actual implementation is kept abstract. In abstraction you just define set of function or actions to do . Now it depends on child classes how they want to implement it . But there is a rule that you have to provide an implementation.

Inheritance

  • Extends: Multiple inheritance
  • Using extends keyword, the child class inherits the methods of parent class.
  • A child inherits the properties and actions (functions) of it’s parent

Encapsulation

  • Declare private variables
  • Declare Setters and Getters to modify them

Polymorphism

  • Process objects differently based on their data type.
  • One method with multiple implementation
  • This can be implemented by designing a generic interface, which provides generic methods for a certain class of action and there can be multiple classes, which provides the implementation of these generic methods.
  • Ways to do it:
    • Override: method of an extended class
    • Compile Time: Multiple methods declaration with multiple parameters
  • In polymorphism, the parent class has a declared method wich is not abstracted and not empty. There is a process inside, it is not only a declaration in a abstract class

Packages

  • Prevent naming conflicts
  • Control access
  • Make searching/locating and usage of classes, interfaces, enumerations and annotations easier...

Interface

  • Collection of abstract methods.
  • A class implements an interface, thereby inheriting the abstract methods of the interface.

Standard Architecture

standard web architecture

src

  • com.project
    • Main: Entry point
  • com.project.configuration
    • project Security & MVC Configuration

Components

in Java @Component is the top level generic annotation which makes the annotated bean to be scanned and available in the DI container

  • com.project.controllers
    • is specialized annotation which makes the bean MVC aware and allows the use of further annotation like @RequestMapping and all such
  • com.project.model
    • Object Relational Database
  • com.project.repositories
    • DAO Interface is specialized annotation and it brings the feature of converting all the unchecked exceptions from the DAO classes
  • com.project.services
    • Indicates that an annotated class is a "Service", originally defined by Domain-DrivenDesign (Evans, 2003) as "an operation offered as an interface that stands alone in themodel, with no encapsulated state." May also indicate that a class is a Business Service Facade (in the Core J2EEpatterns sense),

resources

  • static
    • css
    • images
    • javascript
  • templates
    • admin
    • home
    • registration

properties

  • properties and configuration files

Difference Controller and Presenter

  • Presenter
    • The View is responsible for handling the UI events
  • Controller
    • Handle the UI Events

Design Patterns

  • MVC
  • MVP
  • MVVM

Famous Patterns

Singleton

  • Class Singleton with a private constructor
    • Private static parameter single_instance set to null
    • Private static Method getInstance(): if the parameter is null, instantiate Singleton class as New, if not return the existing instance returning the parameter single_instance

Every instantiation has to be called as: Singleton.getInstance();

Observable

Factory

Strategy

Builder

Adapter

State

Paradigm

  • REST: Representational State Transfer; Used with Web Services
  • Object
  • Procedural

Acronyms

  • CRUD: Create, Read, Update, Delete

Synchronous vs Asynchronous

When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes. In the context of computers this translates into executing a process or task on another "thread."

Good to Know

  • Priority Queue:In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. (https://www.hackerrank.com)
  • Covariant Return Types: Java allows for Covariant Return Types, which means you can vary your return type as long you are returning a subclass of your specified return type. (https://www.hackerrank.com)

More