Anda di halaman 1dari 23

Structured and Object Oriented Programming Data Structures and Algorithms Software Engineering

Computer programming (often shortened to programming, scripting, or coding) is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs This source code is written in one or more programming languages (such as Java, C++, C#, Python, etc.) The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.

Structured programming is a programming paradigm aimed on improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops in contrast to using simple tests and jumps such as the goto statement which could lead to "spaghetti code" which is both difficult to follow and to maintain. Program flow follows a simple hierarchical model that employs looping constructs such as "for," "repeat," and "while." Use of the "Go To" statement is discouraged.
Structured programming was first suggested by Corrado Bohm and Guiseppe Jacopini. The two mathematicians demonstrated that any computer program can be written with just three structures: decisions, sequences, and loops. At a low level, structured programs are often composed of simple, hierarchical program flow structures. These are sequence, selection, and repetition:

"Sequence" refers to an ordered execution of statements. In "selection" one of a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else..endif, switch, or case. In some languages keywords cannot be written verbatim, but must be stropped. In "repetition" a statement is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, repeat, for or do..until. Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).

Non-structured programming is the historically earliest programming paradigm capable of creating Turingcomplete algorithms. It has been followed historically by procedural programming and then object-oriented programming, both of them considered as structured programming. There are both high- and low-level programming languages that use non-structured programming. These include early versions of BASIC (such as MSX BASIC and GW-BASIC), JOSS, FOCAL, MUMPS, TELCOMP, COBOL, machine-level code, early assembler systems (without procedural meta-operators), assembler debuggers and some scripting languages such as MS-DOS batch file language.

"Modular Programming" is the act of designing and writing programs as interactions among functions that each perform a single well-defined function, and which have minimal side-effect interaction between them. Put differently, the content of each function is cohesive, and there is low coupling between functions. Modular Programming is not OO...

Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic An object-oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform object-oriented programming that uses classes is sometimes called class-based programming, while prototype-based programming does not typically use classes.

Encapsulation Enforces Modularity

Inheritance Passes "Knowledge" Down

Encapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object." For example, in a payroll system, a class could be Manager, and Pat and Jan could be two instances (two objects) of the Manager class. Encapsulation ensures good code modularity, which keeps routines separate and less prone to conflict with each other.

Polymorphism Takes any Shape

Classes are created in hierarchies, and inheritance allows the structure and methods in one class to be passed down the hierarchy. That means less programming is required when adding functions to complex systems. If a step is added at the bottom of a hierarchy, then only the processing and data associated with that unique step needs to be added. Everything else about that step is inherited. The ability to reuse existing objects is considered a major advantage of object technology.
Object-oriented programming allows procedures about objects to be created whose exact type is not known until runtime. For example, a screen cursor may change its shape from an arrow to a line depending on the program mode. The routine to move the cursor on screen in response to mouse movement would be written for "cursor," and polymorphism allows that cursor to take on whatever shape is required at runtime. It also allows new shapes to be easily integrated.

