0% found this document useful (0 votes)
156 views8 pages

Object Oriented Programming: OOP and The Programming Industry

Object oriented programming (OOP) uses objects outside programs like files to design applications. OOP features include inheritance, abstraction, polymorphism and encapsulation. It minimizes code fragmentation and makes modifying existing code easier. OOP also helps organize code for graphical interfaces. Some advantages are reduced maintenance costs and flexibility. Leading OOP languages include C++, Smalltalk, and Java. C# combines elements of these languages and everything is treated as an object. Classes and objects form the basis of OOP and define data and behaviors through interfaces, members, and methods. Examples demonstrate creating student classes and objects in C#.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views8 pages

Object Oriented Programming: OOP and The Programming Industry

Object oriented programming (OOP) uses objects outside programs like files to design applications. OOP features include inheritance, abstraction, polymorphism and encapsulation. It minimizes code fragmentation and makes modifying existing code easier. OOP also helps organize code for graphical interfaces. Some advantages are reduced maintenance costs and flexibility. Leading OOP languages include C++, Smalltalk, and Java. C# combines elements of these languages and everything is treated as an object. Classes and objects form the basis of OOP and define data and behaviors through interfaces, members, and methods. Examples demonstrate creating student classes and objects in C#.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

IT111P – B55

Object Oriented
Programming
OOP and the programming industry
Patrick Villar

It shows how and what an OOP is; its usage, concepts features.
Object Oriented Programming

OOP is simply including objects outside like sound files, image files, video files or user-defined
files to design applications and computer programs. Some of OOP’s features or techniques are
Inheritance, Abstraction, Polymorphism and Encapsulation. Some if its basic concepts are Classes,
Objects, and Methods. OOP minimizes the fragmentation of codes making it easier to modify existing
codes and be used as objects instead. It helps the programmer to organize their own codes for
developing graphical user interface applications.

An advantage of OOP is at ease of modifying objects reducing the maintenance costs of the
system. OOP is also a complicated procedural programming but allows flexible interactions. According to
ArchWing Innovations “OO systems are also easier for non-technical personnel to understand and easier
for them to participate in the maintenance and enhancement of a system because it appeals to natural
human cognition patterns.” OOP can speed up developing time thus many objects are standard in some
systems and can be reused.

According to AWI there are almost two-dozen major OO languages, the leading commercial OO
languages are:

 C++
 Smalltalk
 Java

C++
C++ is an OO version of C. It is compatible with C (it is actually a superset), so that existing C code can be
incorporated into C++ programs. C++ programs are fast and efficient. 

Smalltalk
Smalltalk is a pure OO language. A rich class library and a dynamic development environment makes
Smalltalk a favorite of OO developers.

Java
Java is the latest, flashiest OO language. It has taken the software industry by storm due to its close ties
with the Internet and Web browsers. Java is a mixture of C++ and Smalltalk.
OOP and C#

The new programming language C# is fully object-oriented and in many respects combines the
best elements of C++, Smalltalk, Java, and Visual Basic. C# is closest to Java among other programming
languages, and the basic structure of the .NET environment is rather close to the Java environment, with
C# and other .NET languages generating an intermediate language, which executes on a virtual machine
(the Common Language Runtime). But C# contains some important enhancements. The most significant
is that in C# "everything is an object," as in Smalltalk. This uniformity greatly simplifies use of the
language, enabling numbers to be treated like objects, stored in collections, and so on. But whereas
Smalltalk paid a heavy performance penalty for such uniformity, C# has a unique concept of "boxing"
and "unboxing," in which a primitive value like a number can be "boxed" into an object wrapper when
there is need for the value to be treated as an object. But for usages where an object is not required,
simple values can be efficiently manipulated directly. http://zone.ni.com/

We can access an object’s data and behaviour through and interface. The object’s data and
behaviour is within the object so a program can treat it like a box accessible only through and interface.

Parts of an object

 Interface
 Behaviour
 Member or instance variables

The code inside the method is a behaviour since it is the code that actually makes the object do the
work. Programs outside can use the object even if we change the implementation for as long as we
don’t change the interface. As long as method name, parameter and returned value is unchanged, we
can alter the behaviour for as long as we want.

