4. Encapsulation - CS2030S Programming Methodology II
Just like functions allow programmers to group instructions, give it a name, and refer to it later, a composite data type allows programmers to group primitive types together, give it a name (a new type), and refer to it later. This is another powerful abstraction in programming languages that help us to think at a higher conceptual level without worrying about the details. Commonly used examples are mathematical objects such as complex numbers, 2D data points, multi-dimensional vectors, circles, etc, or everyday objects such as a person, a product, etc. Defining composite data type allows programmers to abstract away (and be separated from the concern of) how a complex data type is represented. For instance, a circle on a 2D plane can be represented by the center (x, y) and its radius r, or it can be represented by the top left corner (x,y) and the width w of the bounding square. In C, we build a composite data type with struct. For example, Once we have the struct defined, we are not
Unit 4: Encapsulation After reading this unit, students should understand composite data type as a even-higher level abstraction over variables understand encapsulation as an object-oriented (OO) principle understand the meaning of class, object, fields, methods, in the context of OO programming be able to define a class and instantiate one as an object in Java appreciate OO as a natural way to model the real world in programs understand reference types in Java and its difference from the primitive types Abstraction: Composite Data Type Just like functions allow programmers to group instructio
Explore this link on the map →saved by
related reading
- 17. Abstract Class - CS2030S Programming Methodology IInus-cs2030s.github.io
- 2. Variable and Type - CS2030S Programming Methodology IInus-cs2030s.github.io
- 19. Wrapper Class - CS2030S Programming Methodology IInus-cs2030s.github.io
- Lab 1: Simulation I - CS2030S Programming Methodology IInus-cs2030s.github.io
- 20. Casting - CS2030S Programming Methodology IInus-cs2030s.github.io
- 14. Polymorphism - CS2030S Programming Methodology IInus-cs2030s.github.io
- 21. Variance - CS2030S Programming Methodology IInus-cs2030s.github.io
- how I think when I think about programming - alice mazalicemaz.com
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- LEAP 71 | PicoGK.org Blogpicogk.org
- Object-oriented programming - Learn web development | MDNdeveloper.mozilla.org
- Abstractioncs.cornell.edu