topic 1 pbo

18
TOPIC 1

Upload: imanuel-nugroho

Post on 29-Jun-2015

385 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Topic 1 PBO

TOPIC 1

Page 2: Topic 1 PBO

• Paradigms of Programming• Unstructured (Unofficial Name)• Structured Programming• Procedural Programming• Abstract Data Type• OOP

Page 3: Topic 1 PBO

Paradigms are valuable for solving problemsbecause: – knowing one's paradigm reveals assumptions

being made in modelling a problem, which can clarify programming objectives;

– being able to state the advantages and drawbacks of various paradigms permits someone to decide between them based on the problem at hand.

Page 4: Topic 1 PBO

• goto Statement• Process Abstraction– Function Declaration – Function Prototype (C/C++)

• The function name that is used in function call hides the implementation details from user.

• It shows only the outline of functionality that the function provides.

• Multi Entry and Multi Exit Subprogram• Spaghetti Code

Page 5: Topic 1 PBO

• goto less Programming• Structured Theory– Sequential – Selection– Iteration

• Single Entry and Single Exit Subprogram• Disadvantage: over-used term for using

complexity-reducing techniques (meaningless these days).

Page 6: Topic 1 PBO

Modular Programming :– The main program coordinates calls to procedures in

separate modules and hands over appropriate data as parameters

– Functional independence, measured by:• Internal cohesion (does/deals with one thing)• External coupling (interface complexity)

– Makes modification easier– Reduces error propagation

Page 7: Topic 1 PBO

• Definition of ADT :– ADT , or data abstraction, is a programming

methodology where one defines not only the data structure to be used, but also the processes to manipulate the structure

– Data structure: represents the properties, the state or characteristics of objects

– Methods: permissible behaviors that are controlled through the member functions

– Showing only the essential features and hiding the unnecessary features

Page 8: Topic 1 PBO

– A data representation that• must be able to represent all possible values of the ADT• should be private

– A set of methods that support normal use of the ADT• The user must be able to create, possibly modify, and

examine the values of the ADT– An algorithm for each of the possible operations that• must be consistent with the chosen representation• all auxiliary (helper) operations that are not in the

contract should be private

Page 9: Topic 1 PBO

• The ability to define an ADT where the type and/or size is specified generically so that a specific version can be generated later

• In C++, parameterized ADTs are implemented as template classes

• In C++, and also Ada, the parameterized ADT definition is generated at compile-time

Page 10: Topic 1 PBO

• Encapsulation is a technique that allows the programmer to group data and the functions that operate on that data and place them together in a single place.

• Encapsulation Constructs :– For large programs, to avoid having to recompile all code

when one section changes• Code can be grouped into logically related chunks called

encapsulations– Each language has some technique for then using the

named encapsulation, sometimes called a namespace

Page 11: Topic 1 PBO

• Controlling access to the data structure through some form of interface so that it cannot be directly manipulated by external code

• This is often done by using two sections of an ADT definition– the public part (interface) constitutes those elements that

can be accessed externally– the private part, which remains secure because it is only

accessible by subprograms of the ADT itself

Page 12: Topic 1 PBO

• C++ offers two mechanisms for building data structures: the struct and the class

• C++ class consists of data members and methods (member functions)

• C++ classes contain both visible (public) and hidden (private) components (as well as protected)

• A stack-dynamic object may have heap-dynamic data so that parts of the object may continue even though the instant is deallocated

Page 13: Topic 1 PBO

• OO Concepts: objects of the program interact by sending messages to each other

• Main Features of OOP :– ADT– Inheritance : Create a new class from an existing class Reuse, Extend and Overriding Function Permits objects of a more specific class to inherit the

properties (data) and behaviors (functions) of a more general/base class

Ability to define a hierarchical relationship between objects

Page 14: Topic 1 PBO

- (True) Polymorphism : ability for different objects to interpret functions differently

Dynamic Binding Virtual Methods Pure Virtual Function

• Additional Feature – Generic Programming

Page 15: Topic 1 PBO

• Procedural– Focuses on process– Top Down approach– A Single module will be split into several smaller modules– General to Specific– If the requirements are clear at the first instance we can go for Top

down approach• OOP

– Focuses on object– Bottom Up approach– Lot of small modules will be grouped to form a single large module– Specific to General– In circumstances where the requirements may keep on adding, we go

for Bottom up approach

Page 16: Topic 1 PBO

• C++ is based on Simula 67 and C• Design by Kristen Nygaard and Ole-Johan Dahl

– Norwegian Computing Center, Oslo University– The start of object-oriented programming and object-oriented design

• Model real-world phenomena in code– represent ideas as classes and class objects– represent hierarchical relations as class hierarchies

• Classes, inheritance, virtual functions, object-oriented design• A program becomes a set of interacting objects rather than a

monolith– Has major (positive) implications for error rates

Page 17: Topic 1 PBO

• Compared to C++: no header files, macros, pointers and references, unions, operator overloading, templates, etc.

• Object-orientation: Classes + Inheritance• Distributed: RMI, Servlet, Distributed object programming.• Robust: Strong typing + no pointer + garbage collection • Secure: Type-safety + access control • Architecture neutral: architecture neutral representation• Portable• Interpreted: High performance through Just in time

compilation + runtime modification of code• Multi-threaded

Page 18: Topic 1 PBO

• C#, pronounced C Sharp, was developed by Microsoft as part of the .NET initiative

• The principal designer and lead architect is Anders Hejlsberg, who was previously involved with the design of Turbo Pascal, Borland Delphi, and Visual J++

• It is a multi-paradigm language that include functional, imperative, OO and component-oriented disciplines

• C# is intended to be a simple, modern, general-purpose, object-oriented programming language.

• It was initially named Cool, which stood for "C-like Object Oriented Language." However, in July 2000, the name of the programming language was given as C#