Download - Object oriented programming systems
![Page 1: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/1.jpg)
Object Oriented Programming Systems
An Overview
![Page 2: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/2.jpg)
Object Oriented Analysis And Design
•Software development process consists of analysis, design, and implementation phases
•The goal of the analysis phase is a complete description of what the software product should do
•The goal of object-oriented design is the identification of classes, their responsibilities, and the relationships among them
•The goal of the implementation phase is the programming, testing, and deployment of the software product
![Page 3: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/3.jpg)
Why OOPS ?
• To modularize software development , just like any other engineering discipline
•To make software projects more manageable and predictable
•For better maintainability, since software maintenance costs were more than the development costs.
•For more reuse of code and to prevent the ‘reinvention of the wheel’ every time
![Page 4: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/4.jpg)
Programming Techniques
Unstructured Programming
![Page 5: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/5.jpg)
Structured Programming
![Page 6: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/6.jpg)
Modular Programming
![Page 7: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/7.jpg)
Object-Oriented Programming
![Page 8: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/8.jpg)
Modeling
![Page 9: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/9.jpg)
Use Cases
A use case lists a sequence of actions that yields a result that is of value to an actor
![Page 10: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/10.jpg)
Abstract Data Type
![Page 11: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/11.jpg)
OOPS
• A class specifies objects with the same behavior
•An instance of a class is an object that belongs to the given class
•Class names should be nouns in the singular form
•To discover responsibilities , look for verbs in the problem description.
•A responsibility must belong to exactly one class
![Page 12: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/12.jpg)
An OO Program
![Page 13: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/13.jpg)
A circle is a point and a radius
![Page 14: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/14.jpg)
Class and Object concept
An object is characterized by its state, behavior, and identity
• The collection of all information held by an object is its state
•The behavior of an object is defined by the operations or methods that an object supports
•The unique reference (or name) of an object is its identity
![Page 15: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/15.jpg)
An object of circle is a kind of point
![Page 16: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/16.jpg)
If Logo is circle and triangle
![Page 17: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/17.jpg)
Has-A relationship
![Page 18: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/18.jpg)
Relationships between Classes
Three relationships are common among classes :
•Dependency (“uses”)
•Aggregation (“has”)
•Inheritance (“is”)
![Page 19: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/19.jpg)
Dependency
• A class depends on another class if it manipulates objects of the other class in any way.
•If a class can carry out all its tasks without being aware that the other class even exists, then it doesn’t use that class.
•For example, if there is a Message class which uses the System.Print class, then the Message class is dependant , or coupled with the System.Print class
![Page 20: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/20.jpg)
Aggregation
•A class aggregates another if its objects contain objects of the other class
•Aggregation is often informally described as the ‘has-a’ relationship
![Page 21: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/21.jpg)
Inheritance
A class inherits from another if it incorporates the behavior of the other class
![Page 22: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/22.jpg)
Inheritance
![Page 23: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/23.jpg)
Inheritance
![Page 24: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/24.jpg)
Inheritance tree
![Page 25: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/25.jpg)
ASP.NET component
using System;using System.Web.UI;
namespace MSPress.ServerControls {
public class SimpleControl : Control {
protected override void Render(HtmlTextWriter writer){
writer.Write("I don't do anything useful. ");writer.Write("but at least i'm a control....");
}
}
}
![Page 26: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/26.jpg)
Re-using the component
<%@ Page language="C#" %>
<%@ Register TagPrefix="msp" NameSpace="MSPress.ServerControls" Assembly="SimpleControl.cs" %>
<HTML>
<body>
<br>
Here is the output from our first custom control
<br>
<msp:SimpleControl id="simple1" runat="server" />
<br>
</body>
</HTML>
![Page 27: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/27.jpg)
CRC Cards
A CRC card is an index card that describes a class, its high-level responsibilities , and its collaborators
![Page 28: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/28.jpg)
Polymorphism
![Page 29: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/29.jpg)
Sample Program – Part 1using System;
public class Control
{
public Control (string data) {Data = data; }
protected string data;
public string Data
{
get { return data ; }
set { data = value; }
}
}
![Page 30: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/30.jpg)
Sample Program – Part 2
interface IValidate
{
bool Validate();
}
class SSN : Control, IValidate
{// Class starts here
const char DELIMITER = '-';
![Page 31: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/31.jpg)
Sample Program – Part 3
public SSN(string val) : base (val) {}
public bool Validate()
{
Console.WriteLine("[SSN.Validate] : Validating '{0}'", data);
return (11 == data.Length) && (CorrectFormat());
}
![Page 32: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/32.jpg)
Sample Program – Part 4
protected bool CorrectFormat()
{bool correctFormat = true;
for (int i = 0; (correctFormat && i < data.Length); i++)
{
correctFormat =((IsDelimiterPosition(i) && data[i] == DELIMITER)|| (IsNumberPosition(i)&& char.IsNumber(data[i])));
}
return correctFormat; }
![Page 33: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/33.jpg)
Sample Program – Part 5protected bool IsDelimiterPosition(int i)
{
return (i==3 | i==6);
}
protected bool IsNumberPosition (int i)
{
return (i !=3 && i != 6);
}
} //class SSN : Control, IValidate ends here
![Page 34: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/34.jpg)
Sample Program – Part 6
class InterfacesApp
{ //Main class starts here
public static void Main(string[] args)
{
string data = "";
if (0 < args.GetLength(0))
data = args[0];
SSN ssn = new SSN(data);
IValidate val = (IValidate)ssn;
![Page 35: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/35.jpg)
Sample Program – Part 7
Console.WriteLine("[Main] Calling SSN.Validate");
bool success = val.Validate();
Console.WriteLine("[Main] The validation of " +
"SSN '{0}' was {1}successful",
ssn.Data,
(true == success ? "" : "NOT "));
}
} //Main class ends here
![Page 36: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/36.jpg)
COM
![Page 37: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/37.jpg)
Messages
![Page 38: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/38.jpg)
.NET
.NET has 5 intrinsic types :
•Class
•Interface
•Struct
•Enum
•Delegate
![Page 39: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/39.jpg)
A simple example of .NET delegate – Part 1
' Our delegate type can point to any method
' taking two integers and returning an integer.
Public Delegate Function BinaryOp(ByVal x As Integer, ByVal y As Integer) As Integer
![Page 40: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/40.jpg)
A simple example of .NET delegate – Part 2
'This class defines the methods that will be 'pointed to' by the delegate.
Public Class SimpleMath
Public Shared Function Add(ByVal x As Integer, ByVal y As Integer) As Integer
Return x + y
End Function
Public Shared Function Subtract(ByVal x As Integer, ByVal y As Integer) As Integer
Return x - y
End Function
End Class
![Page 41: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/41.jpg)
A simple example of .NET delegate – Part 3
Module Program
Sub Main()
Console.WriteLine("****** Simple Delegate Example*******")
'Make a delegate object and add method to invocation
'list using the AddressOf keyword.
Dim b As BinaryOp = New BinaryOp(AddressOf SimpleMath.Add)
'Invoke the method 'pointed to'
Console.WriteLine("10 + 10 is {0}", b(10, 10))
Console.ReadLine()
End Sub
End Module
![Page 42: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/42.jpg)
The Move from Two-Tier to N-Tier Architecture
![Page 43: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/43.jpg)
Stored Procedures for Business Logic
![Page 44: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/44.jpg)
Two Tier can be messy
![Page 45: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/45.jpg)
Introducing middle tier
![Page 46: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/46.jpg)
The ‘abilities’
Maintainability
Usability
Reliability
Scalability
Security
Integrity
Testability
Performance
![Page 47: Object oriented programming systems](https://reader036.vdocuments.us/reader036/viewer/2022062418/55561cc5d8b42ae0238b51b7/html5/thumbnails/47.jpg)
Summary
Object Oriented systems are a way of engineering software applications to achieve more consistency and maintainability .