* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Programming Style
Swift (programming language) wikipedia , lookup
Java (programming language) wikipedia , lookup
Join-pattern wikipedia , lookup
Library (computing) wikipedia , lookup
Name mangling wikipedia , lookup
Scala (programming language) wikipedia , lookup
Class (computer programming) wikipedia , lookup
Java performance wikipedia , lookup
Software bug wikipedia , lookup
Control flow wikipedia , lookup
Corecursion wikipedia , lookup
Logic programming wikipedia , lookup
Indentation style wikipedia , lookup
Java ConcurrentMap wikipedia , lookup
Programming language wikipedia , lookup
Design Patterns wikipedia , lookup
C Sharp syntax wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Functional programming wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Go (programming language) wikipedia , lookup
Reactive programming wikipedia , lookup
Structured programming wikipedia , lookup
Programming Style Chapter 14 Part 3: Implementation Object-Oriented Modeling and Design Byung-Hyun Ha bhha@pusan.ac.kr Lecture Outline  Introduction  Object-Oriented Style     Reusability Extensibility Robustness Programming-in-the-large Introduction  The experienced programmer follows principles to make readable programs that live beyond the immediate need  Good style is important in all programming, but it is even more important in OO design and programming because much of the benefit of the OO approach is predicated on producing reusable, extensible, understandable programs Object-Oriented Style  Reusability  Extensibility  Robustness  Programming-in-the-large Reusability  Kind of reusability  Sharing of newly-written code within a project  Reuse of previously-written code on new projects  Style rules for reusability         Keep methods coherent Keep methods small Keep methods consistent Separate policy and implementation Provide uniform coverage Broaden the method as much as possible Avoid global information Avoid modes Reusability  Using inheritance     Subroutines Factoring Delegation Encapsulate external code Extensibility  OO principles for extensibility      Encapsulate classes Hide data structures Avoid traversing multiple links or methods Avoid cast statements on object type Distinguish public and private operations Robustness  Guidelines for robustness  Protect against errors • User errors and low-level system errors • Programming bugs     Optimize after the program runs Validate arguments Avoid predefined limits Instrument the program for debugging and performance monitoring Programming-in-the-large  Guidelines          Do not prematurely begin programming Keep method understandable Make methods readable Use exactly the same names as in the object model Choose name carefully Use programming guidelines Package into modules Document classes and methods Publish the specification Appendix: OO and Programming  We already discussed…  Farm  toString() and priority queue  Window programming  They cannot be possible without inheritance and polymorphism  If you want to prepare those functionalities in the examples, you should consider the use of OO concepts  Otherwise, your program will never be understandable (even for yourself), extensible, and reusable Appendix: OO and Programming  Inventory example  Inventory simulation  Assumptions • • • • Two types of suppliers Three types of demands Two types of policies Two ways of displaying results  If you want to carry out simulation for every possible combination of settings, you have to write 24 (= 2x3x2x2) programs • Too complex to write and manage  Let’s make them using one program (Inv_manage1.java) • How about it? • Could you understand? • Do you think you can easily extend the program? Appendix: OO and Programming  Inventory example (cont’)  Let’s use OO concepts (Inv_manage2.java, …)  First of all, easy to understand  Coherent, small, clear, consistent, extendible, reusable, … Inv_manage Supplier Demand Policy Display put_order today_deliever today_demand today_order show Appendix: OO and Programming  Tree example  Tree traversal with different purposes  Structural way (Tree1.java) • We should implement traversal algorithm every time we need  OO way (Tree2.java) • Don’t care about how to traverse, only need to write what to do 1 2 4 3 5 5 2 2 6 1 3 7
 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                            