3-1 Discussion: Object-oriented Programming Principles
This week, you have learned about various object-oriented programming principles and their importance in programming. In this discussion, you will spend time discussing these principles with your peers. You will also reflect on what you have learned in the first few modules of the course. In your initial post for this discussion, address the following:
How do the four main OOP principles (inheritance, encapsulation, abstraction, and polymorphism) work together to make a well-designed application? How do they allow a programmer to create more reusable and maintainable code?
What was the most interesting thing that you learned in the course so far?
What concept(s) do you feel are unclear or that you need more practice applying?
In responding to your classmates, address the following:
What did you learn from your classmate's post? Do you have any additional information on any of the principles for your classmate to consider?
What did you find interesting or relatable in your peers' posts?
Undergraduate Discussion Rubric
Overview
Your active participation in the discussions is essential to your overall success this term. Discussion questions will help you make meaningful connections between the course content and the larger concepts of the course. These discussions give you a chance to express your own thoughts, ask questions, and gain insight from your peers and instructor.
Directions
For each discussion, you must create one initial post and follow up with at least two response posts.
For your initial post, do the following:
Write a post of 1 to 2 paragraphs.
In Module One, complete your initial post by Thursday at 11:59 p.m. Eastern.
In Modules Two through Eight, complete your initial post by Thursday at 11:59 p.m. of your local time zone.
Consider content from other parts of the course where appropriate. Use proper citation methods for your discipline when referencing scholarly or popular sources.
For your response posts, do the following:
Reply to at least two classmates outside of your own initial post thread.
In Module One, complete your two response posts by Sunday at 11:59 p.m. Eastern.
In Modules Two through Eight, complete your two response posts by Sunday at 11:59 p.m. of your local time zone.
Demonstrate more depth and thought than saying things like “I agree” or “You are wrong.” Guidance is provided for you in the discussion prompt.
Discussion Rubric
Criteria
Exemplary
Proficient
Needs Improvement
Not Evident
Value
Comprehension
Develops an initial post with an organized, clear point of view or idea using rich and significant detail (100%)
Develops an initial post with a point of view or idea using adequate organization and detail (85%)
Develops an initial post with a point of view or idea but with some gaps in organization and detail (55%)
Does not develop an initial post with an organized point of view or idea (0%)
40
Timeliness
N/A
Submits initial post on time (100%)
Submits initial post one day late (55%)
Submits initial post two or more days late (0%)
10
Engagement
Provides relevant and meaningful response posts with clarifying explanation and detail (100%)
Provides relevant response posts with some explanation and detail (85%)
Provides somewhat relevant response posts with some explanation and detail (55%)
Provides response posts that are generic with little explanation or detail (0%)
30
Writing (Mechanics)
Writes posts that are easily understood, clear, and concise using proper citation methods where applicable with no errors in citations (100%)
Writes posts that are easily understood using proper citation methods where applicable with few errors in citations (85%)
Writes posts that are understandable using proper citation methods where applicable with a number of errors in citations (55%)
Writes posts that others are not able to understand and does not use proper citation methods where applicable (0%)
20
Total:
100%
Response one
Object-oriented Programming Principles
Dylan Bayless
Hello class!
The 4 pillars of OOP principles are inheritance, encapsulation, abstraction and polymorphism. Combining these 4 pillars makes designing a program much cleaner and easier. Rather than copying the same function over and over again in your program OOP does all of this with the same core function.
Inheritance- This allows a class to be multiple classes or separate classes from previous classes.
Encapsulation-Is used to hide information from people and programmers. This is used to make things simpler for programmers. This way a programmer needs to understand the qualities of an object, rather than how it works. Encapsulation is also used to keep certain code safe from other users/programmers.
Abstraction is used to create classes and subclasses by finding certain principles of objects. They can create or use these objects to classify them into certain categories.
Polymorphism- allows classes that can make a previous class to use things differently.
OOP makes things easier, simpler, and cleaner for programmers and users.
The most interesting thing I’ve learned in this course is how differently people can use java. There are so many ways to use java. It's amazing how you can find 10 different ways to finish the same way.
Response 2
3-1 Discussion: Object-oriented Programming Principles
Corey Agnew
The four main OOP principles work together in different ways to create a well-designed application. Encapsulation does its part in a well-designed application by allowing the programmer to self-contain variables and then only allowing the alteration of them through publicly defined methods, which allows data to be more controllably accessed and modified. Abstraction is important because it tries to hide everything internal that does not concern the user and leaves only what is necessary to make it less complex. Inheritance allows the object to pull from different classes and use the information to reduce redundant code and allow for more organized code. Polymorphism lets code be called in such a way that enables flexibility and modification. All four of these principles combine to allow code that is readable, organized, and flexible.
The most interesting thing we learned so far is the methods, differences, and similarities from the Python counterpart have been the most interesting to try and distinguish between as they are major parts of both languages. Taking that Python class has also led me to the biggest problem with Java, the differences in syntax as I sometimes try to merge the two languages. I am sure this problem will go away with time but at the current moment, it is my biggest downfall while going through the problems.
Reply to Thread
My Initial post
View profile card for richard Wyckoff
3-1 initial popst discusionn
richard Wyckoff posted Jul 17, 2024 3:43 PM
Subscribed
This page automatically marks posts as read as you scroll.
Adjust automatic marking as read setting
Hello class!
The four pillars of OOP—inheritance, encapsulation, abstraction, and polymorphism—when beautifully put together, create robust, maintainable applications. Inheritance enables the implementation of hierarchical relationships between classes where the child classes inherit properties and behaviors from the parent classes. This reduces code duplication and increases code reusability (javatpoint, 2011). Now, let's consider we need to handle some other kind of pet, for example, cats: This is realized because of inheritance. We can define a class: CatDetails, which inherits all the features from another class, DogDetails — both class attributes such as name, age, weight, and so on, and class methods such as getName, getAge, etc. The attributes that need to be defined in CatDetails are the attributes of cats: the type of fur, the pitch of meows, and so on. This avoids us from rewriting code again, meaning reusability. In a boarding facility application, a base PetDetails class could be the parent for the DogDetails and CatDetails, inheriting common functionalities.
Encapsulation involves putting data (attributes) and functions (methods) manipulating that data together in one block (class) (javatpoint, 2011). In DogDetails, for instance, you'd expect attributes such as name to be private with no direct access. The public methods are gatekeepers like getName, which gives controlled access so that people can retrieve the data. This data protection feature guarantees that only the intended and authorized users are able to change this data to prevent unintended consequences—for example, trying to set a dog's age to a negative value by mistake. Encapsulation prevents this kind of mistake by controlling the way data is manipulated.
Abstraction enables the exposition of only vital functionalities of an object to allow it to hide the implementation details. This simplifies code for users of the class with loose coupling, which means that changes in one part of the code have minimal effects on the others.
Abstraction is revealing the necessary functionalities to the outside world while hiding the implementation details (javatpoint, 2011). The class DogDetails is an example, since it has such functions as getName and getAge that return information about the dog. The user needing to read and modify data does not need to know how these functions are implemented internally. This makes the code easier to use and has the added advantage of loose coupling; changes to the inside of DogDetails, for instance, the way getName obtains the name, do not change the parts of the program using getName to obtain a dog's name.
Polymorphism allows a similar behavior in different objects with a similar interface, even though those objects differ in implementation. This flexibility makes the code more adaptable and easier to extend (javatpoint, 2011). For example, we have a Boarding class that has a member method checkIn. That member method could be multi-typed as one boarding location might fulfill different pet types. Now, using polymorphism, we could have one checkIn method but have it implemented differently based on the passed arguments-in pet object—for example, calling different methods if it was for dog boarding or for cat boarding. This can help you write your code in a way that is flexible and changeable. For instance, consider somehow expanding a check-in so that it can be checked in for another pet type, let's say rabbits. There wouldn't be a change in the main check-in logic, but just more specific information handled in the Rabbit subclass, e.g., RabbitDetails.
The most fascinating concept ever learned so far is inheritance. It feels like using the power of the previously written code in building new functionality. We can make classes that would specialize in some certain functionality by inheritance of attributes and methods. Ends up saving development time but also leads to consistency in the code.
I am, however, grappling a bit with the nuances of access modifiers in encapsulation—public, private, and protected. I understand what they do to protect data, but implementing these effectively in a well-encapsulated class while ensuring the right kind of access is a place where I feel that I need more practice. Also, while I understand polymorphism in theory, I would like to go through practical examples that will help cement how this is implemented in different programming languages.
To conclude, Inheritance in Java allows for code reuse, reducing the need to duplicate data protection logic across similar classes. Encapsulation promotes modularity, hiding implementation details within well-defined modules. Abstraction simplifies code for users by focusing on interfaces rather than specific class implementations. Polymorphism allows for flexible interactions between objects, complementing inheritance by enabling specialized behavior in child classes. By leveraging these principles, a system with well-defined, reusable components and clear interfaces is created, making the code easier to understand, maintain, and extend as the application grows (javatpoint, 2011). For example, a Vaccinate method in DogDetails might handle different protocols than a Vaccinate method in a CatDetails class.
I look forward to discussing these principles further with my peers and really knowing how they all work together to create elegant, maintainable object-oriented applications.
References
javatpoint. (2011). Java OOPs Concepts - Javatpoint. Www.javatpoint.com. https://www.javatpoint.com/java-oops-concepts