Outline • Designing a computational community for WordGames – What are Word Games? – Communities: • Transformers and Connections • User and the System – Building a Transformer • High level design • Low level design – Rules and Methods – Classes and Instances – Fields and Constructors Fundamentals of Software Development 1 } Next session Slide 1 Word Games: Transformers • Our system will have many transformers like – Pig Latin These transformers will be interconnectable modules like Legos! • Hello ello-Hay • How have you been? ow-Hay ave-hay ou-yay een-bay? – Ubby Dubby • Hello => Hubbellubbo • How have you been? => Hubbow hubbave yubbou bubbeen? – Capitalizers: “HELLO” – Name Droppers: (“Maria says Hello”, “Rumi says Hello”) – And more, e.g: • • • • Combiner: Listen and combine two inputs into one Repeaters: Produce two outputs from one Delayers: Don’t produce anything until they are signaled Network-senders: Move words from one computer to another Fundamentals of Software Development 1 Download and run the WordGames demo Slide 2 Designing a Community • What are the key questions for designing a computational community? – – – – Determine the desired system behavior Identify the entities Specify entity interaction Specify entity operation • How to start? – Top-down: high-level and add details – Bottom-up: low-level details combine to form system – Today: in the middle, with a community of interacting transformers and connections Fundamentals of Software Development 1 Slide 3 A Community of Transformers and Connections • Each Transformer is an entity – Transformer interactions, version 1 • Read a word/phrase (from a connection) • Write a word/phrase (to a connection) • Each Connection is an entity – Like tin-can telephones • So Transformers don’t need to know about each other – Connection interactions • Accept a word/phrase written to it • Supply that word/phrase when requested (read) Fundamentals of Software Development 1 Slide 4 Other Entities in the Community • The User – User interactions • Create a Transformer (of a specified type) • Connect two Transformers (in a particular order) • How can we accomplish creating and connecting transformers? • Answer: Through a user interface • Along with modifications to the Transformer interactions – User interface interactions • Create a Transformer (of a specified type) • Create a Connection between two Transformers Fundamentals of Software Development 1 Slide 5 Transformer interactions, version 2 • How do Transformers interact with other entities? – Each Transformer has Connections • Accept input Connection(s) • Accept output Connection(s) – Communication • Read word(s) (from a Connection) • Write word(s) (to a Connection) Fundamentals of Software Development 1 Slide 6 Recap • We have answered: – System Behavior • Allows a user to play various word games – Members of the community • One instance of User and User interface • Many instances of Transformers & Connections – Entity Interaction • Read/write through connections • What is the remaining question? – Answer: Entity operation • How does each entity work? What goes inside each one? – For example: How do Transformers work? Is a Transformer a community (if so, of what?) or an instruction-follower? (See next slide.) Fundamentals of Software Development 1 Slide 7 Building a Transformer • Transformer implementation must be able to: – Accept input Connection(s) – Accept output Connection(s) – Have its own instruction-follower that acts independently to: Read input, transform, write output • Different types of transformers may do the transformation differently • Each Transformer is itself a community! – ConnectionAcceptors (input/output) • E.g., acceptInputConnection: “store the input away someplace so that you can use it later” – Entities that perform startup tasks when the Transformer is constructed – Independent instruction-follower • We’ll focus on this Fundamentals of Software Development 1 Slide 8 goodbye Transformer Example: Capitalizer Hello Capitalizer 1 Capitalizer 2 GOODBYE • Capitalizer: 1. Read the input 2. Produce a capitalized version of it 3. Write this as output HELLO • Each Capitalizer does the same thing but with a different output based on its input Fundamentals of Software Development 1 Slide 9 Transformer Example: NameDropper Maria Hello Rumi Rumi says Hello • NameDropper: 1. 2. 3. • Maria says Hello Read the input Produce a phrase containing its own name, the word “says,” and the input Write this as output Each NameDropper has its own name to drop – – All Capitalizers have the same instructions and same data All NameDroppers have the same instructions and the same structure, but each has its own data associated with it (i.e., the name that it drops) Fundamentals of Software Development 1 Slide 10 Other Transformer Examples • Repeater: 1. 2. 3. • Read the input Write this to one OutputConnection Write this to the other OutputConnection PigLatin: 1. 2. 3. Read the input Produce a new phrase containing all but the first letter, then the first letter, then “ay” Write this as output Fundamentals of Software Development 1 Slide 11 Recap • We have answered (at least partially): – System behavior? • Allows a user to play various word games – Members of the community? • (one) User interface and User , (many) Transformers, (many) Connections – How do they interact? • • User operates user interface, which creates Transformers and Connections Transformers communicate through Connections – What goes inside a transformers: ConnectionAcceptors, ... plus an instruction-follower with rules, such as for Capitalizer: 1. Read input 2. Produce capitalized version of it 3. Write output • Next session: how to implement such rules! Fundamentals of Software Development 1 Slide 12
© Copyright 2025 Paperzz