why a design diagram
play

Why a Design Diagram? S OURCE C ODE is not an appropriate form for - PowerPoint PPT Presentation

Why a Design Diagram? S OURCE C ODE is not an appropriate form for communication. Drawing a Design Diagram Use a D ESIGN D IAGRAM showing selective sets of important: using the Business Object Notation (BON) clusters (i.e., packages)


  1. Why a Design Diagram? ● S OURCE C ODE is not an appropriate form for communication. Drawing a Design Diagram ● Use a D ESIGN D IAGRAM showing selective sets of important: using the Business Object Notation (BON) ○ clusters (i.e., packages) ○ classes [ deferred vs. effective ] [ generic vs. non-generic ] ○ architectural relations [ client-supplier vs. inheritance ] ○ routines (queries and commands) EECS3311 A & E: Software Design [ deferred vs. effective vs. redefined ] Fall 2020 ○ contracts [ precondition vs. postcondition vs. class invariant ] C HEN -W EI W ANG ● Your design diagram is called an abstraction of your system: ○ Being selective on what to show, filtering out irrelevant details ○ Presenting contractual specification in a mathematical form (e.g., ∀ instead of across ... all ... end ). 3 of 26 Learning Objectives Classes: Detailed View vs. Compact View (1) Detailed view shows a selection of: ● ○ features (queries and/or commands) ● Purpose of a Design Diagram : an Abstraction of Your Design ○ contracts (class invariant and feature pre-post-conditions) ● Architectural Relation: Client-Supplier vs. Inheritance ○ Use the detailed view if readers of your design diagram should know such details of a class. ● Presenting a class: Compact vs. Detailed e.g., Classes critical to your design or implementation ● Denoting a Class or Feature: Deferred vs. Effective Compact view shows only the class name. ● ○ Use the compact view if readers should not be bothered with such details of a class. e.g., Minor “helper” classes of your design or implementation e.g., Library classes (e.g., ARRAY , LINKED LIST , HASH TABLE ) 2 of 26 4 of 26

  2. Classes: Classes: Generic vs. Non-Generic Detailed View vs. Compact View (2) ● A class is generic if it declares at least one type parameters. ○ Collection classes are generic: ARRAY[G] , HASH TABLE[G, H] , etc. ○ Type parameter(s) of a class may or may not be instantiated : Detailed View Compact View HA�H��AB�E�G,�H� ����AB�E�1������G,����EGE�� ����AB�E�2��E����,����EGE�� FOO ○ If necessary, present a generic class in the detailed form: feat�re �--���A,�B,���� ��--������������������������������A,�B,������ FOO DATABASE�G�+ M��DB�1�STRING�+ M��DB�2�PERSON�+ feat�re �--��� NONE �� ��--����������������� feature � feature � feature � ��--�������������������������� ��--�������������������������� ��--�������������������������� in�arian� feature �--��� NONE �� feature �--��� NONE �� feature �--��� NONE �� ��--����:� ARRAY �G� ��--����:� ARRAY � STRING � ��--����:� ARRAY �PER�ON� �� in�_1 :�0�<���������<�1,000,000 in�arian� in�arian� in�arian� ��--�������������������������� ��--�������������������������� ��--�������������������������� ● A class is non-generic if it declares no type parameters. 5 of 26 7 of 26 Contracts: Mathematical vs. Programming Deferred vs. Effective ○ When presenting the detailed view of a class, you should include contracts of features which you judge as important . ○ Consider an array-based linear container: A��A�ED�CON�AINE�+ �������� --�Q������ ��c���� + :� IN�EGER ������--� N���������������������������������a���� Deferred means unimplemented ( ≈ abstract in Java) �������� --�C���a�d� ��a�����_a� +� (�:� IN�EGER ;��:� ��RING ) ������ --� C�a���������a����a�����������'�'����'�'. Effective means implemented ���� ������� ������ �a���_����� :�1�������c���� ���� ������ ������ ����_����a���� :����.c�����=�( ��� ����.����).c���� ������ ����_a������� :����[�]���� ������ ������_����a���� :� ∀ ��:�1����������.c�����:������� ⇒ ���[�]���( ��� ����.����)�[�]��� ������� �--��� NONE �� ����� + :� ARRA� [ ��RING ] ����--� I��������a��������a��a��a���-����a���� in�arian� ��������������� :����.c�����=�c���� ● A tag should be included for each contract. ● Use mathematical symbols (e.g., ∀ , ∃ , ≤ ) instead of programming symbols (e.g., across . . . all . . . , across . . . some . . . , <= ). 6 of 26 8 of 26

  3. Classes: Deferred vs. Effective Features: Deferred, Effective, Redefined (2) ● A deferred class has at least one feature unimplemented . ● An effective feature implements some inherited deferred ○ A deferred class may only be used as a static type (for declaration), but cannot be used as a dynamic type. feature. ○ e.g., By declaring list: LIST[INTEGER] (where LIST is a class deferred class), it is invalid to write: DATABASE_V1 [ G ] ● create list.make inherit ● create { LIST[INTEGER] } list.make DATABASE [ G ] feature -- Queries ● An effective class has all features implemented . search ( g : G ): BOOLEAN ○ An effective class may be used as both static and dynamic types. -- Perform a linear search on the database. do end ○ e.g., By declaring list: LIST[INTEGER] , it is valid to write: end ● create { LINKED LIST[INTEGER] } list.make ● create { ARRAYED LIST[INTEGER] } list.make ● A descendant class may still later re-implement this feature. where LINKED LIST and ARRAYED LIST are both effective descendants of LIST . 9 of 26 11 of 26 Features: Deferred, Effective, Redefined (1) Features: Deferred, Effective, Redefined (3) ● A redefined feature re-implements some inherited effective A deferred feature is declared with its header only feature. (i.e., name, parameters, return type). ○ The word “ deferred ” means a descendant class would later class implement this feature. DATABASE_V2 [ G ] inherit ○ The resident class of the deferred feature must also be deferred . DATABASE_V1 [ G ] redefine search end deferred class feature -- Queries DATABASE [ G ] search ( g : G ): BOOLEAN feature -- Queries -- Perform a binary search on the database. search ( g : G ): BOOLEAN do end -- Does item ‘g‘ exist in database? end deferred end end ● A descendant class may still later re-implement this feature. 10 of 26 12 of 26

Recommend


More recommend