How to write better code — follow the interface

<p>If each component is manufacturered and measured according to a standard specs, it can be swapped with other standard-component components.</p> <p>Interface Stability benefits both the programmer and the Operating System Provider.</p> <h1>example: open system call</h1> <ol> <li><strong>Your work as a programmer is simplified, because you don&rsquo;t have to write your own file I/O routines.</strong></li> <li><strong>Your program is likely to be easily portable to any Posix compliant system, because they all provide the same file I/O services.</strong></li> <li><strong>Training time for new programmers is reduced, because everybody already knows how to use the Posix file I/O functions.</strong></li> </ol> <h1>Importance of Interface Specs in Architecture</h1> <p><strong>System Architecture:</strong>&nbsp;defines the major components of the system, the functionality of each, and the interfaces between them.</p> <p>System Architecture lays out the interface specs. We want to make the system work by writing good interfaces.</p> <h1>The Importance of Software Interface Stability</h1> <p>Software Interface Specs: a form of contract where</p> <ul> <li><strong>the contract describes an interface and the associated functionality.</strong></li> <li><strong>implementation providers agree that their systems will conform to the specification.</strong></li> <li><strong>developers agree to limit their use of the functionality to what is described in the interface specification.</strong></li> </ul> <h1>Example: tampering with the interface</h1> <p>Suppose that some architectural genius realized that Posix file semantics are too weak to describe the behavior of files in a distributed system, and that this could be solved by adding a new (required) parameter (for a call-back routine) to the Posix open call. What would happen?</p> <p><a href="https://medium.com/@zichengzhao/how-to-write-better-code-follow-the-interface-72d7adf1e8aa">Visit Now</a></p>