1 / 5

CS 350 – Software Design A Standard Object-Oriented Solution – Chapter 4

CS 350 – Software Design A Standard Object-Oriented Solution – Chapter 4. Before studying design patterns, many programmers solve a problem by starting with a general solution and refine it until you are ready to code (OK or you do not design at all) Specialization is often the intuitive answer.

adonai
Download Presentation

CS 350 – Software Design A Standard Object-Oriented Solution – Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 350 – Software DesignA Standard Object-Oriented Solution – Chapter 4 Before studying design patterns, many programmers solve a problem by starting with a general solution and refine it until you are ready to code (OK or you do not design at all) Specialization is often the intuitive answer. So to solve the problem. Think about each feature. For example, a Slot has two implementations. One for each CAD system. Therefore: A SlotFeature class could be implemented and you could have two derivations, one for each version of CAD.

  2. CS 350 – Software DesignA Standard Object-Oriented Solution – Chapter 4 This is a simple and very straightforward solution. Indeed, it’s not even difficult to code. See how the simple idea is expanded to the other features:

  3. CS 350 – Software DesignA Standard Object-Oriented Solution – Chapter 4 The previous solution was simplified. In reality, V1’s objects would need to access the V1CAD system and its associated functions. Meanwhile, V2’s objects would need to access their corresponding object in the V2CAD system. This is shown below:

  4. CS 350 – Software DesignA Standard Object-Oriented Solution – Chapter 4 Look at the following code: Chapter4Code.txt Note the author doesn’t worry about polymorphism. This is because the expert system treats each feature as a specific type. It needs to know what type it is, because different types have different data. What he is trying to do here is handle the multiple CAD versions. However, his system is not good, because: Redundancy Among Methods: Many methods calling V1 are similar. i.e. V1GetX for a Slot is similar to V1getX for a Hole. Messy: When things are not clean, it’s usually a sign that your design is not ideal. Tight Coupling: features are indirectly linked. If a new cad system is added or an old one modified, then all the features need to be modified. This is bad. Weak Cohesion: Methods to perform core functions are scattered amongst classes.

  5. CS 350 – Software DesignA Standard Object-Oriented Solution – Chapter 4 Let’s look to the future. What happens if we add a third CAD system? A combinatorial explosion! Look what we have now: There are 5 types of features Each type of feature has a pair of classes, one for each CAD system What happens if we add a 3rd system? We still have 5 types of features Now each type of feature has a three of classes, one for each CAD system In addition, if we add a feature we have to add as many classes as we have CAD systems. This is an n x m explosion. Not good!

More Related