About Cohesion

2022-05-11

 In computer programming, cohesion refers to the degree to which the elements of a module belong together.  Thus, it is a measure of how strongly related each piece of functionality expressed by the source code of a software module is.

Cohesion is the concept all the variables and methods in the class fitting together under the name and purpose of the class.  A class should have a single responsibility, a single purpose.  If a class has more than one purpose then it should be split up.

Programming Paradigm

2022-05-07

Paradigm means a school of thought or model that has distinct features, frameworks, patterns, and style which help you solve a particular problem. The languages may follow a particular paradigm or can be a combination of many paradigms. Programming paradigms are a way to classify the programming languages based on their features. Languages can be classified into multiple paradigms.

Declarative programming is to program on a higher level of abstraction than imperative programming. Neither is better or worse, but both have their places. An example of where declarative programming is necessary would be in web development when you are working with frameworks. An area of where Imperative programming is necessary would be in the engineering of algorithms and other low level necessities.

Declarative and Imperative programming paradigms are nothing but buzzwords for describing coding on different levels of abstraction. Declarative programming refers to code that is concerned with higher levels of abstraction. Imperative programming refers to code that is concerned with lower levels of abstraction.

Some argue that many programming languages cannot be strictly classified into one paradigm, but rather include features from several paradigms. For example c# & java are a multi-paradigm programming language which supports imperative as well as declarative, functional and many other programming paradigms.

Common programming paradigms are Imperative and Declarative.

Imperative:  Programming with an explicit sequence of commands, uses statements that change a program's state. Imperative programming implements algorithms in explicit steps. Computer get a list of commands and executes them in order. Imperative programming is generally described as being concerned with "How to do it, not what to do”.

 Procedural: procedural programming (which is also imperative) allows splitting those instructions into procedures (or functions). Procedural programming is a subset of imperative programming.

 Object-oriented:  which groups instructions with the part of the state they operate on.  It allows  grouping functions around a specific entities named “classes” and is also imperative.

Declarative:  Programming by specifying the result a user wants, instead of how to get it, expresses the logic of a computation without describing its control flow.  It describes what the program must accomplish in terms of the problem domain, rather than describe how to accomplish it as a sequence of the programming instructions (the how being left up to the language's implementation). Declarative programming is concerned with "what to do, not how to do it."

Common declarative languages include  a subset of SQL (SELECT queries, for example), regular expressions, logic programming, functional programming, CSS and configuration management language. Many markup languages such as HTML, XAML, XSLT or other user-interface markup languages are often declarative. HTML for example only describes what should appear on a webpage - it specifies neither the control flow for rendering a page nor the page's possible interactions with a user. 

Functional programming : functional programming is a subset of declarative programming. Haskell is an example of functional programming language.