Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Imagine you want to extract information from a CAD system to feed an expert.

Similar presentations


Presentation on theme: "CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Imagine you want to extract information from a CAD system to feed an expert."— Presentation transcript:

1 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Imagine you want to extract information from a CAD system to feed an expert system. I actually did something very similar to this on my coop! We wrote an expert system that accessed a database and produced code that generated CAD diagrams automatically. While the expert system was object oriented, the actual code I wrote was in straight C, so I had all sorts of issues that a modern programmer would not have. The CAD output was actually graphical instruction sheets to tell circuit board assemblers how to put together a circuit board piece by piece. We had “objects” like resistors and capacitors. In the example in the book, the idea is the same. They want to create a system to create stamped metal sheets with cutouts called features.

2 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Slot Straight cuts in the metal with a constant width Hole Circle cuts in the sheet metal. Cutout Squares with either squared or rounded edges. Special Preformed shapes that are not slots, holes, or cutouts. Irregular Anything else. Geometry The description of how a piece of sheet metal looks: the location of each of the features and their dimensions and the external shape of the sheet metal. PartThe piece of sheet metal itself.

3 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Image you wanted to create the shape shown in the bottom left. Given the tools we have, you can create it in many ways. One would be to make three cuts using three features (a square and two slots.)

4 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Even given the solution presented, multiple methods can be applied to create the desired geometry. A bad approach to cutting out the openings. This sequence results in weakened, bent sheet metal.

5 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 A better approach follows that will not bend the metal as much in the process of creating it:

6 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 This software, like most, will change over time. Interestingly in this example, there are two major components that may change: the expert system and the CAD system. These systems can vary independently. Either the CAD system can be upgraded or the Expert System can be enhanced. The challenge is to minimize the impact one has on the other. The author’s problem was he already had two CAD systems and a third was coming.

7 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Since only one version of the expert system could use either version of CAD System, the CAD systems needed to look the same to the expert system. A simple intuitive approach is depicted in the following figure:

8 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 The expert system relates to the CAD system via the Model class. The Main class instantiates the correct version of the Model.

9 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Version 1 of the CAD is a library of subroutines. Here’s how it works 1. Open model XYZ and return a handle to it. 2. Store this handle as H. 3. For the model referred to as H, tell me how many features are present, store result as N. 4. For each feature in the model referred to by H (from 1 to N) 1.For the model referred to by H, tell me the ID of the ith element and store as ID. 2.For the model referred to by H, tell me the feature type of ID and store it as T. 3.For the model referred to by H, tell me the X coordinate of ID and store as X. (Use T to determine the proper routine to call, based on type. Painful way to solve the problem. No OOP.

10 CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Version 2 of the CAD has an object oriented implementation. The geometry is stored as objects. The system requests a model, it is handed an object. The model object contains a set of objects, each representing a feature.


Download ppt "CS 350 – Software Design A Problem That Cries Out for Flexible Code – Chapter 3 Imagine you want to extract information from a CAD system to feed an expert."

Similar presentations


Ads by Google