Learning Objective 3.1.A: Represent the design of a program by using natural language or creating diagrams that indicate the classes in the program and the data and procedural abstractions found in each class by including all attributes and behaviors.
- 3.1.A.1 Abstraction is the process of reducing complexity by focusing on the main idea. By hiding details irrelevant to the question at hand and bringing together related and useful details, abstraction reduces complexity and allows one to focus on the idea.
- 3.1.A.2 Data abstraction provides a separation between the abstract properties of a data type and the concrete details of its representation. Data abstraction manages complexity by giving data a name without referencing the specific details of the representation. Data can take the form of a single variable or a collection of data, such as in a class or a set of data.
- 3.1.A.3 An attribute is a type of data abstraction that is defined in a class outside any method or constructor. An instance variable is an attribute whose value is unique to each instance of the class. A class variable is an attribute shared by all instances of the class.
- 3.1.A.4 Procedural abstraction provides a name for a process and allows a method to be used only knowing what it does, not how it does it. Through method decomposition, a programmer breaks down larger behaviors of the class into smaller behaviors by creating methods to represent each individual smaller behavior. A procedural abstraction may extract shared features to generalize functionality instead of duplicating code. This allows for code reuse, which helps manage complexity.
- 3.1.A.5 Using parameters allows procedures to be generalized, enabling the procedures to be reused with a range of input values or arguments.
- 3.1.A.6 Using procedural abstraction in a program allows programmers to change the internals of a method (to make it faster, more efficient, use less storage, etc.) without needing to notify method users of the change as long as the method signature and what the method does is preserved.
- 3.1.A.7 Prior to implementing a class, it is helpful to take time to design each class including its attributes and behaviors. This design can be represented using natural language or diagrams.
วัตถุประสงค์การเรียนรู้ 3.1.A: แสดงการออกแบบโปรแกรมโดยใช้ภาษาธรรมชาติหรือสร้างแผนภาพที่ระบุคลาสในโปรแกรมและ抽象ข้อมูลและกระบวนการที่พบในแต่ละคลาสโดยรวมถึงคุณสมบัติและการกระทำทั้งหมด
- 3.1.A.1 Abstraction คือกระบวนการลดความซับซ้อนด้วยการมุ่งเน้นไปที่แนวคิดหลัก通过将ไม่เกี่ยวข้องกับคำถามปัจจุบันซ่อนไว้และรวบรวมรายละเอียดที่เกี่ยวข้องและมีประโยชน์เข้าด้วยกัน Abstraction ช่วยลดความซับซ้อนและทำให้สามารถมุ่งเน้นไปที่แนวคิดได้
- 3.1.A.2 Data abstraction ให้การแยกระหว่างคุณสมบัติเชิงนามธรรมของชนิดข้อมูล รายละเอียดจริงของการแสดงผล Data abstraction จัดการความซับซ้อนโดยให้ชื่อแก่ข้อมูลโดยไม่อ้างอิงรายละเอียดเฉพาะของการแสดงผล ข้อมูลอาจอยู่ในรูปแบบของตัวแปรเดียวหรือกลุ่มข้อมูล เช่น ในคลาสหรือชุดข้อมูล
- 3.1.A.3 Attribute เป็นประเภทหนึ่งของ Data abstraction ที่กำหนดไว้ในคลาสภายนอก-method หรือ constructor Instance variable เป็น attribute ที่มีค่าเฉพาะสำหรับแต่ละ instance ของคลาส Class variable เป็น attribute ที่แบ่งปันโดยทุก instance ของคลาส
- 3.1.A.4 Procedural abstraction ให้ชื่อสำหรับกระบวนการและทำให้สามารถใช้ method ได้โดยรู้เพียงว่าทำอะไร ไม่ใช่วิธีการทำ ผ่าน method decomposition นักเขียนโปรแกรมจะย่อยพฤติกรรมขนาดใหญ่ของคลาสออกเป็นพฤติกรรมย่อยๆ โดยการสร้าง methods เพื่อแสดงพฤติกรรมย่อยแต่ละอย่าง Procedural abstraction อาจดึงคุณลักษณะที่ร่วมกันมาเพื่อทำให้ฟังก์ชัน性工作ทั่วไปแทนที่จะทำซ้ำโค้ด สิ่งนี้ช่วยให้ใช้โค้ดซ้ำได้ ซึ่งช่วยจัดการความซับซ้อน
- 3.1.A.5 การใช้ parameters ช่วยให้ procedures可以被 generalize ทำให้ procedures สามารถถูก reuse ด้วยช่วงของ input values หรือ arguments
- 3.1.A.6 การใช้ procedural abstraction ในโปรแกรมอนุญาตให้นักเขียนโปรแกรมเปลี่ยนแปลงภายในของ method (เพื่อให้เร็วขึ้น มีประสิทธิภาพมากขึ้น ใช้พื้นที่จัดเก็บน้อยลง ฯลฯ) โดยไม่ต้องแจ้ง给用户关于การเปลี่ยนแปลงตราบใดที่ method signature และสิ่งที่ method ทำยังคงอยู่
- 3.1.A.7 ก่อนที่จะดำเนินการสร้างคลาส จะเป็นการดีที่จะใช้เวลาในการออกแบบแต่ละคลาส รวมถึง properties และ behaviors การออกแบบนี้สามารถแสดงได้ด้วยภาษาธรรมชาติหรือแผนภาพ

