Software Engineering: Propositional Logic

Ref: Software Engineering Course: https://www.cs.ox.ac.uk/people/michael.wooldridge/teaching/soft-eng/
https://www.cs.ox.ac.uk/people/michael.wooldridge/teaching/soft-eng/lect07-4up.pdf

Oracle PL/SQL: If-Then-Else, For Loop, While Loop

How it works: if, elsif, else (then) (Click on the images to see them clearly)

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Example:

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Oracle: CASE, WHEN, THEN

Simple:

Searched:

Else:

Reverse For Loop

Ref: For Loop Examples in Oracle

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/controlstatements.htm#BABEFFDC

Oracle While Loop

While loop example from the referenced url

DECLARE
done BOOLEAN := FALSE;
BEGIN
WHILE done LOOP
DBMS_OUTPUT.PUT_LINE (‘This line does not print.’);
done := TRUE; — This assignment is not made.
END LOOP;

WHILE NOT done LOOP
DBMS_OUTPUT.PUT_LINE (‘Hello, world!’);
done := TRUE;
END LOOP;
END;
/

Ref: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-control-statements.html#GUID-3F69F563-BCAE-4D3E-8E03-F53C8D64D093

Oracle Sub Types for Data Types: Exception Block

An unconstrained subtype has the same set of values as its base type, so it is only another name for the base type.

Syntax:

SUBTYPE subtype_name IS base_type
Example:
 
SUBTYPE "DOUBLE PRECISION" IS FLOAT
SUBTYPE Balance IS NUMBER;

Constrained SubType
 
SUBTYPE Balance IS NUMBER(8,2);

Oracle Exception Block Example:



Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm


						
						
						
		

Misc. Oracle: Data Types: Why a Data Type.

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/02_funds.htm

https://stackoverflow.com/questions/7425153/reason-why-oracle-is-case-sensitive

Oracle Data Types and Allowed Sizes:

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS99943

Oracle SIMPLE_FLOAT vs SIMPLE_DOUBLE

Ref: https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/datatypes.htm#CJAEAEJG

PLS_Integer vs Number

"The PLS_INTEGER data type has these advantages over the NUMBER data type and NUMBER subtypes:

  • PLS_INTEGER values require less storage.
  • PLS_INTEGER operations use hardware arithmetic, so they are faster than NUMBER operations,

"

Ref: https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS319

Hardly anything is by me. All are from external sources. Credit belongs to them.

Oracle Data types, ROWID, PLS_INTEGER vs INTEGER

Data Types

Ref: https://docs.oracle.com/cd/A97630_01/server.920/a96524/c13datyp.htm

(Click on the image to see it properly)

Why PLS_Integer:

https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/03_types.htm

“You use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -231 .. 231. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic. For efficiency, use PLS_INTEGER for all calculations that fall within its magnitude range.”

ROWID vs ROWNUM

ROWID is useful when you need to refer to a specific row in a table without using a primary key or unique constraint. Hence, ROWNUM is a pseudocolumn that assigns a unique row number to each row in a result set, while ROWID is a physical address that identifies a specific row in a table

https://www.c-sharpcorner.com/interview-question/what-is-the-difference-between-rownum-and-rowed

Simple Integer vs PLS_integer

https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-data-types.html

“SIMPLE_INTEGER has the same range as PLS_INTEGER and has a NOT NULL constraint. It differs significantly from PLS_INTEGER in its overflow semantics. If you know that a variable will never have the value NULL or need overflow checking, declare it as SIMPLE_INTEGER rather than PLS_INTEGER .”

Algorithm Complexity: Notations and Comparisons

Algorithm Complexity Notations and Comparisons:

Ref: https://www.freecodecamp.org/news/big-o-notation-why-it-matters-and-why-it-doesnt-1674cfa8a23c/

Algorithm Complexity: A simple example

The complexity here is: 3n+2 i.e. O(n)

Ref: https://www2.cs.sfu.ca/CourseCentral/125/johnwill/Packet06.pdf

Java spring application demo

https://youtu.be/euJzoAbaXjc

Proxy Pattern

Proxy Pattern:

“Proxy is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.

A credit card is a proxy for a bank account, which is a proxy for a bundle of cash. Both implement the same interface: they can be used for making a payment. A consumer feels great because there’s no need to carry loads of cash around. A shop owner is also happy since the income from a transaction gets added electronically to the shop’s bank account without the risk of losing the deposit or getting robbed on the way to the bank.

Click on the images to see them clearly.

In the above UML class diagram, the Proxy class implements the Subject interface so that it can act as substitute for Subject objects. It maintains a reference (realSubject) to the substituted object (RealSubject) so that it can forward requests to it (realSubject.operation()).

UML Class Diagram

https://refactoring.guru/design-patterns/proxy

https://en.wikipedia.org/wiki/Proxy_pattern

Java: Facade Design Pattern

Façade Pattern

“Facade is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes.”

“When you call a shop to place a phone order, an operator is your facade to all services and departments of the shop. The operator provides you with a simple voice interface to the ordering system, payment gateways, and various delivery services.”

For a clear view, click on the images (images are from Wikipedia)

Ref: https://refactoring.guru/design-patterns/facade

https://en.wikipedia.org/wiki/Facade_pattern