Software Engineering CSC 326
Popular in Course
verified elite notetaker
verified elite notetaker
verified elite notetaker
RELG 361 001
verified elite notetaker
verified elite notetaker
verified elite notetaker
Popular in ComputerScienence
This 48 page Class Notes was uploaded by Jaden Jakubowski on Thursday October 15, 2015. The Class Notes belongs to CSC 326 at North Carolina State University taught by Staff in Fall. Since its upload, it has received 13 views. For similar materials see /class/223822/csc-326-north-carolina-state-university in ComputerScienence at North Carolina State University.
Reviews for Software Engineering
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/15/15
Singleton Structural and q Adapter Patterns By Anton Roukhline John Setzer and Jingfeng Yu Information taken from Design Patterns Overview Singleton Summary of Structural Patterns Adapter lSingleton Creational Pattern Intent To ensure that a class has exactly one instance and provide global access to that class Pages 127134 in Design Patterns Printer Example A system may have many printers but it should should only have one printer spooler Class Diagram Singleton public static getInstance public sampleOperation public getData private static Singleton private static Singleton instance private sampIeData Code for Using a Singleton Singleton myVariable Singleton getInstanceO Type data myVariablegetData Type result myVariablesampleOperation g Singleton s Code public class Singleton private static Singleton instance private Singleton public static Singleton getInstance if instance null instance new Singleton return instance Singleton Benefits 1 Controlled access to sole instance 2 Reduced name space 3 Easy refinement of operations and representation 4 Allows a variable number of instances 5 More flexible that static methods that do the same thing g Discuss with a Partner Try to name as many programs that you have used or written that could benefit from implementing a Singleton structure For Example It might be good for a program X to use the Singleton pattern because Structural Patterns Structural patterns are concerned with how classes and objects are composed to form larger structures Structural class patterns use inheritance to compose interfaces or implementations Types of Structural Patterns Ada pter Makes one interface compatible with another Bridge Separates an object from its abstraction so the two can be changed independently Com posite A treelike hierarchy of objects that lets a client treat all the individual objects uniformly PI OXY Acts as a placeholder for another object to control access to it Flyweig ht Structure for sharing objects in order to save space Fagade Single object that represents an entire subsystem l Decorator Adds responsibilities to an object dynamically Page 137 Design Patterns Problem Shazbotl I have a power cord with a ground and a power socket with only two holes I need to use both parts but they won t t together s Solution Adaptee Adapter Target Adapter Converts the interface of one class into a form that a second class understands Lets two classes with previously incompatible interfaces work together Pages 139150 in Design Patterns Discuss with a Partner Why would a developer want to be able to make two interfaces compatible Adapter That Uses Object Composition Adaptee speci cRequestO g Adapter With Multiple Inheritance Adaptee speci cRequestO A A Example Adapter That Uses Object Composition Quadn39lateral quadrilateralo i Code 7 class Adapter extends Quadrilateral public Adaptero draw is an abstract method in class Quadrilateral public draw pointl p0int2 p0int3 p0int4 bottomLeftCorner pointl sideLength p0int2X 7 p0int1X Squaredrawb0tt0mLe Corner sideLength Example Make SQL Easier to Use public querytabe column target initialize table connection here or preferably in a constructor resultSet StatementexecuteQuery SELECT target FROM tabe WHERE column target list resultSettoList return list Bene ts Makes old code more reusable Lets you override adaptee s behavior Consequences Adapter will have to be changed when adaptee s interface is changed Makes it harder to override adaptee l The End if Questions Agenda Patterns AgileXP I ISOCMM M STATEUNWEHSHV Design Patterns Inspired by architect Christopher Alexander Each pattern describes a problem thch occurs over and over again in our environment and then describes the core of the solution to that roblem in such away that you can use his solution a m39 39 over without ever doing it the same way Ice Design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a pa lcular context The design pattern identifies the articipating classes and instances their roles and co aborations and the distribution of responsibilities NC STATEUNWEHSHV Why Design Patterns Experienced designers Rarely start from first princi les Apply aworking handbook of approaches Software patterns are a first step toward a design handbook for software engineerin the enumeration and elaboration of the basic parts of the conceptual side of software Patterns capture and pass on the knowledge of these experienced designers Support evaluation of alternatives at a higher level of abstraction NC STATE UNWEHSHV Your Book Gang of Four book 23 design patterns We ll go over 12 of them in class There are hundreds of patterns in the literature so we re just scratching the surfac The Learning Process Internalization M STATEUNWEHSHV Model View Controller Controller Data Model lllc STATE UNllE sllv A other 5 data models and methods ObjectOriented Design Principles 1st Object Oriented Design Principle Ch 1 p 18 Program to an interface notan implemenmtlon 2quotd Object Oriented Design Principle Ch 1 p 20 Favor object composition over class inherimnce M STATEUNWEHSHV Inheritance vs Composition 1 Inheritance 1 ISA lt1 public class Fruit public class Apple exkends Fruit NC STATE UNWEHSHV Inheritance versus Composition 2 Chapter 1 p 18 Inheritance define the implementation of one class in terms of another s A Reuse by subclassing white boxquot reuse quotquot 39 39 Visible break encapsulationquot Change in parent class 9 change in subclass Straightforward defined statically at compile time NC STATE UNllIEHSlIV Inheritance vs Composition Bad Example Composition HASA public class Fruit public class Appe F link aggregation yvalue I private Fruit InkFruit generated by TogetherSo NC STATE UNIVEHSHV Inheritance versus Composition 2 Composition new functionality obtained by assembling or composing objects to get more complex functionality Has a bjects have welldefined interfaces black boxquot reuse No internal details of objects are v b e Defined dynamically at runtime through objects acquiring references to other objects Any object can be replaced at runtime by another as long as they have the same type news L 39 and 39 Classesclass hierarchies will remain small and less likely to grow into unmanageable monsters System behavior depend on interrelationships instead of being de ned in one class NC STATEUNWEHSHV Agile ManifestoAlliance gt XP SCRUM DSDM Adaptive Software Development Crystal FDD gt February 2001 Snowbird UT gt Agile Alliance gt Started as 17 methodology authors and practitioners gt Agile Manifesto Values gt Individuals and interactions over processes and tools gt Working software over 39 39 gt Customer collaboration over contract negotiation gt Responding to change over following a plan NC STATEUNWEHSHV R UAgiIe IE Employ an empirical process control model gt De ed process repeatable with predictable results gt Empirical process all aspects not fully known gt Inspect frequently and adapt Emergence g gt Requirements gt Technology g Self Organization gt Team members not constrained by roles gt Team members not constrained by obsolete task plans NcsTATE NilEH V Let Common Sense Prevail Process Discipline Yes No Creative Quallty Chaos 2 BMindess Mindless ureaucracy Chaos Common Sense With thanks to Sanjiv Ahuja fomler President and COO of Telcordia Technologies NC STATE UNIVEHSHV Now that you39re Iso 9000 Certified we can do businesswithyou ISO 9000 ISO is the International Organization for Standardization It is located in Switzerland and was established in 1947 to develop 39 ternational standards 39n man areas The term ISO 9000 refers to a set of quality management standards ISO39s purpose is to facilitate international trade by providing a single set of standards that people everywhere would recognize and respect You generally become ISO 9000 certified because your customers expect you to do so or because a governmental body has made it mandatory NC STATE UNWEHSHV Becoming Certified You then develop a Quality Management System that meets the requirements specified by ISO 90012000 Examples of Major Categories Establish your quality system Document your quality system Support quality Satisfy your customers Establish a quality policy Carry out quality planning Control your quality system Perform management reviews Provide quality resources Provide quality infrastructure Monitor and measure quality NC STATE UNlllEHSlIV Becoming Certified With ISO they don t try to tell you how to do anything If you document follow it and produce quality products that s OK A Registrar come to your site to audit the effectiveness of your Quality Management System Actually an official auditor does not have to certify you you can do it yourself Customers will more likely believe an independent external auditor NC STATE UNlllEHSlIV What is yo Can we be your software vendor m STATE UNIVERSH Capability Maturity Model CMM for Software The SWCMM describes good engineering and management practices and prescribes improvement priorities Created by the Software Engineering Institute SEI which is located at Carnegie Mellon University The SEI is funded by US Department of Defense CMM is geared toward the kinds of projects the US Department of Defense want As opposed to ISO 9000 the CMM does say what you need to do However it does not say how you need to do it The CMM is tailorable and should be applied with common sense NC STATE UNlllEHSllV Capability Maturity Model Defacto standard for assessing and improving software processes NC STATE UNWEHSHV Overview of the Software CMM 1 18 Key Process Areas KPA 52 goals of the KPAs Level 1 Initial Competent People and heroics Level 2 Repeatable Project Management Processes Requirements Management Software Project Planning Software Project Tracking and Oversight Software Subcontract Management Software Quality Assurance Software Configuration Management NC STATE UNIVERSITY optimizing De ned WINNING Inllial Key Process Areas KPA Overview of the Software CMM 2 Level 3 Defined Engineering Processes and Organizational Report Organization Process Focus Organization Process Definition Training Program Integrated Software Management Software Product Engineering Intergroup Coordination Peer Reviews Level 4 Managed Product and Process Quality Quantitative Process Management Software Quality Management NC STATE UNIVERSITY Manama unfilled MIIBIBME Initial Overview of the Software CMM 3 Level 5 Optlmlzmg mm Continual Process Improvement mum Defect Prevention Hummus Technology Change Management I Process Change Management mm NC STATE UNIVERSITY XP satisfaction of key process areas given the appropriate environment Level Key process area Satisfaction 2 Requirements management H 2 Soltware project planning H 2 H 2 Soltware subcontract management 7 2 Soltware quality assurance 2 3 Organization process locus 3 3 Training program 7 3 Integrated software management 7 3 H 3 Intergroup cuordination H 3 eer reviews H 4 Quantitative process management 7 4 Soltware quality management 7 5 Defect preven ion 5 Technology change management 5 Process change management 7 s Partially addressed in XP Largeh addressed m xv perhaps by Milemm Nat addressed in XP r t SOURCE Extreme Programming from a CMM Perspective IEEE Software NovDec 2001 NC STATE UNIVERSITY Other CMMs People CMM is a framework that helps organizations successfully address their critical people issues ls based on the best current practices in fields such as human resources knowledge man39a elment and organizational development the People C guides organizat ns in improving their processes for managing and developingt ei wor orces CMMIntegration improving your organization39s p cesses and your ability to manage the development acqui tion and maintenance of products and services CMM Integration places proven practices into a structure that helps your organIzation assess Its organizational maturity and process area capability establish priorities for improvement and guIde the Implementation of these Improvemen s m STATEUNWEHS W Comparison of CMM and ISO 9000 Both Say what you do do what you say According to the SEI CMM focuses on continuous process improvement ISO addresses the minimum criteria for an acceptable quality ystem M STATEUNWEHSHV q Overview Chapter 5 intro Behavioral Patterns Types of Behavioral Patterns Chain of Responsibility q Behavioral Patterns I concerned with algorithms and the assignment of responsibilities between objects I describe patterns of communication between classes and objects characterize complex control flow shift your focus away from flow of control Types of Behavioral Patterns Class Patterns IemplateMetllod stepbystep algorithm w inheritance nterpreter grammar as a class hierarchy Object Patterns MedLath indirection for loose coupling Chain of Responsibility requests through a chain of candidates Observer defines and maintains dependencies Strategy encapsulates an algorithm in an object Command encapsulates a request State change behavior according to changed state Visitor encapsulated distributed behavior Iterator abstracts traversal and access Chain of Responsibility Gives more than one object a chance to handle the request to avoid coupling Chain the receiver objects in a linked list and pass the request along the chain until an object handles it in q Requester and Receiver Requester has no idea who handles it Implicit Receiver First Receiver first Object Handles Forwards q Undercover To ensure that the receiver remain implicit objects shares a common interface accessing its successor on the chain lChain of Responsibility Amechamcal sumngban cum ispassed m until a tube can acceptthe cmn wzs was win sum Behavioral Application more than one object can handle a request and the handler is not known issue a request to one of several objects without specifying the receiver explicitly set of objects that can handle a request should be specified dynamically lChain of Responsibility The Chain afReSparmbllrty a sdemmmredmme military whae some undalmg asks r g or approval and the request is request up the chain of command Behavioral Participant When Handler De nes and interfaoe for handling requests ems the suocessor link d 9 3 n a E I m 3 Han ls requests it is responsible for Can acoess its suocessor If it can handle the request it does or it forwards the request to Its sucoessor rent Initiates the request to a OoncreteHandler object on the chain a client issues a re uestr the requst propagates along the o chainuntil a Concrete and er object takes responsibility handling It Consequences Advantages Reduced coupling Added Flexibility Disadvantages Receipt is not guaranteed q Implication Implementing the successor chain Connecting successors Representing requests Automatic forwarding in Smalltalk Strategy Pattern Parul Patel Josh Goodrich Justin Plotkin Jonas Wei Purpose of Strategy Pattern G Encapsulate different algorithms 6 Strategy lets the alogorithm vary in dependantly from the clients that use it 73 The Strategy pattern defines an abstract policy for performing an algorithm At the same time it provides multiple mechanisms that can comply with that policy thus letting mechanism vary independently from the policy required Use When You have many related classed that differ only in their behavior You need different variants of an algorithm Z39An algorithm uses data that clients shouldn39t know about lt helps to avoid exposing complex algorithmspecific data structures When you have several conditional statements in the program Strategy Pattern Example 1 o Situation A GUI container object wants to decide at runtime what strategy it should use to layout the GUI components it contains Many different layout strategies are already available n Solution Encapsulate the different layout strategies using the Strategy pattern 3 Heyl This is what the Java AWT does with its LayoutManagersl Container t LayoulManager V V FlowLayout EorderLayout CardLayoul Strategy Pattern Example 2 o Situation A class wants to decide at ruurlime what algorithm it should use to son an army Many different suit algorithms are already available Solution Encapsulale tho different SOl39l algorithms using the Strategy patteinl Benefits Families of related algorithms 2An alternative to subclassing Easier to vary algorithm Removes hardwiring rtStrategies eliminate conditional statements Drawbacks G The application must be aware of all the strategies to select the right one for the right situation 6 Increased number of object 6 Context and the Strategy classes normally communicate through the interface
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'