CS136 Lecture Notes - Lecture 12: Information Hiding, In C, Data Structure
Document Summary
For consistency, always have (# include my-module. h ) even in (my-module. c: my-module. c, my-module. h, client. c. Prevent the client from tampering with data used by the module. Ensure only way the client can interact with the module is through the interface: flexibility. Can change the implementation freely, updates and lots. Avoid client to write based on implementation, which create error when implementation is changed: in c. C is not very good at hiding data. Can simply guess the memory address of some data. Opaque structures: good for hiding data from a friendly client, like a black box , incomplete declarations (a struct is declared without any fields) Incomplete declarations (a struct is declared without any fields) Opaque, structure details hidden away > client cannot access: full structure definition in implementation file + incomplete structure in the interface. Transparent, structure details available to all: full structure definition in interface. Data structure & abstract data types: as clients doesn"t know how data was structured.