public abstract class LoggerBase { /// <summary> /// field is private, so it intend to use inside the class only /// </summary> private log4net.ILog logger = null;

{ get; } /// <summary> /// Simple log method, /// which is only visible for inherited classes /// </summary> /// <param name="message"></param> protected void LogError(string message) { if (this.logger.IsErrorEnabled) { this.logger.Error(message); } } /// <summary> /// Public properties which exposes to inherited class /// and all other classes that have access to inherited class /// </summary> public bool IsThisLogError { get { return this.logger.IsErrorEnabled; } } }

/// <summary> /// protected, so it only visible for inherited class /// </summary> protected LoggerBase() { // The private object is created inside the constructor logger = log4net.LogManager.GetLogger(this.LogPrefix); // The additional initialization is done immediately after log4net.Config.DOMConfigurator.Configure(); } /// <summary> /// When you define the property as abstract, /// it forces the inherited class to override the LogPrefix /// So, with the help of this technique the log can be made, /// inside the abstract class itself, irrespective of it origin. /// If you study carefully you will find a reason for not to have set method here. /// </summary> protected abstract System.Type LogPrefix

In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently Data structures provide a means to manage huge amounts of data efficiently such as:

large databases internet indexing services designing efficient algorithms and formal design methods and programming languages

In computing, a hash table (also

hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found.

Choosing a good hash function Perfect hash function

A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code) The most common reason for wanting to transform source code is to create an executable program

In computer science, a B-tree is a tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time The B-tree is a generalization of a binary search tree in that a node can have more than two children (Comer 1979, p. 123) Unlike self-balancing binary search trees, the B-tree is optimized for systems that read and write large blocks of data. It is commonly used in databases and filesystems.

In computer science, a tree is a widely used data structure that simulates a hierarchical tree structure with a set of linked nodes. A tree can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a list of nodes (the "children"), with the constraints that no node is duplicated. A tree can be defined abstractly as a whole (globally) as an ordered tree, with a value assigned to each node

A simple unordered tree; in this diagram, the node labeled 7 has two children, labeled 2 and 6, and one parent, labeled 2. The root node, at the top, has no parent.

List of data structures Plain old data structure Concurrent data structure Data model Dynamization Linked data structure Persistent data structure

In computer science, a concurrent data structure is a particular way of storing and organizing data for access by multiple computing threads (or processes) on a computer. Historically, such data structures were used on uniprocessor machines with operating systems that supported multiple computing threads (or processes) The term concurrency captured the multiplexing/interleaving of the threads' operations on the data by the operating system, even though the processors never issued two operations that accessed the data simultaneously.

(POD) is a data structure that is represented only as passive collections of field values, without using encapsulation or other objectoriented features

A high-level data model in business or for any functional area is an abstract model that documents and organizes the business data for communication between functional and technical people. It is used to show the data needed and created by business processes. A data model in software engineering is an abstract model that documents and organizes the business data for communication between team members and is used as a plan for developing applications, specifically how data are stored and accessed. According to Hoberman (2009), "A data model is a wayfinding tool for both business and IT professionals, which uses a set of symbols and text to precisely explain a subset of real information to improve communication within the organization and thereby lead to a more flexible and stable application environment."

In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.

The following program shows how a simple, linear linked list can be constructed in C, using dynamic memory allocation and pointers. #include<stdlib.h> #include<stdio.h> struct list_el { int val; struct list_el * next; }; typedef struct list_el item; void main() { item * curr, * head; int i; head = NULL; for(i=1;i<=10;i++) { curr = (item *)malloc(sizeof(item)); curr->val = i;

Singly linked list


Singly linked lists contain nodes which have a data field as well as a next field,

which points to the next node in the linked list

Doubly linked list


In a doubly linked list, each node contains, besides the next-node link, a second

link field pointing to the previous node in the sequence. The two links may be called forward(s) and backwards, or next and prev(ious).

Multiply linked list


n a multiply linked list, each node contains two or more link fields, each field being

used to connect the same set of data records in a different order (e.g., by name, by department, by date of birth, etc.). While doubly linked lists can be seen as special cases of multiply linked list, the fact that the two orders are opposite to each other leads to simpler and more efficient algorithms, so they are usually treated as a separate case.

Circular list

In the last node of a list, the link field often contains a null reference, a special value used to indicate the lack of further nodes. A less common convention is to make it point to the first node of the list; in that case the list is said to be circular or circularly linked; otherwise it is said to be open or linear.

In the case of a circular doubly linked list, the only change that occurs is that end, or "tail", of the said list is linked back to the front, or "head", of the list and vice versa.

Bubble sort

sometimes incorrectly referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, most of the other sorting algorithms are more efficient for large lists

All notes available from below link.

An XOR linked list is a data structure used in computer programming. It takes advantage of the bitwise XOR operation, here denoted by , to decrease storage requirements for doubly linked lists. An ordinary doubly linked list stores addresses of the previous and next list items in each list node, requiring two address fields: The key is the first operation, and the properties of XOR: XX=O XO=X XY=YX (XY)Z=X(YZ)

Anda mungkin juga menyukai