Classes in C#

[attributes] [modifiers] class identifier [:base-list] { class-body }[;]

Here are the parts of this statement:

 attributes (Optional)—Attributes hold additional declarative information, as we'll see in Chapter


14, "Using Attributes and Reflection."
 modifiers (Optional)—The allowed modifiers are new, static, virtual, abstract, override, and a
valid combination of the four access modifiers we'll see in this chapter.
 identifier—The class name.
 base-list (Optional)—A list that contains the base class and any implemented interfaces,
separated by commas.
 class-body—Declarations of the class members.
Constructors

[attributes] [modifiers] identifier([formal-parameter-list])


[initializer] { constructor-body }

Here are the parts of this statement:

 attributes (Optional)—Hold additional declarative information, as we'll see in Chapter 14.


 modifiers (Optional)—The allowed modifiers are new, static, virtual, abstract, override, and a
valid combination of the four access modifiers.

 identifier—The same as the class name.


 formal-parameter-list (Optional)—The optional parameters passed to the constructor. The
parameters must be as accessible as the constructor itself.
 initializer (Optional)—Invoked before the execution of the constructor body. The initializer can
be one of the following with an optional argument-list:

:base (argument-list)

:this (argument-list)

 constructor-body—The block that contains the statements that initialize the object.

Namespaces

namespace name[.name1] ...] {


type-declarations
}

Here are the parts of this statement:

 name, name1—A namespace name can be any legal identifier, and it can include periods.

 type-declarations—Within a namespace, you can declare one or more of the following types:
another namespace, a class, interface, struct, enum, or delegate.

You can create as many namespaces in a file as you want; just enclose the code for each namespace in
the code block following the namespace keyword. For example, here's how we can put the Messager
class into the namespace Output:

namespace Output
{
class Messager
{
public string message = "Default message.";

public void DisplayMessage()


{
System.Console.WriteLine(message);
}
}
}

To access Messager outside the Output namespace, you qualify its name as Output.Messsager, just as
you can qualify Console.Writeline as System. Console.WriteLine.

Some Examples

// private data, not publicly accessible

bool OnOff;

int volume;

int channel;

// accessor methods

SwitchOn() ;

SwitchOff() ;

SetVolume( int volume ) ;

SetChannel( int channel) ;

int GetVolume() ;

int GetChannel() ;
Student Class Program

//Class

class Student
{
    // Data Members
    public string Name;
    public int Age;

    // Member Function


    public void Display()
    {
        Console.WriteLine("Name {0}\n Age {1}", Name, Age);
    }
}

//Main

using System;

namespace CSTutorials
{
    class Student
    {
        // Data Members
        public string Name;
        public int Age;
        // Member Function
        public void Display()
        {
            Console.WriteLine("Name {0}\n Age {1}", Name, Age);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Student S1;             // Declaration
            S1 = new Student();     // Instantiation

            Student S2 = new Student();     // Single line Declaration & Instantiation

            // Assigning value to member variables


            S1.Name = "Michael";    
            S1.Age = 37;            

            S1.Name = "Kimi";
            S2.Age = 25;

            // Invoking member function


            S1.Display();          
            S2.Display();          
            Console.ReadLine();
        }
    }
}

Summary

Programming is made easier and efficient because of the OOP’s concepts and features and
never ending improvement of the world of programming. More namespaces that we can include can
become or narrow down to small classes. Simply, OOP is used to make the programming industry
efficient in memory management and prevent the fragmentation of files used by users.
Very useful references

http://www.archwing.com/technet/technet_OO.html

http://www.c-
sharpcorner.com/UploadFile/tusharkantagarwal/objectorientedcsharp11162005070743AM/obj
ectorientedcsharp.aspx

http://cplus.about.com/od/learnc/ss/csharpclasses.htm

http://www.informit.com/articles/article.aspx?p=101373&seqNum=2

http://zone.ni.com/devzone/cda/ph/p/id/45

http://www.astahost.com/info.php/Tutorial-Lesson-4-Object-Oriented-
Programming_t15397.html

http://www.google.com.ph/

You might also like