Software Design CSE 335
Popular in Course
Popular in Computer Science and Engineering
This 18 page Class Notes was uploaded by Donnell Kertzmann on Saturday September 19, 2015. The Class Notes belongs to CSE 335 at Michigan State University taught by Staff in Fall. Since its upload, it has received 15 views. For similar materials see /class/207422/cse-335-michigan-state-university in Computer Science and Engineering at Michigan State University.
Reviews for Software Design
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: 09/19/15
Synthetic OOD Concepts and Reuse Lecture 3 Separation of concerns Topics Separation of concerns as a general principle for managing complexity in software designs Example problem Need to isolate operations over composite structures Visitor pattern Systematic design technique for encapsulating operations over such structures into a single class Softw design body of knowledge Organized around a set of core principles Rigor and formality Separation of concerns Abstraction Anticipation of change Modularity S ource Generallty Fundamentals of Software Engineering 39 Crementallty by Ghezzi Jazayeri and Mandrioli Goal At end of this courseyou should be able to apply these prmcnples With pro cnency In real deSIgn contexts Quote from Edsgar Dijkstra Let me try to explain what is characteristic for all intelligent thinking It is that one is willing to study in depth an aspect of one s subject matter in isolation for the sake of its own consistency all the time knowing that one is occupying oneself only with one of the aspects We know that a program must be correct and we can study it from that viewpoint only we also know that it should be efficient and we can study its efficiency on another day so to speak In another mood we may ask ourselves whether and so why the program is desirable But nothing is gained on the contrary by tackling these various aspects simultaneously It is what sometimes have called quotthe separation of concerns quot which even not perfectly possible is yet the only available technique for effective ordering of one s thoughts that know of This is what mean by quotfocusing one s attention upon some aspect it does not mean ignoring the other aspects it is just doing justice to the fact that from this aspect s point of view the other is irrelevant t is being one and multipletrack minded simultaneously Separation of concerns SOC Very general principle of software engineering indeed any intellectual activity Suggests that we should manage complexity by separating or avoid unnecessarily mixing conceptually unrelated aspects of a problem or solution A clean separation allows each concern to be dealt with in isolation and for the composition of concerns to be well understood 00 Design is flush with patterns and idioms for separating concerns Opportunity for SOC in 00 Design Problem Program understanding when code contains interleaved strands that accomplish distinct purposes Code that implements these distinct purposes tends to be tangled together Code for a single purpose may be scattered across many classes and functions Concerns Each distinct purpose or feature Idea Manage complexity by disentangling these functionally distinct code strands Motivation Suppose we have a class hierarchy that instantiates the composite pattern Eg expressiontree hierarchy Lots of polymorphic operations that we might want to implement Eg type checking Eg pretty printing Eg evaluation Question Suppose we have an existing Expr hierarchy that supports type checking and evaluation but not pretty printing How many classes must we modify in order to add pretty printing Visitor pattern Allows addition of new polymorphic operations to a class hierarchy without modifying any of the classes Requires two hierarchies Original composite hierarchy Visitorclass hierarchy New operations implemented by specializing visitor class hierarchy More precisely Visitorclass hierarchy must have a most abstract root class Every class in the subject hierarchy provides a polymorphic accept operation which takes a reference to the visitorhierarchy root class as a parameter invokes a subjectclass specific method on this parameter passing itself ie the object that received the accept message as a parameter Eg the body of accept method in class X would invoke method visitX on visitor object passing this as a parameter Example Expression Visitor class ExprVisitor public virtual void visitLiteralExprLiteralExpr virtual void visitAddExprAddExpr virtual void visitVarExprVarExpr virtual void visitSubtractExprSubtractExpr Accept operation class Expr public virtual Expr virtual void acceptExprVisitorampO protected Expr class LiteralExpr public Expr public virtual void accept ExprVisitoramp v vvisitLiteralExprthis Accept operation continued class AddExpr public Expr public void accept ExprVisitoramp v protected Expr left Expr right void AddExpraccept ExprVisitoramp v left gtacceptv right gtacceptv vvisitAddExprthis Example Evaluation visitor class EvaluateVisitor public ExprVisitor public double getValue void visitLiteralExpr LiteralExpr void visitVarExpr VarExpr void visitAddExpr AddExpr void visitSubtractExpr SubtractExpr protected stackltdoublegtr valStack Evaluation visitor continued void EvaluateVisitorvisitLiteralExpr LiteralExpr l valStackpushl gtvalue void EvaluateVisitorvisitAddExpr AddExpr a double rightValvalStacktop valStackpop double leftValvalStacktop valStackpop valStackpush leftVal rightVal Inclass activity Suppose we have Expr e new AddExpr new LiteralExpr5 new LiteralExpr4 Draw a UML sequence diagram that depicts the execution of EvaluationVisitor ev e gtacceptev Sequence diagram notation opera unE c a crealeC arg apem onE m n exacute order resukT msultv g L5 anunncn dlagmm mm msam mm Many apnhcmmns have a m or amqu am nasswe mums They mm m deslmy necks Gammanew Modem and Design mm we 59mm Edmun m M chae aw Madame Hummngh SM n m m592u 4 mans Penman E uuahun m Hnynr 5mm wnr m AH mm msvvw Sequence diagram example CuslomerTable campme commwssloquot ssmca Jeva swimmer commission A gun 35 Sluunnm dlagvam wm passwn objm munncc mugmms can m m wp emenlamn m vparalms wisdomvied Modem and awn wun um sebum Ed hun my mama em m drama Humuawn SW 0 w m gzu 4 a anus Peavsm tducahun m ngm 5mm mm m AH mm msmm Inclass activity Develop a prettyprint visitor for the example Expr hierarchy
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'