Module 1 - General Overview

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

Computer

Programming II
CSC202

STATUS: COMPULSORY CREDITS: 3

CSC202: Computer Programming II College of Basic & Applied Sciences


Computer Programming
Fundamentals
CSC202 Lectures

Preliminaries
&
Conventions

CSC202: Computer Programming II College of Basic & Applied Sciences


Overview

 Principles of Good Programming


 Benefits of good Programming principles
 Structured Programming Concepts
 Types of structured programming
 Advantages of structured programming
 Disadvantages of structured programming

CSC202: Computer Programming II 3


Preliminaries & Conventions
Principles of Good Programming (1)
1. DRY (Don’t-Repeat-Yourself)
 A piece of logic should only be represented once in an application.
o Duplication is the root of all software evils.
o Duplication is a waste.
2. KISS (Keep It So Simple)
 Most systems work best if they are kept simple rather than making
them complex
 Therefore, simplicity should be a key goal in design
 Unnecessary complexity should be avoided .

CSC202: Computer Programming II General Overview


Principles of Good Programming (2)
3. YAGNI (You Aren’t Gonna Need It)
 YAGNI states that "don’t implement something until it is necessary".
 There are two main reasons for this:
o You save time because you avoid writing code that you turn out not to
need
o Your code is better because you avoid polluting it with 'guesses' that
turn out to be more or less wrong but stick around anyway.
2. SOLID
SOLID principle supports good object-oriented design and programming.
 Five of these principles are:
CSC202: Computer Programming II General Overview
Principles of Good Programming (3)
SOLID Cont’d
Single responsibility
Open-closed,
Liskov substitution
Interface segregation
Dependency inversion

CSC202: Computer Programming II General Overview


Benefits of Good Programming
1. Readability
All developers were in a team able to understand the code.
2. Extensibility
Change requests will come at any time. So our code is always easy
to extend without breaking existing business rules.
3. Maintainability
It’s easy to maintain by the development team and the production
support team too because the application is loosely coupled.
4. Modularity
Divide a program into reusable pieces: functions, modules, libraries.

CSC202: Computer Programming II General Overview


Structured Programming Concepts
 Structured programming is a programming paradigm that facilitates
the creation of programs with readable code and reusable
components
 Encourages dividing an application program into a hierarchy of
modules or autonomous elements, which may, in turn, contain other
such elements
 Code may be further structured using blocks of related logic designed
to improve readability and maintainability
 May include case, which tests a variable against a set of values;
repeat, while and for, which construct loops that continue until a
condition is met.
CSC202: Computer Programming II General Overview
Types of Structured Programming
Procedural programming. Defines modules as "procedures" called with
a set of parameters to perform a task, subdivided into the following:
Service-oriented programming simply defines reusable modules as
"services" with advertised interfaces
Microservice programming focuses on creating modules that do not
store data internally, and so are scalable and resilient in cloud
deployment
Functional programming modules are written from functions whose
outputs are derived only from their inputs. Designed for serverless
computing but has since expanded to be largely synonymous with
microservices
CSC202: Computer Programming II General Overview
Types of Structured Programming (1)
Object-oriented programming (OOP)
 Defines a data resource and sends it to process commands. E.g.,
procedural programmer might say "Print(object)" while OOP might say
"Tell Object to Print".)
 Defines a program as a set of objects or resources to which
commands are sent
Model-based programming
 Example of this is database query languages.
 Units of code are associated with steps in database access and
update or run when those steps occur

CSC202: Computer Programming II General Overview


Types of Structured Programming (2)
Model-based programming Cont’d
 The database and database access structure will determine the
structure of the code
 Another example of a model-based structure is Reverse Polish
Notation (RPN), a math-problem structure that lends itself to efficient
solving of complex expressions and Quantum computing

CSC202: Computer Programming II General Overview


Advantages of Structured Programming
The primary advantages of structured programming are:
1. It encourages top-down implementation, which improves both
readability and maintainability of code.
2. It promotes code reuse: internal modules can be extracted and made
independent, residents in libraries, described in directories and
referenced by many other applications.
3. It improves development time and code quality

CSC202: Computer Programming II General Overview


Disadvantages of Structured Programming
1. Reduction in execution efficiency.
2. Greater memory usage.
Both these problems arise from the introduction of calls to a module or
process. All structured programming languages are at risk to "over-
structuring" and loss of efficiency
3. Selecting the wrong type of structure for the task at hand.
For example, solving of math problems. RPL is an efficient way to state
and solve a math problem as it eliminates the need to explicitly state
execution order and eliminates recursion in code. However, posing
such problem in structured programming procedural or object form, the
resulting code would be much less efficient than the RPL version
CSC202: Computer Programming II General Overview
Questions?

CSC202: Computer Programming II Preliminaries & Conventions

You might also like