Saturday, December 30, 2017

Session 9

Session 9
Saturday, 2 desember 2017

Today is my group's turn to present today's topic "Object Oriented Programming" but because Miss Yanfi made a mistake and list us to present session 7's topic "Abstract Data Type" so Miss Yanfi gave us option to choose between session 7 "Abstract Data Type" or session 8 "Object Oriented Programming". My group chose to present session 7 "Abstract Data Type". Today we discuss about The Concept of Abstraction, Introduction to Data Abstraction, Language Examples, Parameterized Abstract Data Types, Encapsulation Constructs, and Naming Encapsulations. After we explain the topics, there were some questions. We were a little confused about the answers for the questions and ask some of it to Miss Yanfi. On this session there's also mind map that Miss Yanfi made for us.

This session talks about the introduction, Object-Oriented Programming, Design Issues for Object-Oriented Languages, Support for Object-Oriented Programming in C++, and The Implementation of Object-Oriented Constructs.

3 major language features :

  • Abstract data type.
  • Inheritance.
  • Polymorphism.
Inheritance allows new classes defined in terms of existing ones, i.e., by allowing them to inherit common parts. Inheritance addresses both of the above concerns--reuse ADTs after minor changes and define classes in a hierarchy.

Three ways a class can differ from its parent:
1. The parent class can define some of its variables or methods to have private access, which means they will not be visible in the subclass.
2. The subclass can add variables and/or methods to those inherited from the parent.
3. The subclass can modify the behavior of one or more of its inherited methods.

A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants.

Design Issues for OOP Language :
•The Exclusivity of Objects.
•Are Subclasses Subtypes?
•Single and Multiple Inheritance.
•Object Allocation and Deallocation.
•Dynamic and Static Binding.
•Nested Classes.
•Initialization of Objects.

That's all for this session.

Friday, December 29, 2017

Session 8 - GSLC

Session 8
Saturday, 25 November 2017

Today is GSLC session. Miss Yanfi gave us some questions to answer on the binusmaya's forum.
Here are the questions:

1. What are the similarities of and the differences between Java Packages and C++ Namespace?
2. Explain the dangers of C's approach to encapsulation.

And these are my answers that i wrote on the forum:

1. Similarity : 
- Java uses packages to group classes. C++ uses namespace to group related function and classes. 
- Java package and c++ namespace both make the code cleaner and less redundant. 
- Java package and c++ namespace both provide breakup for class names. 
- Java package and c++ namespace are both abstract container for classes. 

Difference : 
- Java package cant be nested. c++ namespace can be nested. 
- C++ namespace are just used for partitioning names to avoid collisions. java package are used for modules, the naming aspect is just a part of it. 
- In java you can apply various access specifiers to classes which will have impact on your package. these type of access specifiers are not applicable to namespace in C++. 

2. The main problem is that the biggest part of encapsulation is done via hiding, rather than protection. This is achieved through definition hiding: a header file is preprocessed (which is a synonym for copy-pasted) into the implementation file. Anyone with this header file will be able to access any method or public variable of a the client related to the header, left apart any "static" method / variable. The documentation of the dependence of the client program on the library (and its header file) is lost. The author of the library could change the header file and the implementation file, but the client could attempt to use the new implementation file (not realizing it had changed) but with the old header file, which the user had copied into his or her client program.