Object Oriented
Object Oriented
What is "Object Oriented" Means Please Explain Step by Step in Simple words
Thanks
Thanks
Re: Object Oriented
An object is a discrete bundle of functions and procedures, all relating to a particular real-world concept such as a bank account holder or hockey player. Other pieces of software can access the object only by calling its functions and procedures that have been allowed to be called by outsiders. A large number of software engineers agree that isolating objects in this way makes their software easier to manage and keep track of.
Fundamental concepts and features
You need to learn and get familiar with following concepts clearly to proceed further.
Class
A class defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviours (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog would consist of traits shared by all dogs, such as breed and fur colour (characteristics), and the ability to bark and sit (behaviours). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self-contained (generally using encapsulation). Collectively, the properties and methods defined by a class are called members.
Object
A pattern (exemplar) of a class. The class Dog defines all possible dogs by listing the characteristics and behaviours they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.
Instance
One can have an instance of a class; the instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that's defined in the object's class.
Method
An object's abilities. In language, methods (sometimes referred to as "functions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit() or eat() or walk() or save(timmy). Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking.
Message passing
"The process by which an object sends data to another object or asks the other object to invoke a method." Also known to some programming languages as interfacing. For example, the object called Breeder may tell the Lassie object to sit by passing a "sit" message which invokes Lassie's "sit" method. The syntax varies between languages, for example: [Lassie sit] in Objective-C. In Java, code-level message passing corresponds to "method calling". Some dynamic languages use double-dispatch or multi-dispatch to find and pass messages.
Inheritance
"Subclasses" are more specialized versions of a class, which inherit attributes and behaviours from their parent classes, and can introduce their own.
For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance of the Collie subclass. Suppose the Dog class defines a method called bark() and a property called furColor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once.
Each subclass can alter its inherited traits. For example, the Collie subclass might specify that the default furColor for a collie is brown-and-white. The Chihuahua subclass might specify that the bark() method produces a high pitch by default. Subclasses can also add new members. The Chihuahua subclass could add a method called tremble(). So an individual chihuahua instance would use a high-pitched bark() from the Chihuahua subclass, which in turn inherited the usual bark() from Dog. The chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua. In fact, inheritance is an "a... is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class: a Collie is a Dog ("a... is a"), but Lassie is a Collie ("is a"). Thus, the object named Lassie has the methods from both classes Collie and Dog.
Multiple inheritance is inheritance from more than one ancestor class, neither of these ancestors being an ancestor of the other. For example, independent classes could define Dogs and Cats, and a Chimera object could be created from these two which inherits all the (multiple) behaviour of cats and dogs. This is not always supported, as it can be hard to implement.
Abstraction
Main article: Abstraction (computer science)
Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviours, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.
Abstraction is also achieved through Composition. For example, a class
Encapsulation
Encapsulation conceals the functional details of a class from objects that send messages to it.
For example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume). Timmy, Lassie's friend, however, does not need to know exactly how she barks. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface — those members accessible to that class. The reason for encapsulation is to prevent clients of an interface from depending on those parts of the implementation that are likely to change in the future, thereby allowing those changes to be made more easily, that is, without changes to clients. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: Java uses the default access modifier to restrict access also to classes in the same package, C# and VB.NET reserve some members to classes in the same assembly using keywords internal (C#) or Friend (VB.NET), and Eiffel and C++ allow one to specify which classes may access any member.
(Subtype) polymorphism
Polymorphism allows the programmer to treat derived class members just like their parent class's members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name, each one according to an appropriate type-specific behaviour. One method, or an operator such as +, -, or *, can be abstractly applied in many different situations. If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). Each subclass overrides the speak() method inherited from the parent class Animal.
Decoupling
Decoupling allows for the separation of object interactions from classes and inheritance into distinct layers of abstraction. A common use of decoupling is to polymorphically decouple the encapsulation, which is the practice of using reusable code to prevent discrete code modules from interacting with each other. However, in practice decoupling often involves trade-offs with regard to which patterns of change to favour. The science of measuring these trade-offs in respect to actual change in an objective way is still in its infancy.
Now you must be clear on the terms that are used in OOP. In the next step, we can move on to define Object Oriented Programming principles.
Fundamental concepts and features
You need to learn and get familiar with following concepts clearly to proceed further.
Class
A class defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviours (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog would consist of traits shared by all dogs, such as breed and fur colour (characteristics), and the ability to bark and sit (behaviours). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self-contained (generally using encapsulation). Collectively, the properties and methods defined by a class are called members.
Object
A pattern (exemplar) of a class. The class Dog defines all possible dogs by listing the characteristics and behaviours they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.
Instance
One can have an instance of a class; the instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that's defined in the object's class.
Method
An object's abilities. In language, methods (sometimes referred to as "functions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit() or eat() or walk() or save(timmy). Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking.
Message passing
"The process by which an object sends data to another object or asks the other object to invoke a method." Also known to some programming languages as interfacing. For example, the object called Breeder may tell the Lassie object to sit by passing a "sit" message which invokes Lassie's "sit" method. The syntax varies between languages, for example: [Lassie sit] in Objective-C. In Java, code-level message passing corresponds to "method calling". Some dynamic languages use double-dispatch or multi-dispatch to find and pass messages.
Inheritance
"Subclasses" are more specialized versions of a class, which inherit attributes and behaviours from their parent classes, and can introduce their own.
For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance of the Collie subclass. Suppose the Dog class defines a method called bark() and a property called furColor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once.
Each subclass can alter its inherited traits. For example, the Collie subclass might specify that the default furColor for a collie is brown-and-white. The Chihuahua subclass might specify that the bark() method produces a high pitch by default. Subclasses can also add new members. The Chihuahua subclass could add a method called tremble(). So an individual chihuahua instance would use a high-pitched bark() from the Chihuahua subclass, which in turn inherited the usual bark() from Dog. The chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua. In fact, inheritance is an "a... is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class: a Collie is a Dog ("a... is a"), but Lassie is a Collie ("is a"). Thus, the object named Lassie has the methods from both classes Collie and Dog.
Multiple inheritance is inheritance from more than one ancestor class, neither of these ancestors being an ancestor of the other. For example, independent classes could define Dogs and Cats, and a Chimera object could be created from these two which inherits all the (multiple) behaviour of cats and dogs. This is not always supported, as it can be hard to implement.
Abstraction
Main article: Abstraction (computer science)
Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviours, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.
Abstraction is also achieved through Composition. For example, a class
Encapsulation
Encapsulation conceals the functional details of a class from objects that send messages to it.
For example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume). Timmy, Lassie's friend, however, does not need to know exactly how she barks. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface — those members accessible to that class. The reason for encapsulation is to prevent clients of an interface from depending on those parts of the implementation that are likely to change in the future, thereby allowing those changes to be made more easily, that is, without changes to clients. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: Java uses the default access modifier to restrict access also to classes in the same package, C# and VB.NET reserve some members to classes in the same assembly using keywords internal (C#) or Friend (VB.NET), and Eiffel and C++ allow one to specify which classes may access any member.
(Subtype) polymorphism
Polymorphism allows the programmer to treat derived class members just like their parent class's members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name, each one according to an appropriate type-specific behaviour. One method, or an operator such as +, -, or *, can be abstractly applied in many different situations. If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). Each subclass overrides the speak() method inherited from the parent class Animal.
Decoupling
Decoupling allows for the separation of object interactions from classes and inheritance into distinct layers of abstraction. A common use of decoupling is to polymorphically decouple the encapsulation, which is the practice of using reusable code to prevent discrete code modules from interacting with each other. However, in practice decoupling often involves trade-offs with regard to which patterns of change to favour. The science of measuring these trade-offs in respect to actual change in an objective way is still in its infancy.
Now you must be clear on the terms that are used in OOP. In the next step, we can move on to define Object Oriented Programming principles.
Re: Object Oriented
Introduction to Object Oriented Programming, Part 1 (Video)
[media]http://www.youtube.com/watch?v=mDGhN6Jh9YA[/media]
Introduction to Object Oriented Programming, Part 2 (Video)
[media]http://www.youtube.com/watch?v=_om9zKjBoDY[/media]
Object Oriented Programming Concepts (Video)
[media]http://www.youtube.com/watch?v=NtfJxA1J3h8[/media]
[media]http://www.youtube.com/watch?v=mDGhN6Jh9YA[/media]
Introduction to Object Oriented Programming, Part 2 (Video)
[media]http://www.youtube.com/watch?v=_om9zKjBoDY[/media]
Object Oriented Programming Concepts (Video)
[media]http://www.youtube.com/watch?v=NtfJxA1J3h8[/media]
Re: Object Oriented
Thanks for all
Re: Object Oriented
I've Read they Friends but I'm Confused So I decided to Search More in the Internet to get an Idea,
So
I watched YouTube videos but No Luck only Little things got
Then Read more Articles and Confused More.
Then I came Across This Site, It is about OOP but with PHP but I was able to get some Idea from It and I am going to Search for More to Get the Rest
http://www.forgetdbigwords.com/wordpres ... hp-part-1/
Now I am Clear with Some
If you Know more about these Please Let Me know, I really Need them.
Thanks for the Helps Guys
So
I watched YouTube videos but No Luck only Little things got
Then Read more Articles and Confused More.
Then I came Across This Site, It is about OOP but with PHP but I was able to get some Idea from It and I am going to Search for More to Get the Rest
http://www.forgetdbigwords.com/wordpres ... hp-part-1/
Now I am Clear with Some
If you Know more about these Please Let Me know, I really Need them.
Thanks for the Helps Guys
Re: Object Oriented
This one is an OOP with Java tutorial & seems to cover all theoretical aspects in OOP in university level. (You will mostly learn things under BIT in this fashion).
This one is from Oracle (Owners of Java now.. Sun (previous owner) no longer exists).
http://download.oracle.com/javase/tutor ... index.html
The following page is one of the simplest explanations I found for OOP and Java on web. It is also from a university so it covers all aspects in OOP with Java.
http://sepwww.stanford.edu/sep/jon/fami ... p/oop1.htm
Always remember, don't go out of concept. There is no use for you to lean OOP with Java for your degree (since I already know information about you ). It is very useful to learn things that will help your degree as well. Otherwise it would be a waste of time at this time.
You can ask questions related to that but make sure you put a good title as much as possible to save my time
This one is from Oracle (Owners of Java now.. Sun (previous owner) no longer exists).
http://download.oracle.com/javase/tutor ... index.html
The following page is one of the simplest explanations I found for OOP and Java on web. It is also from a university so it covers all aspects in OOP with Java.
http://sepwww.stanford.edu/sep/jon/fami ... p/oop1.htm
Always remember, don't go out of concept. There is no use for you to lean OOP with Java for your degree (since I already know information about you ). It is very useful to learn things that will help your degree as well. Otherwise it would be a waste of time at this time.
You can ask questions related to that but make sure you put a good title as much as possible to save my time
Re: Object Oriented
Thanks Friend I will Read those too.
Now I am always adding Good Titles as much as I can.
If you can Change the Topic to a topic that will well be related to our discussion.
BTW: Now VLE has posted Semester 2 Subjects, And I can Refer those too.
But Semester 1 Subjects have Gone. When will they Posted? I think they will be posted at September when Semester 1 for next year starts. Am I right?
Now I am always adding Good Titles as much as I can.
If you can Change the Topic to a topic that will well be related to our discussion.
BTW: Now VLE has posted Semester 2 Subjects, And I can Refer those too.
But Semester 1 Subjects have Gone. When will they Posted? I think they will be posted at September when Semester 1 for next year starts. Am I right?
Re: Object Oriented
No idea. Since I don't know about BIT degree, you better call UCSC/BIT office for that.But Semester 1 Subjects have Gone. When will they Posted? I think they will be posted at September when Semester 1 for next year starts. Am I right?
Re: Object Oriented
It's OK. I will wait anyway because I must do Semester 2 Subjects very well then move into Semester 1 again later.
Last time i didn't get much time to do Semester 1 , And Missed the Exam too.
I won't let it happen again
Last time i didn't get much time to do Semester 1 , And Missed the Exam too.
I won't let it happen again
Re: Object Oriented
Nipuna you can do semester one examination in this September & then you can do semester 1 & semester 3 both in next 2012 march
Don't worry brother you will finish it fine
I was really busy with new year season.Sorry about the late reply.I am so tired these days .
wishes from g-sparkz
Don't worry brother you will finish it fine
I was really busy with new year season.Sorry about the late reply.I am so tired these days .
wishes from g-sparkz